Skip to content

docs/determinism: the REPACK=OFF stop-gap costs 38% of prefill, and that is the number it was missing - #1228

Merged
bong-water-water-bong merged 3 commits into
mainfrom
docs/repack-off-cost
Nov 6, 2026
Merged

bong-water-water-bong merged 3 commits into
mainfrom
docs/repack-off-cost

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

The page names -DGGML_CPU_REPACK=OFF as the way to make cpu width-invariant, and never said what it costs. #1145 records that cost as the one thing never measured here; this is it.

Root cause of where the cost lands is the mechanism the page already describes: the repacked path walks mul_mat output rows in 4-row blocks and the remainder singly (ggml-cpu/repack.cpp:4300-4306), so it is only reached when ne11 >= 4 — prompt processing, not one-token decode. So the cost is a prefill cost, and single-stream decode should not pay. Measured, that is exactly what happens.

Measured — Qwen3-0.6B Q4_K_M, -t 8, one build with only libggml-cpu.so swapped between the arms, 6 requests per arm interleaved by round so the box's other tenants load both equally:

REPACK=ON REPACK=OFF
prefill 984 tok/s 612 tok/s 1.61×, −38 %
1183-token prompt + 32-token reply, wall clock 2.10 s 3.01 s +43 % (3 rounds each)
23-token prompt + 75-token reply, wall clock 0.60 s 0.61 s a wash
single-stream decode 82 tok/s 85 tok/s ranges overlap, no cost

Two independently run arms gave 1.607× and 1.618× on prefill.

The pair was verified before it was measured, and both halves of that check found something:

  1. The arms did not differ at all on the first attempt — LD_LIBRARY_PATH unset means the launcher's absolute DT_RUNPATH into the build dir wins, so both arms loaded the same library and produced two identical results. Two suspiciously identical arms is what caught it, not an assertion.
  2. With the loader pointed at each arm, the harness now fails loudly unless the mapped libggml-cpu comes from that arm (/proc/<pid>/maps), and the width-2/4 oracle reproduces serve: identical requests served concurrently are not bit-reproducible on cpu and hrx (decode-batch width changes the logprobs; --parallel 4 default) #751 digit for digit: repack on 6/6 and 6/6 trials moved, worst 2.953e-01; repack off 0/6 and 0/6, 0.000e+00.

Every other byte of the two payloads is identical — verified file by file (23 files, real paths, not md5sum over relative symlinks, which resolves against the cwd and lies).

tools/copyright.py --check rc 0. One file, docs only, +9/−1.

Does not close #1145 — the width gate itself is still unwritten. This is the cost line that a fixer and a user both need in order to decide, and the issue's "Cost" section asks for exactly it.

Data: ~/wt/rlk-ab/{pp_ab_par1.json,pp_ab_short.json,wall_ab.json} on strixhalo; harness ~/wt/rlk-ab/{pp_ab.py,wall_ab.py,repack_oracle.py} (all self-tested). No GPU, no NPU, no ticket — this is a CPU-only measurement on a box whose GPU was held by another lane all night.

…hat is the number it was missing

The page names `-DGGML_CPU_REPACK=OFF` as the way to make `cpu` width-invariant, and never said
what it costs. #1145 records that cost as the one thing never measured here; this is it.

Where the cost lands is fixed by the mechanism the page already describes: the repacked path walks
mul_mat output rows in 4-row blocks and the remainder singly (ggml-cpu/repack.cpp:4300-4306), so it
is only reached when ne11 >= 4 -- prompt processing, not one-token decode.

Measured, Qwen3-0.6B Q4_K_M, -t 8, one build with only libggml-cpu.so swapped between the arms (so
every other byte of the payload is identical, verified file by file), 6 requests per arm interleaved
by round so the box's other tenants load both equally:

  prefill   984 -> 612 tok/s   (1.61x, -38%)
  long:     2.10 s -> 3.01 s   (+43%)   1183-token prompt, 32-token reply, 3 rounds each, wall clock
  chat-short 0.60 s vs 0.61 s  (a wash) 23-token prompt, 75-token reply
  decode    82 vs 85 tok/s     (ranges overlap: single-stream decode does not pay)

Two independently run arms gave 1.607x and 1.618x on prefill.

The pair was verified causally before it was measured, and both halves of that check found something:
the two arms did not differ until LD_LIBRARY_PATH was set, because the launcher carries an absolute
DT_RUNPATH into the build dir -- the first attempt measured the same library twice and produced two
identical arms. With the loader pointed at each arm, the width-2/4 oracle reproduces #751 digit for
digit (repack on: 6/6 and 6/6 trials moved, worst 2.953e-01; repack off: 0/6 and 0/6, 0.000e+00).

