Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5.3 KiB
Prefill throughput of the Original serve stack (port)
Branch claude/prefill-throughput. Measurements on the RTX 5090 server (job queue holder2, jobs 700-702) with
the long-context smoke original_serve_long_context_streamed_kv_smoke (LELEKA_ORIGINAL_SERVE_LONG_TOKENS=8000,16000,
greedy, 16 new tokens, INT8 KV, resident window 20480, ceiling 65536, budget 30 GiB, model IQ3_S + KAR L2 + MTP pack
as in job 312). Expert tier "on" = EXPERT_SLOTS=2048 EXPERT_PER_LAYER=yes EXPERT_PROFILE=baseline/profile.bin PCIE_FRAC=0.55. One process per configuration, one pass per prompt (n = 1: indicative, not a charter A/B).
Profile
LELEKA_BRINGUP_TRACE=1 prints one PREFILL-PROFILE line per published chunk (qwen_forward/prefill_profile.rs):
host wall time per stage, nested moe.* and inject spans included in their parents, other = outside every
top-level span. LELEKA_PREFILL_PROFILE_SYNC=1 drains the device at every span end (GPU attribution); on this
workload it changed no stage by more than a few percent, i.e. the stages below are host-bound or synchronous.
Before (job 700, cffbf88, 2048-token chunk, steady state, ms per chunk):
| stage | ms | what |
|---|---|---|
| validate | 4,450 | per-row session validation: quadratic in the chunk, and every row re-ran the dense-source checks |
| moe.ring | 850 | expert DMA ring + grouped MMQ (registered bank, PCIe-bound: ~34 GB of experts per chunk) |
| moe.spans | 650 | host finite rescan of every routed expert's bytes (~1.4 MB each, one thread) every chunk |
| gdn / qsa | 220 / 85 | mixers incl. GR injection |
| input / init | 50 / 50 | per-token KAR/PLE input staging / row upload |
| reads, inject, prepare, finish | 65, 32, 18, 10 | |
| total | ~6,500 | 315 tok/s |
Fixes
19fac1brow validation once per set (linear), same checks and order.5416f4ea routed expert's bank bytes are admitted finite once per bank (bit per layer/expert in the MoE cache).ae283e6pageable (file-mapped, laptop) banks: prefill.cpp'sStagerin the copy ring (helper threads copy into page-locked buffers, check the block scales there, the launching thread DMAs); registered banks unchanged.
Results (RTX 5090)
| build | chunk | tier | 8000 tok/s | 16000 tok/s |
|---|---|---|---|---|
before cffbf88 |
2048 | off | 307 | 311 |
before cffbf88 |
2048 | on | 306 | 310 |
after 5416f4e |
2048 | off | 1,145 | 1,435 |
after 5416f4e |
2048 | on | 1,174 | 1,463 |
after 5416f4e |
8192 | off | 1,922 | 2,887 |
after 5416f4e |
8192 | on (lends 1,891 slots) | 1,883 | 2,828 |
Greedy output ids at chunk 2048 are identical before and after (both prompts, tier off and on). The first chunk of a process still pays the one-time finite admission (~0.7-0.85 s).
After (8192-token chunk, ms): moe.ring 1,110, gdn 585, qsa 254, input 184, init 210, attn+ffn reads 229, inject 125, moe.spans 36, prepare 47, finish 36.
Chunk size and greedy output (jobs 702/703, tier off, 16 greedy tokens; every configuration is deterministic over
two passes on one stack): 8000, 10000 and 12000 tokens answer identically at chunks 2048 and 8192; 16000 tokens
answers identically at 2048, 4096 and 6144 (1,430 / 1,569 / 1,982 tok/s) but differently at 8192 (an immediate
</think> answer instead of a thinking turn). Whether that is chunk-order rounding at a decision boundary or a
large-chunk defect is open: compare final-row logits at 6144 vs 8192 (and the Original at 8192) before making 8192
the default. The default stays 2048; LELEKA_ORIGINAL_SERVE_CAPACITY / prefill_capacity select larger chunks.
The Original's --prefill auto reaches 8192 only when it can lend expert-cache slots (profile + borrow), and
otherwise keeps 2048, so the port's default matches it without the tier.
Laptop (RTX 3080 laptop, WSL2, mapped experts, VRAM tier auto + profile, KAR file, 3 prompts of 78-88 tokens)
Same harness as docs/laptop-profile.md (scripts/laptop/port_bench.sh, 16 new tokens, 2 passes), one process per
arm, W first (cold page cache after a WSL restart), then Y. Greedy outputs identical.
| arm | prefill tok/s pass 0 / pass 1 | TTFT s pass 0 / pass 1 |
|---|---|---|
W 3e05437 (integration head) |
0.7, 1.4, 3.1 / 1.6, 1.9, 2.3 | 120, 59, 26 / 56, 44, 35 |
Y ae283e6 (all fixes + stager) |
5.6, 4.5, 6.4 / 9.0, 9.4, 9.4 | 17, 19, 13 / 10.5, 9.5, 8.9 |
Y's profile (pass 1, ~80 tokens): moe.ring 5.5-7.0 s (expert bytes over PCIe from the page cache), gdn 1.33 s, qsa 0.33 s, everything else < 0.2 s. The Original's paired row in docs/laptop-profile.md: 12.4 tok/s, TTFT 7.2 s.
Remaining gap (RTX 5090, 8192-token chunks: 2,830-2,930 tok/s vs the Original's 5,400-5,900)
- moe.ring 1.1 s: the expert DMA (~34 GB per chunk) runs layer by layer and drains before the next mixer; the
Original's
stream_all(prefill.cpp 1159-1286, driverrun_stream_all_forwardexists, unused by the runtime) keeps the copy stream busy across layers. - gdn 0.58 s, qsa 0.25 s, GR reads/injects 0.35 s per 8192 tokens. GDN costs 1.3 s even on an 80-token laptop
prompt, so most of it does not scale with the chunk; the chunk owner checks and stages each layer's recurrent state
from host values (
GdnChunkDevice::new), the likely cause (not yet measured separately). - input 0.18 s (per-token KAR gather with device round trips) and init 0.21 s (host row staging) per 8192 tokens.