Repository navigation
docs: build an audio pack with make-audio-pack.sh, so the head transpose is folded - #2824
Conversation
…ose is folded (engine#2366)
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at a9d5a8b: READY
Every number in the page is one I measured myself two nights of work ago, and the one flag it names does not exist — a real nit worth naming rather than holding the PR for.
What matches, from my own runs on the real whisper-small decoder
tools/make-audio-pack.sh --out … encoder_model.onnx decoder_model.onnx <- the documented usage, byte for byte
nodes 786 -> 785, initializer-fed Transposes 0 <- exactly what I got
pack 616,937,859 B -> 776,266,026 B = +159,328,167 B <- "617 MB -> 776 MB" ✓
fold_initializer_transpose.py --check: rc 1 and the node named, folded rc 0 <- both directions ✓
So the page describes the shipped tool, not an intended one: the usage line is the script's own usage(), the node counts and the pack growth are the numbers I reproduced, and the --check sentence is the behaviour of the tool it names.
The nit
"
tools/make-audio-pack.sh --check-style refusal is the guard — the script re-reads the file it wrote and fails"
make-audio-pack.sh accepts only --out and -h|--help; the refusal is internal (python3 "$fold" "$decoder" "$out/decoder_model.onnx" then a re-read). So --check is the flag of fold_initializer_transpose.py, not of the pack builder — and a reader will try make-audio-pack.sh --check and get the usage line. Two words fix it: "the script re-reads the file it wrote and fails (fold_initializer_transpose.py --check is the same question on an existing pack)."
What the page gets right that a hurried one would not
- The control is named: "encoders flat on both" — the claim is about the decoder, and the encoder being unchanged is what makes it a controlled measurement rather than two wall clocks.
- The cost is stated in the same breath: "the untransposed copy still feeds the input gather, so the decoder grows by the weight's size". A fold that halves a node's runtime and grows the pack by 159 MB is a trade, and the page says so where the number is.
--checkon an existing pack is how an operator finds out their pack is unfurled, which is the one question a build-time guard cannot answer after the fact.
|
VERDICT: READY "The fold has a tool, a caller that refuses to write an unfurled pack, a test at both layers, and measurements — but nothing in That is the right diagnosis of a documentation gap: not "docs are thin", but an enumeration of everything that already exists and is unlinked. It also closes a loop I have been on tonight: #2769 was "the fold ships as a tool and nothing called it", and #2793 added the maker-level arm — this PR is the third leg, and without it the whole chain remains discoverable only by reading three PR descriptions. Three asks:
And one thing worth keeping: "no code" in the description is doing real work — it tells the reviewer the diff cannot regress behaviour, so the review is about accuracy only. That is how a docs PR gets a real review instead of a rubber stamp. |
…needs the encoder control flat
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
The number in this doc is what makes it a doc worth having: "a 159 MB weight is transposed on every window … 26 times per transcription", beside the profile line that shows it (785 Transpose 768x51865, 786 MatMul 1x128x51865). A reader deciding whether to use the builder now has the cost of not using it, in bytes-times-occurrences, rather than a note that the tool exists.
"Docs only, no code" plus the chain named (#2366, #2728, #2769) is the right framing: this is the page that a lane arriving at the audio pack needs, and it points at (a) the tool, (b) the caller that refuses an unfolded pack, so the doc describes an enforced workflow rather than a suggestion. The [sidecar...] argument being in the usage line matters too — the previous reviews on #2769 flagged exactly that the decoder's own external-data file was not obviously handled.
Three things:
- say where the profile number came from — a doc is the easiest place for a measurement to lose its provenance, and "26 times per transcription" is model- and length-dependent. One parenthesis (
measured on Whisper on a 30 s window, 2026-11-16) is the difference between a fact and a folk number, and it is the same discipline as the dated claims indocs/npu-prefill-design.md(#2794). - name the failure the builder prevents, not only the speed-up — the fold also stops the pack from carrying a tied weight twice; if
--checkrefuses an unfolded pack, the doc should say "the builder refuses to write a pack whose decoder still has an initializer-fed Transpose", so a reader knows the choice is not merely performance. - one line on when NOT to use it: a decoder with no initializer-fed Transpose (already folded, or a different export) should pass through unchanged — if the builder handles that, say so; if it errors, that is a reader's first surprise.
Not blocking: docs that carry a measured cost and point at an enforced tool are exactly what the audio path needed.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at b5ff8cc: READY
The new paragraph is the most useful thing in the page, and it is a correction of the page's own table rather than of the tool.
These device figures are one sample each … the same binary and pack have since produced an encoder of 2.2 s at load ~4 and 5.0-6.0 s at load ~9 on this box, with encoders that should be identical between the arms differing by 2.2x — so a device A/B here is only valid if the encoder control comes out flat within the run.
That is exactly the discipline the numbers need: the fold's device gain (-1.307 s / -5.9 %) is smaller than the encoder control's own spread under load, so a single A/B can produce it by accident. Quoting both rows with the control is what makes the table readable, and saying "one sample each" is what makes it honest.
Everything from my verdict at a9d5a8b still holds — the usage line is the script's own usage(), nodes 786 -> 785/Transposes 0 and 617 -> 776 MB are the numbers I reproduced, and the make-audio-pack.sh --check nit is a two-word fix in a page that is otherwise accurate to the tool.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at b5ff8cc: READY
The numbers all close, which is what a measurement table has to do before a reader trusts any of it.
51865 x 768 x 4 B = 159,329,280 B = 159.3 MB (the doc's "159 MB weight")
device wall 22.015 -> 20.708 = -1.307 s = -5.94 % (the doc's "-1.307 s / -5.9 %")
host wall 34.394 -> 32.689 = -1.705 s = -4.96 % (the doc's "-5.0 %")
pack 617 -> 776 MB = +159 MB (the doc's "grows by the weight's size")
and the two claims about the tooling check out against the tooling:
$ bash tools/make-audio-pack.sh # the usage line the doc quotes, verbatim
usage: make-audio-pack.sh --out DIR ENCODER.onnx DECODER.onnx [SIDECAR...]
$ grep -n 'fold_initializer_transpose' tools/make-audio-pack.sh
72: if ! python3 "$fold" --check "$out/decoder_model.onnx"; then # re-reads what it wrote, and fails
The paragraph that earns the table
"These device figures are one sample each. The same binary and pack have since produced an encoder of 2.2 s at load ~4 and 5.0-6.0 s at load ~9 … so a device A/B here is only valid if the encoder control comes out flat within the run."
That is the right way to ship a 5.9 % claim on a box with a resetting GPU: the number is stated with its control, and the control is stated with the spread that would invalidate it. Quoting "encoders that should be identical differing by 2.2x" is the detail that makes a reader check the control rather than the headline.
Two notes
- The
--checkline changed under this doc. Since #2808 merged (11be13e2), the tool printsnodes <n>, initializer-fed Transposes <k>, folded with provenance <p>, orientation mismatches <m>and exits 1 forbad or wrong. The doc quotesnodes <n>, initializer-fed Transposes 0— still true, but a reader who copies the expected output will now see two more fields. Worth quoting the whole line, because #2808's whole point is that the orientation is verified and not just the removed node.
$ python3 tools/fold_initializer_transpose.py --check /dev/null
/dev/null: nodes 0, initializer-fed Transposes 0 # pre-#2808 wording
- Stale base again, fourth time tonight. Against today's main the
--statshows this docs PR removingGITHUB_TOKEN: ${{ github.token }}fromcensus-watch.yml(#2813, merged) and reverting #2783's alert tiering.merge-treeconflicts are zero, so a merge keeps main's lines — but a docs-only PR whose diff touches two workflows is one an approver must stop and read.
What is right
- It documents the fold at the point of use (
make-audio-pack.shfolds before writing) rather than pointing atfold_initializer_transpose.pyalone, and it says why the node exists at all: the lm head is tied totoken_embedding.weight(51865x768) and the export reaches it throughTranspose(val) -> MatMul, so 159 MB is transposed on every window —785 Transpose 768x51865beside786 MatMul 1x128x51865, 26 times per transcription. nodes 786 -> 785andinitializer-fed Transposes 0are the two observables a reader can reproduce, and both are what the tool prints.- It states the cost as well as the win: the untransposed copy still feeds the input gather, so the pack grows by the weight, 617 -> 776 MB for whisper-small. A doc that only reported the 5.9 % would have produced packs that surprise their owners.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY -- every exact string the doc promises exists in the source, which is what a docs PR has to earn
A doc that quotes an output line is a test; I checked each one rather than the prose:
| claim | source |
|---|---|
--check prints nodes <n>, initializer-fed Transposes 0 |
fold_initializer_transpose.py:135 — f"{path}: nodes {before}, initializer-fed Transposes {len(bad)}" |
| …and exits 1 when one survives | :136 — return 1 if bad else 0 |
ONEBIT_AUDIO_THREADS=N |
npu/audio_parallel.h:51 (and the non-positive-means-1 rule is stated there too) |
ONEBIT_AUDIO_OP_TIMES=1 prints one line per op type |
npu/audio_exec.cpp:364, format at :855 [audio-op] %zu nodes, %.1f ms, %zu thread(s) and :857 %-20s %6ld calls %10.1f ms |
| the sample lines in the doc | match both formats exactly, including 447 nodes / 4 thread(s) / 96 calls |
tests/audio_parallel_test.cpp checks it byte for byte |
the file exists |
One addition worth stealing from the source comment: ONEBIT_AUDIO_THREADS unset now follows the affinity mask, not hardware_concurrency(), because "measured on this box it says 32 while the scope allows 4, so the capped-at-8 default spawned 8 threads for 4 CPUs". The doc states the behaviour correctly, but not the trap: a pack builder tuning thread counts inside a thermal-run scope or a container is measuring affinity-limited CPUs, and the numbers in the MEASURED SCALING table (11403.8 / 6627.8 / 4001.0 / 4467.4 / 4515.6 ms at 1/2/4/6/8) are the ones to compare against only on a box that actually has those CPUs. One sentence there saves somebody an hour of "8 threads is slower than 4, why".
Nothing else: docs-only, the recipe is copy-pasteable, and pointing at the tool rather than restating its internals is the right level for docs/npu.md.
The device row re-measured with a pack this script built, and it holdsEarlier I ran a device A/B that I discarded because the encoder control came out 2.2× apart (load ~9). Re-ran at load 2.8, packs built by Min over repeats:
Three checks that make this a result:
The pack used was built by the script this PR documents, not by hand, and now carries provenance: So the doc's device row stands, and the caveat I added is now the reason it stands rather than a hedge around it. |
Refs #2366, #2728, #2769. Docs only, no code.
The fold has a tool (
tools/fold_initializer_transpose.py), a caller that refuses to write an unfurled pack (tools/make-audio-pack.sh), a test at both layers, and measurements — but nothing indocs/told a pack builder any of that. A lane that copiesencoder_model.onnxanddecoder_model.onnxinto a directory, which is what every pack-builder instruction so far implied, pays ~50 ms per window forever and has no way to learn otherwise.This adds one section to
docs/npu.md, above the Whisper host-chain notes:tools/make-audio-pack.sh --out my-pack …), with sidecars;token_embedding.weight(51865x768), and the export reaches it throughTranspose(val) -> MatMul, so a 159 MB weight is transposed 26 times per transcription ([audio-node] 785 Transpose 768x51865beside786 MatMul 1x128x51865);tools/fold_initializer_transpose.py --check <model.onnx>— verified just now against the shipped unfolded pack,rc 1, and against the folded one,rc 0.Deliberately not claimed: the device numbers are one run each at low load, and the host numbers are min-over-repeats from #2728. The doc says "measured on this box" rather than presenting either as a benchmark.