End to end: Qwen2.5-1.5B-Instruct
All attention and MLP projections use round-to-nearest 4-bit weights (group 128) and our kernels. Embeddings, lm_head, attention (SDPA) and RoPE stay in fp16 on both sides. Both sides run the same small runner under CUDA graphs with a static KV cache, so the only difference is the kernels.
Decode speed
Model size (L4)
On the smaller model the fp16 lm_head is a bigger share of each token, so the same kernels help less, and round-to-nearest 4-bit costs more quality.
| model | fp16 tok/s | ours tok/s | speedup | fp16 ppl | 4-bit ppl |
|---|---|---|---|---|---|
| Qwen2.5-0.5B-Instruct | 128.4 | 178.8 | 1.39x | 15.79 | 19.09 |
| Qwen2.5-1.5B-Instruct | 59.5 | 118.2 | 1.99x | 10.65 | 11.90 |
Where a decode token's time goes
The swapped layers are timed alone in their own CUDA graph; the rest is the full step minus that. The fp16 lm_head (151936 x 1536) alone reads 0.47 GB per token, so it becomes the next thing to fix.
L4
| backend | decode tok/s | swapped layers ms/token | prefill tok/s (T: tok/s) | WikiText-2 ppl | linear weights GB |
|---|---|---|---|---|---|
| fp16 | 59.5 | 11.36 | 128: 5743, 512: 11782, 2048: 12409 | 10.654 | 2.62 |
| ours | 118.2 | 3.28 | 128: 7683, 512: 11573, 2048: 12346 | 11.900 | 0.70 |
| ours_cuda | 114.4 | 3.62 | 128: 7650, 512: 11545, 2048: 12262 | 11.900 | 0.70 |
| w4_ref | - | - | - | 11.901 | 0.70 |
| ours_fp8 | 91.8 | 5.64 | 128: 7877, 512: 12173, 2048: 12889 | 10.719 | 1.31 |
Runner check against Hugging Face: max abs logit difference 0.034 on the prompt; perplexity 10.654 vs HF 10.654. Greedy tokens are identical for the first 14 of 32 steps, then a near-tie flips and the texts drift apart (expected from fp16 rounding order).
Greedy outputs (L4)
Greedy decoding, cut at 64 new tokens. The 1.5B model gets dates wrong in both versions; 4-bit changes the wording, not the gist.
H100
| backend | decode tok/s | swapped layers ms/token | prefill tok/s (T: tok/s) | WikiText-2 ppl | linear weights GB |
|---|---|---|---|---|---|
| fp16 | 283.1 | 2.32 | 128: 21500, 512: 65072, 2048: 108242 | 10.654 | 2.62 |
| ours | 397.9 | 1.31 | 128: 16292, 512: 48927, 2048: 79706 | 11.900 | 0.70 |
| ours_cuda | 338.6 | 1.74 | 128: 16400, 512: 48708, 2048: 79961 | 11.900 | 0.70 |
| w4_ref | - | - | - | 11.901 | 0.70 |
Runner check against Hugging Face: max abs logit difference 0.029 on the prompt; perplexity 10.654 vs HF 10.654. Greedy tokens are identical for the first 14 of 32 steps, then a near-tie flips and the texts drift apart (expected from fp16 rounding order).
Greedy outputs (H100)
Greedy decoding, cut at 64 new tokens. The 1.5B model gets dates wrong in both versions; 4-bit changes the wording, not the gist.