Does not close #1145: the width gate itself is still unwritten. This is the cost line a fixer and a
user both need in order to decide.

tools/copyright.py --check rc 0. One file, docs only.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

#1228 ready for review at a72091a

Docs-only, one file, +9/−1: the measured cost of the GGML_CPU_REPACK=OFF stop-gap that this page names as the way to make cpu width-invariant and never costed. Prefill 984 → 612 tok/s (1.61×, −38 %), long-prompt end-to-end 2.10 s → 3.01 s (+43 %), chat-short a wash, single-stream decode unchanged. Every number measured on this box tonight; the A/B is one build with only libggml-cpu.so swapped, verified file by file and by /proc/<pid>/maps, and it reproduces #751's oracle digit for digit.

Refs #1145 without closing it — the width gate itself is still unwritten.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

/review

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 846abac)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

1145 - Partially compliant

Compliant requirements:

  • The documentation now includes the performance cost of using -DGGML_CPU_REPACK=OFF as a stop-gap for achieving CPU determinism

Non-compliant requirements:

  • The PR does not implement the actual fix for the root cause of the width-dependent logprob issue
  • The PR does not address the attention split-KV path issue
  • The PR does not address the HRX width-1 fused kernel issue

Requires further human verification:

  • The actual fix implementation needs to be verified through testing with the acceptance criteria
  • The performance impact measurements need to be confirmed in the actual engine environment
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Documentation Update

The PR updates the documentation to include the performance cost of using -DGGML_CPU_REPACK=OFF as a stop-gap for achieving CPU determinism. This is a valuable addition that provides users with important information about the trade-offs involved in using this flag. The documentation correctly states that the cost is in prompt processing, not single-stream decode, and provides concrete measurements of the performance impact.

there is no equivalent env switch. **That flag is not free, and what it costs is prompt processing,**
which is where the 4-row block is actually reached: Qwen3-0.6B Q4_K_M, `-t 8`, one build with only
`libggml-cpu.so` swapped between the two arms, prefill **984 → 612 tok/s (1.61×, −38 %)** over 6 requests
per arm, interleaved so the box's other tenants load both equally. End to end, measured wall clock, 3 rounds
each: a 1183-token prompt with a 32-token reply goes **2.10 s → 3.01 s (+43 %)**, while a 23-token chat
prompt with a 75-token reply is a wash (**0.60 s vs 0.61 s**). Single-stream decode does not pay: 82 vs 85
tok/s, the two sample ranges overlapping. So it is a switch to reach for when the numbers must be
reproducible, not a free one, and a long (RAG-sized) prompt is where it shows. Under heavy load the
absolute times move; the ratio does not — two independently run arms gave 1.607× and 1.618× on prefill.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at a72091a2.

The arithmetic of every number in the new paragraph checks out, and the flag it is about is the one already in the page
(determinism.md:277, -DGGML_CPU_REPACK=OFF):

prefill 984 -> 612 tok/s : 984/612 = 1.608 (claimed 1.61x), (984-612)/984 = 37.8 % (claimed -38 %)
wall    2.10 -> 3.01 s   : 3.01/2.10 = 1.433 (claimed +43 %)
"two independently run arms gave 1.607x and 1.618x" is consistent with the headline 1.61x

What I did not re-measure is the arms themselves — two libggml-cpu.so builds plus three interleaved rounds on a
box that four other lanes are loading is not something a docs PR should buy, and the page's claim is the cost of a flag
rather than a new capability. What I can say is that the shape of the claim is the right one: it converts a "reproducible
CPU" recommendation into "reproducible, and here is what it costs you on a RAG-sized prompt, and what it does not cost you
on decode", with the decode row (82 vs 85 tok/s, ranges overlapping) stated as a wash rather than dressed up as a win.

The one thing worth a second look before merge is not in the diff: -38 % prefill and +43 % wall for the same
1183-token prompt are consistent with each other only if the reply is the small part of that wall time, which is what a
32-token reply is. That is the case here, and the sentence says which prompt does which, so a reader cannot carry the
43 % over to a decode-bound workload — which is the mistake the paragraph exists to prevent.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 5e6cd76

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 846abac

@bong-water-water-bong
bong-water-water-bong merged commit 5d37f1b into main Nov 6, 2026
9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the docs/repack-off-cost branch November 6, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kernels: the decode K-reduction order follows the batch width, so concurrent requests report different logprobs (the width gate #751 deferred)

1 participant