Where a decode step goes on an RTX 4090: in a 4-bit 7B model, the 16-bit output head is a fifth of every token
At one request in flight, every token an LLM generates costs one decode step: the forward pass through the layers, then the output head (the last hidden state times the vocabulary matrix, one score per token in the vocabulary), then, if the output must follow a schema, a mask over those scores, and finally the sampler that picks the token. Quantizing a model to 4 bits shrinks the layers, but the 4-bit checkpoints people download leave the head in 16 bits. So the smaller the layers get, the larger the head’s share becomes.
I wanted to know how large, on a consumer card, and whether either end of the tail is worth a kernel: a smaller or faster head, or a kernel that fuses mask and sampler.
The short answer, for Qwen2.5-7B-Instruct on one RTX 4090 with vLLM v0.30.0: in the 4-bit model the head takes 1.14 ms of a 6.0 ms token, 19%. It already reads its 1.09 GB at 95% of the card’s memory bandwidth, so a faster kernel cannot help; storing the head in fewer bits can, by up to 14% per token. Mask and sampler together take 2%, too little for a fused kernel to matter.
The setup
- One RTX 4090 (24 GB), NVIDIA driver 550.144.03, vLLM v0.30.0 (CUDA 12.9 build), served with
vllm serve <model>and nothing else: the V2 model runner with asynchronous scheduling, and the model’s own default sampling settings (temperature 0.7, top-p 0.8, top-k 20, repetition penalty 1.05). - Two checkpoints of the same model: Qwen2.5-7B-Instruct-GPTQ-Int4 (4-bit layers on the Marlin kernels, 16-bit head) and its 16-bit original. The head is the same 152,064 x 3,584 matrix, 1.09 GB, in both: 24% of the bytes a decode step reads in the 4-bit model, 8% in the 16-bit one.
- Requests: 256-token prompts, 256 output tokens, streamed. Plain text, and JSON constrained by a schema (an array of 400 to 600 integers) so that the grammar mask is active on every step. One request in flight, and eight.
How the step is split. A patched copy of vLLM’s model runner, loaded only by the timing server, records a CUDA event at every boundary of the step (before and after the forward pass, after the head, after the mask, and inside the sampler). Recording an event never waits for the GPU, and the events are read only after all requests have finished. The difference between two events is the GPU time of that segment.
Checks that the split means what it says, all passed for the cells below:
- The patched server’s gap between tokens is within 3% of an unpatched server’s (it is within 0.4%), so the markers do not slow the step.
- The segments add up to the step period to within 1%. The remaining 0.9% is the only time in a step the GPU waits for anything, so the CPU does not set the pace.
- The head, timed alone in a separate process with the same shape, takes 1.17 ms against 1.14 ms inside the server.
- Five rounds; the head’s share varies by less than 0.001 between them, and other processes used at most 2% of the CPU while each was measured.
Where the step goes
| One request, median over five rounds | 4-bit | 16-bit |
|---|---|---|
| time per output token | 5.98 ms | 15.90 ms |
| forward pass (28 layers) | 4.69 ms | 14.62 ms |
| output head | 1.14 ms (19.1%) | 1.14 ms (7.2%) |
| sampler | 0.11 ms | 0.11 ms |
| grammar mask (JSON only) | 0.005 ms | 0.005 ms |
| mask and sampler, JSON | 2.0% | 0.7% |
At eight requests in flight the picture is the same: the head is 1.16 ms of a 6.03 ms token (19.2%) in the 4-bit model, and mask and sampler stay at 2.1-2.3%.
The head costs the same 1.14 ms in both models, because it is the same 16-bit matrix doing the same work. What changes is everything around it: 4-bit layers cut the forward pass from 14.6 to 4.7 ms, and the head that was 7% of a token becomes 19%.
A faster kernel would not help; a smaller head would
The head reads 152,064 x 3,584 x 2 bytes = 1.09 GB per token in 1.14 ms: 956 GB/s, 95% of the RTX 4090’s 1,008 GB/s memory bandwidth. At one request the head is a matrix-vector product, and this one is already as fast as the memory lets it be. A better kernel can win at most the last 5%.
What can win is reading fewer bytes. vLLM keeps the head in the checkpoint’s 16-bit dtype unless
the quantization config names it ("lm_head": true), and none of the common 4-bit releases of
this model do: GPTQ and AWQ leave it out, the compressed-tensors ones list it under ignore. If
the head read 8-bit or 4-bit weights at the bandwidth it reaches now, the token would get this
much shorter:
These two bars are arithmetic on the measured segments, not measurements of a quantized head; they also leave out any loss of accuracy from quantizing the head. One such route is already proposed upstream: vllm-project/vllm#55494 stores an exact packed encoding of the 16-bit head, so no weight changes, and reports the head 1.28x faster on an RTX 4060 laptop GPU.
Mask and sampler are too small to fuse
With the JSON grammar on, the mask takes 5 µs and the sampler (penalties, top-k and top-p, and the draw) 0.11 ms: 2.0% of a token in the 4-bit model. A kernel that fused the two could save at most that 2%, against about 14% from a 4-bit head. On this card, at this model size, the tail work worth doing is the head.
What to take from it
On an RTX 4090 with a 4-bit 7B model:
- The 16-bit output head is a fifth of every token. It runs at the memory’s speed, so the way to shorten it is a smaller format for the head, not a faster kernel: up to 10% per token at 8 bits and 14% at 4 bits, before any accuracy cost.
- The grammar mask and the sampler cost 2% together; leave them alone.
The measurements cover one and eight requests in flight. With a small model (Qwen3-1.7B) and at 32 requests in flight, some streams received two tokens in one chunk, which this setup does not count as a usable per-token gap, so those cells are not reported.
Reproduce
The harness is at
rockyshi-dev/decode-tail-split: it builds the
prompts, the timing overlay of vLLM’s model runner (the installed vLLM is never edited), runs the
unpatched and patched servers and the head-alone timing, and recomputes every share above from
the raw step records (python -m tailsplit report). The numbers in this post come from a run of
that repository.