﻿# llama.cpp CUDA few-row MMQ: speculative verification has its own matrix regime

The b12342 few-row MMQ kernel targets a narrow CUDA shape regime; verification speed and total speculative-decoding benefit remain separate results.

Author: Retrivium team
Updated: 2026-11-15
Canonical URL: https://retrivium.ai/journal/week46-engine-cuda-fewrow-mmq-speculative-verification/
Language: en

llama.cpp b12342 adds a CUDA quantized matrix-multiplication kernel for two to 24 activation columns. Upstream identifies small batches and speculative verification as motivating cases. The optimization targets weight reuse across a few columns, so its value depends on internal operation shape rather than the label “speculative decoding” alone.

## Several columns can reuse one weight decode

The PR contrasts repeated per-column work with a new kernel that decodes weights once for multiple activation columns. It also explains why a large-batch kernel can be inefficient at these small sizes. This is a shape-specific reuse strategy, not a change to the statistical acceptance rule of speculative decoding. The supported quantized formats and GPU generations are part of the implementation boundary and should accompany any test.

## Verification columns are not accepted tokens

A verification pass may process candidate positions that are later rejected. Faster evaluation of those columns does not directly specify useful tokens produced per second. A serving comparison must record draft cost, verification cost and accepted progress, rather than counting all evaluated candidates as output. This distinction is especially important if a configuration change alters the number of drafted positions while also changing which matrix kernel is selected.

## Compare the same arithmetic before the pipeline

A proposed backend test uses the same quantized matrix and activations across the old and new implementations, including boundary column counts and representative row sizes. Check numerical error against a trusted reference before timing. Then profile the actual verification graph to establish that the few-row route is selected. A standalone kernel gain cannot explain an end-to-end result unless the application spends a meaningful fraction of time in that operation.

## Avoid a universal small-batch speed claim

The release publishes a kernel with explicit format and hardware scope. Small batches outside that scope can still use another route. Report the actual matrix dimensions and device with any result, and keep ordinary decode and prompt processing separate from speculative verification. This article reports the upstream mechanism and proposes measurement boundaries, without importing a microbenchmark ratio as a prediction for every model or declaring new independent throughput measurements.

## Sources

- [llama.cpp b12342 release](https://github.com/ggml-org/llama.cpp/releases/tag/b12342)
- [llama.cpp pull request #31533](https://github.com/ggml-org/llama.cpp/pull/31533)

## Related reading

- [llama.cpp and vLLM: the fixed-concurrency RTX 4090 study](/journal/llama-cpp-vllm-4090-fixed-concurrency-2025-comparison/)
- [CUDA events and request time: different measurement boundaries](/journal/gpu-cuda-events-wall-time/)
