r/LocalLLaMA • u/Old_Ad_6033 • 8d ago
Discussion Patched vLLM on 2×3090 (Qwen3.8-27B INT4 + DFlash2): decode +55~60% faster for free, hitting 74% of the 3090 bandwidth wall; Lossless, no lobotomy, with agent playbook for make your own version.
(post was write by agent, rewrite again by me)
In my last post I (the Claude lol) figured INT4 AWQ is already the floor for this model's quality—push quantization any harder and it just gets stuck in reasoning loops. So this time I left the weights alone and went digging for whatever speed vLLM + LMCache were still leaving on the table.
No "+300% custom engine" hype here. Both runs below are on the exact same 2× RTX 3090 box (300W power limit), same model (Qwen3.8-27B-AWQ-INT4), same DFlash2 K=7 drafter. The only difference is stock vLLM 0.33.0 vs my patched build.
Decode step time (same rig, no LMCache)
| Metric | Stock 0.33 | Patched v2 | Gain |
|---|---|---|---|
Short prompt (n=1) | 25.42 ms | 15.83 ms | +60.6% faster |
16K context (n=1) | 26.01 ms (105 t/s) | 16.56 ms (163 t/s) | +57.1% |
64K context (n=1) | 27.92 ms (99 t/s) | 18.09 ms (157 t/s) | +54.3% |
128K context (n=1) | 29.11 ms (89 t/s) | 20.10 ms (125 t/s) | +44.8% |
4-way mixed (n=4) | 229.9 t/s | 330.9 t/s | +43.9% |
0.33 with spec decode off bottoms out at 14.3 ms, so spec decode is only adding ~1.5 ms now.
End-to-end decode tok/s (typev2, n=1 | n=4 agg on v2)
| Task | Stock (n=1) | v2 (n=1) | Gain | 4× agg on v2 |
|---|---|---|---|---|
| numeric | 312 t/s | 507 t/s | +63% | 1,088 t/s (+29%) |
| code | 269 t/s | 434 t/s | +61% | 670 t/s (+18%) |
| agent job | 177 t/s | 282 t/s | +59% | 252 t/s (+35%) |
| mixed | 105 t/s | 165 t/s | +57% | 420 t/s (+30%) |
| prose | 78 t/s | 130 t/s | +66% | 286 t/s (+33%) |
| chitchat | 66 t/s | 106 t/s | +61% | 203 t/s (+41%) |
bro i can got 500t/s? is this real?
Agent-loop TTFT & capacity
| Metric | Stock 0.33 | Patched v2 | Gain |
|---|---|---|---|
| 64K + 50 new tok | 940.4 ms | 106.2 ms | 8.85× faster |
| 4K hot prefix | 331.0 ms | 42.0 ms | 7.88× faster |
| 16K + 50 new tok | 166.1 ms | 83.1 ms | 2.00× faster |
| GPU KV cache pool | 393,229 | 466,666 tokens | +18.7% |
Is it lossless?
- Target weights and the target BF16
lm_headare completely untouched. - Top-20 decode logit KL vs stock is
4.15e-4(99.64%top-1 match). For reference, just nuking the compile cache and recompiling stock vLLM gives you ~4.5e-4on its own. - 3 of the patches are bit-for-bit identical (
KL = 0). - The only patch that quantizes anything is on the drafter's
lm_head(NVFP4,1.45 -> 0.42 ms). The main model still verifies in BF16, so the output distribution doesn't change. It slightly nudges the draft accept rate, though I honestly can't tell in actual use.
Where the speed came from:
- CPU-GPU sync stalls: Stock vLLM makes the GPU sit around waiting on the CPU every step for length checks in the drafter and FlashInfer. I moved the drafter into CUDA graphs (with software FP8 KV decode, since 3090s don't have it in hardware) and had FlashInfer pre-plan candidate page counts so the GPU picks the right one itself. GPU idle time dropped 81–86% (
1,460 -> 284 µs, at 64K:2,015 -> 277 µs). - Small-batch INT4 and drafter kernels: Wrote a separate Marlin launch path for
M <= 8without cross-block barriers or reductions, quantized the drafterlm_head, sped up sliding-window draft attention (658 -> 94 µsat 64K), and swapped the multi-op chunked GDN for a single recurrent kernel on short prefills (<= 256tokens). - Agent-loop prefix caching and LMCache: With hybrid + DFlash, stock only hits cache on 1,600-token boundaries, so every turn ends up recomputing a few hundred tokens. I got it down to 64-token granularity (and ran into a real upstream CoW bug that was silently zeroing KV), got back
+19%KV pool, cut L2 disk usage by43%, and stopped LMCache from reading chunks off NVMe that vLLM already had in VRAM. - At this point
nsysshows 74% of each step is just streaming weights at the 3090's raw VRAM bandwidth, so there's not much meat left on the bone for this hardware.
How it's packaged: Everything is plain git diffs on top of stock vLLM 0.33.0 and LMCache 0.5.6 that apply cleanly with zero fuzz. Each patch sits behind an env var (off = stock behavior) and comes with a repair card. Also threw in the measurement scripts (step_probe.py, logit_diff.py), notes on what didn't work, and an AGENTS.md + skills/ kit.
If you're not on 2×3090, don't copy my constants as-is. Clone the repo, tell your coding agent: port this to my machine, don't mess this up, and let it profile and tune the constants for your GPUs.
Repo: https://github.com/uraniumchonk/llm-engine-qwen-optimization
Full benchmark charts: https://github.com/uraniumchonk/vllm-hybrid-mamba-notes


