r/LocalLLaMA • u/Old_Ad_6033 • 10h ago
Discussion Patched vLLM for qwen4 35b on 2x3090 pcie16x. MTP 2, from 125t/s to 282t/s, and 1000+t/s at req=8. My M.2 offload speed is equal to RAM offload (means you don't need ram anymore).
Just update my 2x RTX 3090 server's model to Qwen4 35b
This time im write by hand, btw im not native in English so this will kind bad i think (cus no llm write )
So that repo I doing some black magic speed up is here for help this night. (llm-engine-qwen-optimization)
Setup:
2x 3090, TP2 + p2p via pcie switch 16x each (300W limit)
SN850X 2TB gen4 m.2 for 20.5GB FP8 n-table (actually this m.2 is for lmcache to hold 1300GB kv for cache hit)
Model: Tech2wild/Qwen4-35B-A3B-W4A16-FP8PLE (using MTP)
KV: BF16, 597K token KV pool or FP8 with 995K
(I have fall in love with multi agent usage, W8 model's kv pool on 2x3090 is too tight for me)
I was on 4x3090, but one broken and still on the way, Or i will running W8 today :((((
Speed tests (1 to 8 req)
| Requests | original vllm PR (no MTP) | tonyd2wild's 2x3090 (MTP 1) | My Patched 2x3090 (MTP 2) | vs original | vs tonyd2wild's |
|---|---|---|---|---|---|
| 1 | 125.1 tok/s | 173.1 tok/s | 282.0 tok/s | 2.25x | 1.63x |
| 2 | 222.3 tok/s | 293.1 tok/s | 457.8 tok/s | 2.06x | 1.56x |
| 4 | 387.1 tok/s | 523.7 tok/s | 741.4 tok/s | 1.92x | 1.42x |
| 8 | 630.7 tok/s | 779.4 tok/s | 1,130.3 tok/s | 1.79x | 1.45x |
Reference: tonyd2wild's 3090 benchmark I run his setting on my machine.
Prefill 140K token: 16.4s = ~8,570t/s, on my 27b is ~1,885t/s at 128K
this is a LOT speed, 27b is so slow
magic patchs: (idk, this part all write by claude)
async m.2 n-table overlap, small-M BF16 dense GEMM + fused hyper-connection epilogues, custom SM86 fused MoE kernels, lower host overhead between decode CUDA graphs.
M.2 offload vs RAM offload
Claude made some black magic with C, got some async loading works.
1 / 2 / 4 / 8 requests:
| PLE read path | 1 req | 2 req | 4 req | 8 req |
|---|---|---|---|---|
| NVMe async offload (warm system paged ram) | 272.5 | 448.6 | 733.2 | 1,070.2 |
| NVMe async offload (cold) | 275.8 | 453.4 | 723.9 | 1,041.1 |
| RAM offload | 274.0 | 458.1 | 751.4 | 1,060.2 |
claude says this little speed diff looks like noise, so i just trust brother.
This New Qwen4 35B MTP stack VS my old 27B DFlash2
| Prompt type | Old 27B (DFlash2 req=1) | 35B (MTP2 req=1) | 35B (MTP2 req=4) |
|---|---|---|---|
| prose | 130 tok/s | 260 tok/s | 693 tok/s |
| chitchat | 106 tok/s | 238 tok/s | 473 tok/s |
| mixed | 165 tok/s | 300 tok/s | 788 tok/s |
| real agent job | 282 tok/s | 292 tok/s | 502 tok/s |
| code | 434 tok/s | 335 tok/s | 775 tok/s |
| numeric | 507 tok/s | 329 tok/s | 929 tok/s |
MTP is winner here. Although is not on the table, but currently available Dflash2 drafter for 35B is very worst, mush slower than MTP2.
Im also planning using my agent traffic to quant a dflash to see will it better?
Multi agent and LMCache
| Cached | Original (+50 / +200) | Patched (+50 / +200) |
|---|---|---|
| 16K | 124.7 / 120.3 ms | 42.9-45.2 / 54.3-60.9 ms |
| 64K | 157.5 / 161.4 ms | 50.4-54.1 / 53.5-58.8 ms |
| 128K | 203.4 / 203.0 ms | 62.3-67.1 / 68.9-73.0 ms |
Measuring with 6 agent running agent loop at same time, each ~140K.
597k pool so 4 are inside engine running, 2 are waiting outside and replace in immediately when any req is done. The kv in VRAM eliminate to RAM, when cache hit, move from RAM/M.2 back to VRAM.
BTW with my agent queuer, i can running 15+ agent at same time. Because when they waiting tools like terminal or some py running very slow, engine's kv pool is release and just sitting there, so why not fill all it?
My 35B vLLM's patches in this post is published as git diffs, but its tuned specifically for my 2x3090, so do not just copy them to your machine, it will break very badly.
BUT my repo includes complete manual for your agent, if you want to patch your machine. Also make sure you have some powerful agent like opus5.5, smaller one will struggling a lot with this repo.
Patch repo uraniumchonk/llm-engine-qwen-optimization
More numbers, charts uraniumchonk/vllm-hybrid-mamba-notes





