Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
5.4 KiB
CPU expert pool: thread trace (2026-11-12)
Question (stage 6b): the CPU leg of the expert path has a longer tail than vanilla (T=3, layers 0-15: p75/p90 117/182 us against 69/99; layers 16-47: 95/151 against 66/92). Is it the time per expert (the CPU kernel) or the pool (queue, wake, straggler)?
Tool: LELEKA_POOL_TIMING=layers (crates/native-cpu-expert/src/rust_pool/trace.rs, engine line leleka-serve pool-layer {json} per layer window, report scripts/e2e/codex/prefill/pool_layer_report.py). Off by default; the pool then reads no clock.
Run: pool-thread-trace-default-release-0ac612d2df74-d1-pt1-pt2 (release 0ac612d2df = 83bdd85bb4 + trace, owner default placement quota=no + PCIe 0.65, replay VANL/nestng-crm-r2, 30 requests; blocks D.1 without the trace, PT.1 and PT.2 with it). Results: /data/leleka-e2e/prefill-latency/runs/pool-thread-trace-default-release-0ac612d2df74-d1-pt1-pt2/.
Caveats
- The PT blocks carry an INVALID marker that is FALSE: the arm guard read
leleka-serve meta: configfromengine.log, but the engine log is a bounded tail and the trace lines (about 2.6 KB each) pushed the start of the log out (4,883 and 10,755 pool-layer lines are left, 15,638 together; the line is the START of the run). The config is proven by theengine environmentline ofup-foreground.txt(EXPERT_PER_LAYER=no, PCIE_FRAC=0.65) and by D.1 (same profile,meta: configexpert_per_layer=0 pcie_frac=0.65). The traced window is the tail of each replay. - Tracing costs time: replay wall (30 requests, sum
wall_s) D.1 263.7 s, PT.1 301.5 s, PT.2 284.5 s (+8..14 %; n = 1 each, no A/A: indicative). The cost is the one engine-log line per window, not the timers (two clock reads per task, 28-72 us tasks). Times inside the pool are valid; absolute round times of PT blocks are not comparable with D.
Result (T = 1..4 tokens, microseconds, p50)
The pool always has 48 tasks (3 x 16 threads: 15 workers + host), whatever the expert count; every thread takes exactly 3 tasks; wake (publication to a thread's first task, slowest thread) 0.7-1.3 us; publish 0.3, park 0.1, requant 0.4-0.6, pre/post 3-4 us.
| experts in window | windows | group wall p50 / p75 / p90 | m5 gate/up wall | m5 task | m6 down wall | m6 task | m5 tail (last - median thread) p50 / p90 |
|---|---|---|---|---|---|---|---|
| 1 | 916 | 82 / 90 / 97 | 58 | 15.3 | 20 | 5.3 | 9 / 14 |
| 2 | 581 | 159 / 171 / 185 | 111 | 30 | 40 | 11 | 17 / 27 |
| 3 | 185 | 236 / 250 / 270 | 162 | 45 | 70 | 21 | 23 / 41 |
| 4 | 62 | 306 / 337 / 360 | 215 | 71 | 101 | 31 | 19 / 52 |
| 5 | 29 | 382 / 411 / 425 | 240 | 69 | 127 | 39 | 32 / 56 |
Reading
- The group time is LINEAR in the number of experts: about 76-80 us per expert (82 -> 159 -> 236 -> 306 -> 382), with a fixed part of only about 5 us. The pool's own overhead (wake 1 us, publish/park under 1 us, requant 0.5 us) is under 10 % at one expert and under 3 % at four. It is not the queue and not the wake.
- What a window costs is the kernel time per task: 3 tasks per thread, 15.5 us per gate/up task for one expert (1.36 MB of IQ3_S for gate+up, about 28 KB per task: 1.8 GB/s per thread, about 29 GB/s for the pool) and 5.3 us per down task (about 34 GB/s). One expert (2.047 MB) costs about 76 us across 16 threads = about 27 GB/s. The gate/up phase is about 25 % slower per byte than the down phase. Whether this is the memory bus (sustained DDR bandwidth of the machine, the PCIe DMA reads the same pinned bank) or the IQ3_S dequantisation arithmetic needs a one-thread kernel microbenchmark; it is the open question.
- The straggler is the granularity of the tasks: tail (last thread minus median thread) is about 0.55-0.6 x the task time (9 us at 15 us tasks, 17 at 30, 23 at 45), and p90 reaches 14-55 us. With 3 tasks per thread the last claimed task of a thread can end one task later than the median.
gu_wait_doneis 10-23 us (p50). That is the only part of the pool that can be improved by the pool: 6-12 us per window at 1-2 experts, i.e. 5-10 % of the group. - Compared with vanilla (T=3: 69/99 and 66/92 us p75/p90): our windows with ONE expert take 90/97 us at p75/p90 (above vanilla's p75 of 66-69, level with its p90 of 92-99); with two or more experts we are above it by construction (linear in the expert count). The gap of stage 6b is therefore at least partly the NUMBER of CPU experts per window (placement, and our quota=no changes it), not the pool; to separate it from the per-expert kernel cost the vanilla trace must be split by expert count (it has the same per-layer-window grouping). The pool trace does not implicate the pool, so no vanilla strace is needed.
Candidate fixes (none applied; each needs a paired A/B and the quality gate)
- Finer tasks at the end of a phase (guided / halving chunk: 3 -> 5-6 tasks per thread, claim cost about 50 ns each): expected tail 17 -> about 9 us at two experts, 6-12 us per window; non-lossy (same arithmetic, same outputs), numerical identity by tensor compare.
- Gate/up kernel (58 us per expert against down 20 us for half the bytes): compare with the vanilla C++ kernel per task (Rust vs C++ were within 6 % in the earlier kernel bench), look at the activation quantisation shared by the 48 tasks and at prefetching the next task's rows.
- Fewer CPU experts per window (more VRAM slots, higher PCIe share) moves the cost out of this linear regime; the quota=no + PCIe 0.65 default is exactly this lever (about 10 % fewer non-resident experts).