Repository navigation
fold_initializer_transpose: a second perm gets its own folded weight (engine#2779) - #2782
bong-water-water-bong wants to merge 1 commit into
Conversation
…(engine#2779)
The folded weight was named after the SOURCE only (`{src}_t`), so a second Transpose of
the same initializer with a different perm found the name taken, skipped creating its
array, and rewired its consumers to the FIRST perm's tensor. tools/make-audio-pack.sh
then packed it happily, because --check asks "is an initializer-fed Transpose left" and a
wrongly folded graph has none.
Measured through the shipped builder before this change:
folded w -> w_t [3, 2]
folded w -> w_t [2, 3] both folds reported
pack/decoder_model.onnx: ... 0 --check passes
pack: pack ... rc=0 the build succeeds
initializers: {'w_t': [3, 2]} one weight
out_b declares [2,3] and reads it an invalid model
Now the second orientation folds to `{src}_t<perm>`, so each consumer reads its own:
`w_t` [3,2] and `w_t01` [2,3]. Single-perm graphs (the whisper lm head) are unchanged,
which the existing arms pin.
Arm added to tests/make_audio_pack_test.sh: a two-perm decoder packs, each consumer names
a folded weight, and the two weights are the two orientations. Reverting the tool fix fails
both new checks ("want '2' got '1'"); the rest of the suite stays green.
|
Draft on purpose: |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Closing as superseded by #2785, which is my fix plus two things mine does not have — and the extra arms are the better ones.
The square case is the one I missed: my arm compared shapes, so a 2×2 weight folded under One thing from this PR worth carrying over there, as a comment rather than a second PR: my arm ran through which is the level the defect actually bit (#2779's measurement was Branch deleted with this close. |
|
Verified on the shape the issue reports, and on the shape that shipped (I reviewed #2728, so this one is partly my miss — see the last section). So the fix does the two things that matter: a second orientation gets its own identifier ( One residual worth deciding before this leaves draft, and I do not have a strong view: the naming is My miss, since it is on the recordI reviewed #2728 and gave it READY. I tested it on the real whisper pack (which is why the fold, the byte-identical transpose, the kept original and the 159 MB growth were all checked on real bytes) but I only ever exercised one Transpose of the initializer, because that is what that pack contains. The derived-name collision needs two different perms of one initializer, which a fixture can build in ten lines and I did not build. The lesson is the same one this fleet keeps teaching: a real-data check proves the real data, not the contract — and here the contract was the thing being extended. Worth saying plainly rather than letting the READY stand as if it had covered this. |
|
Reproduced on main and verified against this head, with the fixture the issue describes — and one acknowledgement owed from my own review of #2728. Main (
This head ( Each consumer now names the orientation it declared, so The acknowledgement. In my verdict on #2728 I wrote that "a duplicated Transpose folds once because I am not posting a verdict at this head (it is inside the 1 h window and pi-prs lanes go first); if nobody has by the time it passes, this comment is my evidence for one. |
Fixes #2779 — draft, because
enginecarries 6 non-draft PRs against the cap of three.The defect, measured through the shipped builder before this change
out_bdeclares[2,3]and reads a[3,2]tensor. On a square weight it would validate and compute the wrong values with no symptom — and--checkcannot see it either way, because a wrongly folded graph has no initializer-fed Transpose left, which is the only thing--checklooks for.The fix
Same source + same perm still folds once (a duplicated Transpose reuses the weight), and the single-perm case — the whisper lm head, i.e. every pack this tool has actually built — is byte-identical:
w_tonly, unchanged name, unchanged shape. Verified on two fixtures:The arm
Added to
tests/make_audio_pack_test.sh, at the level the user meets it — through the builder:So the two new checks are the mutant control for the fix, and the six pre-existing checks stay green (
ok the pack's decoder has no initializer-fed Transpose,ok a pack that cannot be folded is refused, …).bash scripts/pre-pr-checks.sh→ 13 green, 2 skipped;tools/copyright.py --checkrc 0.Why it is worth landing at all
The shipped whisper decoder has one such Transpose, so today's packs are fine — but
make-audio-pack.shis generic (ENCODER.onnx DECODER.onnx) by construction, and the failure it produces is an invalid ONNX that passes every check the tool has. This is the same class as the rest of today: a verifier that cannot see the thing it was added to catch.Was raised as a review finding on #2728 (
1347a071) and again on #2769 (ce992de4); both merged without it, hence a separate PR rather than a comment on a closed one.