[GH-ISSUE #494] Decode profile (RTX A3000 + i7-12850HX): the CPU expert pool is ~half the round; pin the verify host first #227

Closed
opened 2026-11-04 01:41:05 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @yannickloth on GitHub (Oct 2, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/494

Context

A decode-time profile of the RTX A3000 12 GB laptop + i7-12850HX host from #485, on production engine 0.1.35
(Qwen3.8-Flash-Next Swift 1.5 IQ3_XXS native pack, the calibrated --pcie-frac 0.35 --spec-min-p 0.70 --pool-workers 8), from the engine's own --stats accumulators. Full write-up and raw lines:
bench/results/2026-10-02-rtx-a3000-i7-12850hx/profile.md (PR #489).

The split

One verify-window round, ms and share of the round's wall clock. A round emits 2.10 tokens at the fresh hit
rate and 1.15 when the output degenerates and hits more.

Term fresh decode, hit_rate 0.354 ms warm/degenerate, hit_rate 0.756 ms
GPU — "wait for rings" 34% 26.7 62% 23.1
CPU expert pool 53% 41.6 26% 9.6
MTP drafter 4% 3.1 6% 2.1
host 2% 1.7 1% 0.2
verify copy-stream commit ~0% 0.03 ~0% 0.03
embed/sample/round overhead 6% 4.9 6% 2.2
round 78.1 (26.9 tok/s) 37.3 (30.9 tok/s)

Real serve traffic on this host ran hit_rate 0.35-0.65 (34-40 tok/s), i.e. the fresh-decode end. There the
CPU expert pool is the largest single term, and the GPU is second.

What it sizes

  • Pinning the verify host thread is the top host-side lever. The pool is 26-53% of the round; recovering the
    pool.hpp pinned vs in-loop rates (36.3 vs 26.9 GB/s, ~1.35×) is worth ~+8-15% tok/s. The pool measures only
    18-22 GB/s over the rows here, so there may be more than 1.35× to win. The generate/session path already
    pins the host (SessionLoopScratch::init), but the serve/spec Verifier::run does not — the doorbell-spinning
    host and the PCIe-copy helpers are free to land on a worker's core.
  • 256-bit AVX-VNNI is bounded. The down path is ~29% of the pool; a 1.5-2× down path is ~5-8% of the round.
    The i-quant gate/up is ~68% of the pool and documented codebook-bound, so VNNI barely touches it.
  • The per-window copy-stream cudaStreamSynchronize is already ~0 ms/round on this host. The MTP drafter's
    per-draft syncs live inside the 4-6% MTP term and are the only part of that area with headroom.
  • P/E-aware division: --pool-workers 8 on the default --pool-affinity all does not land on 8 P-cores;
    it pins cores 2,4,6,8,10,12,14,16 = seven P-core primaries + the first E-core, and the E-core is the tail of
    every split-row drain. --pool-affinity p-cores avoids it but starts only p_cores - 1 = 7 workers.

Notes for measuring this model

The native IQ pack runs verify windows only, so --gpu-stages, --gpu-only-full and --no-pool+--spec are
unavailable (session_replay_stages: not captured with the split, etc.), and /metrics'
ram_blobs/file_blobs/file_mb are 0 on the MAP_HUGETLB arena. The verify-window "wait for rings" term is
the GPU floor available on this path; the 26.32 ms graph floor is the non-native path's.

Refs #485 (the probe's low reading matters via pcie_frac, not via bandwidth: PCIe in use is ~4 GB/s) and #487.

Originally created by @yannickloth on GitHub (Oct 2, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/494 ## Context A decode-time profile of the RTX A3000 12 GB laptop + i7-12850HX host from #485, on production engine **0.1.35** (Qwen3.8-Flash-Next Swift 1.5 IQ3_XXS native pack, the calibrated `--pcie-frac 0.35 --spec-min-p 0.70 --pool-workers 8`), from the engine's own `--stats` accumulators. Full write-up and raw lines: `bench/results/2026-10-02-rtx-a3000-i7-12850hx/profile.md` (PR #489). ## The split One verify-window round, ms and share of the round's wall clock. A round emits 2.10 tokens at the fresh hit rate and 1.15 when the output degenerates and hits more. | Term | fresh decode, `hit_rate 0.354` | ms | warm/degenerate, `hit_rate 0.756` | ms | | --- | --- | ---: | --- | ---: | | GPU — "wait for rings" | 34% | 26.7 | 62% | 23.1 | | CPU expert pool | **53%** | 41.6 | 26% | 9.6 | | MTP drafter | 4% | 3.1 | 6% | 2.1 | | host | 2% | 1.7 | 1% | 0.2 | | verify copy-stream commit | ~0% | 0.03 | ~0% | 0.03 | | embed/sample/round overhead | 6% | 4.9 | 6% | 2.2 | | round | | 78.1 (26.9 tok/s) | | 37.3 (30.9 tok/s) | Real serve traffic on this host ran `hit_rate 0.35-0.65` (34-40 tok/s), i.e. the fresh-decode end. There the **CPU expert pool is the largest single term**, and the GPU is second. ## What it sizes - **Pinning the verify host thread is the top host-side lever.** The pool is 26-53% of the round; recovering the `pool.hpp` pinned vs in-loop rates (36.3 vs 26.9 GB/s, ~1.35×) is worth ~+8-15% tok/s. The pool measures only **18-22 GB/s over the rows** here, so there may be more than 1.35× to win. The `generate`/session path already pins the host (`SessionLoopScratch::init`), but the serve/spec `Verifier::run` does not — the doorbell-spinning host and the PCIe-copy helpers are free to land on a worker's core. - **256-bit AVX-VNNI is bounded.** The down path is ~29% of the pool; a 1.5-2× down path is ~5-8% of the round. The i-quant gate/up is ~68% of the pool and documented codebook-bound, so VNNI barely touches it. - **The per-window copy-stream `cudaStreamSynchronize` is already ~0 ms/round on this host.** The MTP drafter's per-draft syncs live inside the 4-6% MTP term and are the only part of that area with headroom. - **P/E-aware division:** `--pool-workers 8` on the default `--pool-affinity all` does **not** land on 8 P-cores; it pins cores `2,4,6,8,10,12,14,16` = seven P-core primaries + the first E-core, and the E-core is the tail of every split-row drain. `--pool-affinity p-cores` avoids it but starts only `p_cores - 1 = 7` workers. ## Notes for measuring this model The native IQ pack runs verify windows only, so `--gpu-stages`, `--gpu-only-full` and `--no-pool`+`--spec` are unavailable (`session_replay_stages: not captured with the split`, etc.), and `/metrics`' `ram_blobs`/`file_blobs`/`file_mb` are 0 on the `MAP_HUGETLB` arena. The verify-window "wait for rings" term is the GPU floor available on this path; the 26.32 ms graph floor is the non-native path's. Refs #485 (the probe's low reading matters via `pcie_frac`, not via bandwidth: PCIe in use is ~4 GB/s) and #487.
Author
Owner

@yannickloth commented on GitHub (Oct 2, 2026):

P1 measured: no serve-path collision on this host — the host is already pinned, so no code is needed.

Before writing a fix I ran the Phase 0 census and a same-binary A/B, on production 0.1.35 (--serve --spec 4 …, Swift 1.5 IQ3_XXS native pack, --pool-workers 8).

Collision check

During an active serve decode, /proc/<pid>/task/*/status plus ps -L sampled 120 × 50 ms: the only busy non-worker thread is the engine main thread, Cpus_allowed_list: 0; the 8 pool workers are on 2,4,6,8,10,12,14,16. Exactly nine busy threads (host + 8 workers), the host on core 0 in every sample. No worker core is ever shared.

Why: SessionLoopScratch::init (src/core/session.cpp:547) is called unconditionally in main() (src/program/generate.cpp:3607) before the serve/verifier block (:4200), so the serve host is pinned to the pool's reserved core before Verifier::run ever executes. The "serve verifier is unpinned" premise is a code-location asymmetry, not a behavioral one.

A/B

Same binary, STRATA_NO_VERIFY_PIN off/on, bench/e2e.sh, fixed prompt, max_tokens 200, interleaved, 6 runs per arm, alternating order:

arm runs (tok/s) median mean stdev
off 31.5, 22.7, 22.7, 26.9, 25.8, 25.7 25.75 25.88 2.97
on 32.8, 34.7, 18.8, 19.7, 24.5, 24.4 24.45 25.82 6.03

Mean delta −0.3%, median −5.1%: not the >3% win tools/calibrate.py requires (the host is noisy, ±20%).

A guarded Verifier pin was implemented and verified (fixed-prompt output bit-identical on/off; pool_test/pool_stress/expert_parity/verify_host_pin_test/expert_layout_test/expert_cache_per_layer_test and 10 parity tests pass), but it only re-pins the already-pinned thread, so it is ~0 perf. I closed PR #501 rather than merge redundant code.

Plan order: P1 is done/no-op on this host; the next real gain stays P7/P8 on the codebook-bound pool.

<!-- gh-comment-id:5954191678 --> @yannickloth commented on GitHub (Oct 2, 2026): **P1 measured: no serve-path collision on this host — the host is already pinned, so no code is needed.** Before writing a fix I ran the Phase 0 census and a same-binary A/B, on production 0.1.35 (`--serve --spec 4 …`, Swift 1.5 IQ3_XXS native pack, `--pool-workers 8`). ### Collision check During an active serve decode, `/proc/<pid>/task/*/status` plus `ps -L` sampled 120 × 50 ms: the only busy non-worker thread is the engine main thread, `Cpus_allowed_list: 0`; the 8 pool workers are on `2,4,6,8,10,12,14,16`. Exactly **nine busy threads** (host + 8 workers), the host on core 0 in **every** sample. No worker core is ever shared. **Why:** `SessionLoopScratch::init` (`src/core/session.cpp:547`) is called unconditionally in `main()` (`src/program/generate.cpp:3607`) *before* the serve/verifier block (`:4200`), so the serve host is pinned to the pool's reserved core before `Verifier::run` ever executes. The "serve verifier is unpinned" premise is a code-location asymmetry, not a behavioral one. ### A/B Same binary, `STRATA_NO_VERIFY_PIN` off/on, `bench/e2e.sh`, fixed prompt, `max_tokens 200`, interleaved, 6 runs per arm, alternating order: | arm | runs (tok/s) | median | mean | stdev | | --- | --- | ---: | ---: | ---: | | off | 31.5, 22.7, 22.7, 26.9, 25.8, 25.7 | 25.75 | 25.88 | 2.97 | | on | 32.8, 34.7, 18.8, 19.7, 24.5, 24.4 | 24.45 | 25.82 | 6.03 | Mean delta **−0.3%**, median −5.1%: not the >3% win `tools/calibrate.py` requires (the host is noisy, ±20%). A guarded `Verifier` pin was implemented and verified (fixed-prompt output bit-identical on/off; `pool_test`/`pool_stress`/`expert_parity`/`verify_host_pin_test`/`expert_layout_test`/`expert_cache_per_layer_test` and 10 parity tests pass), but it only re-pins the already-pinned thread, so it is **~0 perf**. I closed PR #501 rather than merge redundant code. **Plan order:** P1 is done/no-op on this host; the next real gain stays P7/P8 on the codebook-bound pool.
Author
Owner

@Niko1221 commented on GitHub (Oct 2, 2026):

Thank you for the detailed profile and for closing #501 after measuring it. The verify thread is already pinned by the session setup, so the -0.3% fits. Two leftovers we noted: --pool-workers 8 with --pool-affinity all can put a worker on an E-core, and --pool-affinity p-cores starts p_cores - 1 workers. The remaining gain is in the codebook-bound pool kernels (your P7/P8), which stay on our list. Closing as a report.

<!-- gh-comment-id:5956993013 --> @Niko1221 commented on GitHub (Oct 2, 2026): Thank you for the detailed profile and for closing #501 after measuring it. The verify thread is already pinned by the session setup, so the -0.3% fits. Two leftovers we noted: `--pool-workers 8` with `--pool-affinity all` can put a worker on an E-core, and `--pool-affinity p-cores` starts p_cores - 1 workers. The remaining gain is in the codebook-bound pool kernels (your P7/P8), which stay on our list. Closing as a report.
Author
Owner

@yannickloth commented on GitHub (Oct 3, 2026):

Thanks for the careful handling here and for keeping the pool kernels (P7/P8) on the list. The work behind 0.1.38 is appreciated.

What you are building is the difference between running a SOTA model locally and having to pay for cloud/API access — that is not a negligible feat.

<!-- gh-comment-id:5966396984 --> @yannickloth commented on GitHub (Oct 3, 2026): Thanks for the careful handling here and for keeping the pool kernels (P7/P8) on the list. The work behind 0.1.38 is appreciated. What you are building is the difference between running a SOTA model locally and having to pay for cloud/API access — that is not a negligible feat.
Author
Owner

@yannickloth commented on GitHub (Oct 3, 2026):

P7 (i-quant gate/up) follow-up is now a dedicated report: #616 — the AVX2 codebook gather is bit-exact and a stable 1.3x isolated, but gives +1.0% e2e and zero gain at 15 workers, so the pool is not decode-bound there. Moving the long version there to keep this closed thread short.

<!-- gh-comment-id:5968648230 --> @yannickloth commented on GitHub (Oct 3, 2026): P7 (i-quant gate/up) follow-up is now a dedicated report: #616 — the AVX2 codebook gather is bit-exact and a stable 1.3x isolated, but gives +1.0% e2e and zero gain at 15 workers, so the pool is not decode-bound there. Moving the long version there to keep this closed thread short.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#227
No description provided.