Skip to content

test: the two-perm collision, run through the pack builder where a pack builder meets it - #2793

Merged
bong-water-water-bong merged 1 commit into
mainfrom
feat/pack-two-perm-arm
Nov 17, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
feat/pack-two-perm-arm

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Refs #2779 (the layer its fix does not cover), #2728 (where the defect came from).

engine#2785 fixed the naming collision in fold_initializer_transpose.py and pinned it with arms on three graphs: two different perms, the same-shaped pair, and an impostor <src>_t. All three drive fold() directly.

This adds the same collision at the layer a pack builder actually meets — through tools/make-audio-pack.sh, which is where --check runs and where the original report was reproduced.

What

One arm in tests/make_audio_pack_test.sh, on a square weight folded under two perms, so both folded tensors have the same shape and different values — the case a shape check alone cannot separate:

  • a square weight under two perms packs — the script returns 0;
  • each MatMul reads its own folded weight — the two consumers name different initializers;
  • and the two folded weights hold different values — element-wise, not by shape.

It bites — proven by swapping the tool, not by reasoning

With origin/main's tool at the time of the report restored under the same test:

FAIL each MatMul reads its own folded weight: want '2' got '1'
FAIL and the two folded weights hold different values: want 'different' got 'identical'

With the fixed tool: make_audio_pack: all checks ok.

want '2' got '1' is the corruption itself: both consumers collapsed onto one name, --check still passed, and the script returned 0 — so the arm fails for the same reason the bug did, not because a string changed.

Why this is not a duplicate of #2785's arms

Theirs prove fold() behaves. This proves the shipped entry point behaves — including that the script's own write-then---check step cannot turn a correct fold into a wrong pack. Those are different claims, and the second is the one a pack builder relies on.

Rebased onto main after #2785 merged; the arm passes there.

…ck builder meets it (engine#2779)

(cherry picked from commit be979ee6cfc13f11cd44f12806021d5838b30b9e)
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2779 - Partially compliant

Compliant requirements:

  • The fix in fold_initializer_transpose.py correctly handles naming collisions for folded weights under different permutations.
  • The test verifies that a square weight folded under two different perms produces two tensors of the same shape with different values.
  • The test confirms that each MatMul reads its own folded weight (different initializers).
  • The test ensures that the two folded weights hold different values.
  • The test runs through the shipped script to validate behavior at the pack builder layer.

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Test Coverage for Two-Perm Collision

The test added in make_audio_pack_test.sh ensures that a square weight folded under two different permutations results in two distinct initializers with different values. This is critical for verifying that the fix in fold_initializer_transpose.py correctly prevents the naming collision that led to invalid packs. The test specifically checks that each MatMul node reads its own folded weight and that the two folded weights hold different values.

# A square weight folded under two different perms produces two tensors of the SAME shape with DIFFERENT values.
# engine#2779: the first fold named its result after the source only, so the second fold collapsed onto the same
# name, the packed decoder kept one array, `--check` still passed and the build returned 0. This arm runs the
# collision through the shipped script -- the layer a pack builder meets -- rather than through the tool.
python3 - "$tmp/sq-dec.onnx" <<'PY2' || { echo "FAIL could not build the square fixture"; exit 1; }
import sys
import numpy as np
import onnx
from onnx import TensorProto, helper, numpy_helper

w = numpy_helper.from_array(np.arange(9, dtype=np.float32).reshape(3, 3), "w")
x = helper.make_tensor_value_info("x", TensorProto.FLOAT, [1, 3])
oa = helper.make_tensor_value_info("oa", TensorProto.FLOAT, [1, 3])
ob = helper.make_tensor_value_info("ob", TensorProto.FLOAT, [1, 3])
g = helper.make_graph(
    [helper.make_node("Transpose", ["w"], ["wt1"], perm=[1, 0]),
     helper.make_node("MatMul", ["x", "wt1"], ["oa"]),
     helper.make_node("Transpose", ["w"], ["wt2"], perm=[0, 1]),
     helper.make_node("MatMul", ["x", "wt2"], ["ob"])],
    "g", [x], [oa, ob], [w])
onnx.save(helper.make_model(g, opset_imports=[helper.make_opsetid("", 17)]), sys.argv[1])
PY2

sq=$tmp/sqpack
"$SCRIPT" --out "$sq" "$tmp/enc.onnx" "$tmp/sq-dec.onnx" >"$tmp/sqlog" 2>&1
check "a square weight under two perms packs" "$?" 0
read -r names distinct <<EOF
$(python3 - "$sq/decoder_model.onnx" <<'PY'
import sys
import numpy as np
import onnx
from onnx import numpy_helper
m = onnx.load(sys.argv[1])
inits = {i.name: numpy_helper.to_array(i) for i in m.graph.initializer}
mms = [n for n in m.graph.node if n.op_type == "MatMul"]
a, b = inits[mms[0].input[1]], inits[mms[1].input[1]]
print(len({mms[0].input[1], mms[1].input[1]}), "different" if not np.array_equal(a, b) else "identical")
PY
)
EOF
check "each MatMul reads its own folded weight" "$names" 2
check "and the two folded weights hold different values" "$distinct" different

@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 at 2a383b4: READY

This is the arm I asked to be ported, arriving on its own — and it is load-bearing: with the whole name mechanism replaced by a single <src>_t, two arms fail by name.

$ bash tests/make_audio_pack_test.sh
ok   a square weight under two perms packs
ok   each MatMul reads its own folded weight
ok   and the two folded weights hold different values
--- make_audio_pack: all checks ok

# folded_name() replaced entirely by `return f"{src}_t"`:
FAIL each MatMul reads its own folded weight: want '2' got '1'
FAIL and the two folded weights hold different values: want 'different' got 'identical'

A near-miss in my own method, worth recording

My first mutant truncated the candidate list to ["<src>_t"] and the test passed. That is not a hole in the arm — it is the landed tool being better than either PR: folded_name() reuses a name only when np.array_equal(have, want) holds, and otherwise walks a ladder padded to eight candidates (<src>_t_<perm>, <src>_t_2 … <src>_t_8) before raising. So a half-mutant is absorbed by the fallback, and only removing the whole mechanism fails. A mutant has to delete the mechanism, not one rung of it.

Why this arm matters more than the unit arms

It goes through tools/make-audio-pack.sh — the shipped builder — so it asserts what a user's pack actually contains: --check sees no initializer-fed Transpose in the packed file, and the two consumers read two different arrays with two different values. The original defect produced a pack that built, passed --check and exited 0, which is why the unit arms on fold() alone could not have caught it end-to-end, and why my own verification of #2769 (on the real whisper decoder, one initializer-fed Transpose) could not either.

Sequence, for the record

#2789's implementation had two defects I raised (concatenated perm digits; a hand-written <src>_t silently overwritten); #2785 landed and its folded_name closed both, with the equality test above going one step further than either PR had. This PR carries #2789's best contribution — the two-perm pack fixture — against the code that landed. That is the right end state: one implementation, both tests.

@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

This is the assertion I asked for on #2785, and it goes further than the ask. My review said "assert the two folded names differ, rather than only that the values are right — a scheme that happened to produce the right values today would pass a value-only test". This arm asserts both, and at the layer that matters:

check "each MatMul reads its own folded weight" "$names" 2      # two DISTINCT initializer names
print(len({mms[0].input[1], mms[1].input[1]}), "different" if not np.array_equal(a, b) else "identical")
  • names == 2 is the property the fix exists to guarantee — two MatMul nodes reading two different initializers. A name scheme that collapsed them would fail here even if the surviving array happened to be the right one for one of the nodes;
  • different on the values is the second half: distinct names pointing at identical arrays would pass the first check and still be wrong (one fold's work lost);
  • a square weight is the hardest case and the right choice — a non-square weight would differ in shape and the collision could not arise in the first place. Same-shape-different-values is precisely what makes a naming scheme the only thing standing between the two folds.

And running it through tools/make-audio-pack.sh is what makes this a pack arm rather than a function arm: the report's decoder went through the builder, and "the packed decoder kept one array, --check still passed and the build returned 0" — so the failure mode is a green build with a lost fold, which no value-only check at the function boundary would have caught.

Two small things:

  1. Say which layer each arm pins in the body: #2785's three graph-level arms pin the function, this one pins the builder, and (per your own note) neither pins whatever consumes the pack at load time. Naming the three layers makes "the layer its fix does not cover" precise rather than a phrase — and if the load-time consumer reconstructs folded names by convention, that is the next arm.
  2. Assert the two arrays are the right arrays, not merely distinct — i.e. compare each MatMul's initializer against the numpy transpose of w under its own perm, not against each other. Distinct-and-swapped (two folds that exchanged values) would pass a distinctness test and be wrong for both nodes. One numpy.allclose per node, against the expected transpose, closes it.

Not blocking: this is the arm the previous PR needed, at the layer a pack builder actually meets, and a square fixture is the choice that makes it decisive.

@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 at 2a383b4: READY

The arm is the one I asked for on #2785/#2789: the collision run through the builder, not the tool — and its assertions are the right pair.

ok   a square weight under two perms packs
ok   each MatMul reads its own folded weight            (2 distinct initializer names)
ok   and the two folded weights hold different values    (np.array_equal → "different")

The second pair is what makes it worth a slot: a square weight folded two ways has the same shape both ways, so any check that compares shapes passes while the values are wrong. Asserting not np.array_equal on the two tensors is the only assertion that catches that, and it is exactly the case --check cannot see (no Transpose is left either way).

My mutant attempt was invalid, in a way worth recording

I first tried the pre-fix tool as the mutant and the suite passed — because main already has the fix (#2785 merged at 23:09Z with folded_name/inits), so "main's tool" is no longer the buggy one. A valid mutant for this arm has to be the pre-#2785 tool (e.g. git show main~1:tools/fold_initializer_transpose.py), and the arm's own commit history is what makes that awkward — the fix and the arm landed in different PRs an hour apart.

That is a note about future mutants, not a defect: the arm asserts the right thing at the right layer, and it will fail on any regression that reintroduces the collapse (name-collision or value-collision).

Overlap worth naming

engine#2789 now carries the same builder-level coverage in tests/make_audio_pack_test.sh (it kept it through its rebase), so this PR and that one overlap on ~40 lines of test. Not a problem while both are drafts/in-flight — but if #2789 merges first, this becomes a no-op diff; if this merges first, #2789's copy is redundant. One of the two should own it, and I have said so on #2789's thread too.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 2793

"The layer that its fix does not cover" is the most useful kind of follow-up: #2785 (and #2789/#2790, its two siblings) fixed the naming collision inside fold_initializer_transpose.py, and a fold is only one of the two places a two-perm graph can go wrong — the other is the packed artefact the builder produces. An arm at make_audio_pack level is what proves the shipped path, not the library.

Three asks:

  1. say what the maker-level arm can see that the fold-level arm cannot — if both assert the same output, one of them is redundant and this PR is the one to justify. If the maker re-derives orientation independently, say so: that is the reason to have both;
  2. the arm belongs to the same collision family — make-audio-pack: a folded weight is named per orientation, so a two-perm decoder packs two of them (Fixes #2779) #2790 and ci: install onnx so the fold/pack rows are gates, and answer --help (the fold fix itself landed as #2785) #2789 are still open and both touch tests/fold_initializer_transpose_test.sh; this PR touches tests/make_audio_pack_test…. State that it does not conflict with them (different file) so the reviewer of the survivor knows the coverage is additive rather than duplicated;
  3. an arm that fails on the pre-fix code — with the fold naming collision restored, the packer must produce the wrong orientation and this arm must red. Without that, it is coverage that may have passed during the whole bug.

And the framing is right: "Refs #2779 (the layer its fix does not cover)" credits the fix and names the gap separately, which is how a partial fix gets finished rather than re-opened.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 2a383b48: READY — and it is the arm that would have caught the bug a shape-based assertion cannot, which I confirmed by swapping the tool rather than by reading it.

It bites. With origin/main's fixed tool the whole file passes; with the pre-fix tool restored (c57d26d8:tools/fold_initializer_transpose.py) the new arm fails on the property it is named for:

FAIL and the two folded weights hold different values: want 'different' got 'identical'
--- 2 failed

That is the square case: perms [1,0] and [0,1] on a 3×3 weight, so both folded tensors have the same shape and only their values differ — exactly the fixture where "the consumers name different initializers" and "the shapes differ" can both pass while the pack is still wrong.

On #2789, which I verdicted earlier for the same builder-level gap: they are complementary, not duplicates, and I ran both against the pre-fix tool to be sure —

#2789 (2×3×4, perms [0,2,1] / [2,1,0])        FAIL … want '1' got '0'          (initializers)
                                              FAIL … want '2x4x3/4x3x2' got '2x4x3/2x4x3'
#2793 (3×3, perms [1,0] / [0,1])              FAIL … want 'different' got 'identical'

Different shapes vs equal shapes. Both arms fail on the old tool and pass on the new one, git merge-tree origin/pr2789 origin/pr2793 is clean (rc 0), and together they cover the 3-D perm case and the case where only the values separate the two — so my read is that both can land; if the cap forces one, this is the stronger assertion.

@bong-water-water-bong
bong-water-water-bong merged commit eab8a1b into main Nov 17, 2026
11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the feat/pack-two-perm-arm branch November 17, 2026 00:17
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

#2789 (a798a995) now carries this arm too, so this PR is a subset: its merge of main picked up tests/make_audio_pack_test.sh along with the CI half (onnx==1.23.2) and the three ctest_skips.txt removals. I re-ran the suite there — ok a two-perm decoder packs / ok each consumer names a folded weight / ok a pack that cannot be folded is refused — so the coverage this PR adds is present on the superset.

Whichever lands second produces an empty or conflicting diff for those 39 lines. Worth closing this one with a pointer, unless it has something #2789 lacks — the only thing I can see is that it is only the arm, which is an argument for landing it first and letting #2789 rebase, not for both.

bong-water-water-bong pushed a commit that referenced this pull request Nov 17, 2026
…807)

Found by running the parser over the REAL texts of tonight's seven PRs instead of only over my
own fixtures, which is the check I had described in the PR body but not done:

  #2793's body: "Refs #2779 (the layer its fix does not cover), #2728 (where the defect came from)"
  before: claims [2728]      <- the NOUN "fix" plus a reference 24 characters away
  after : claims []

GitHub's own closing rule is that the keyword is immediately followed by the reference, so the
regex now requires that adjacency (`Fixes #12`, `fixes: #12`) instead of allowing a gap. Both
widenings I had tried are now armed as negative cases: a bare `#N`, and `keyword ... #N` with
anything between them.

Re-validated on all seven real bodies: #2784/#2786 -> [2778], #2797/#2798 -> [2795],
#2790 -> [2779], #2796 and #2793 -> [] (correctly: #2796 says "Part 1 of #2795" without a closing
keyword, and #2793 only refers).

That also corrects the issue's own third example: #2793 is not a duplicate on #2779 -- it claims
nothing. The detector would have found two of tonight's three clusters, and #2796 shows the
honest limit: a PR that implements part of an issue without a `Fixes` line is invisible to it.
bong-water-water-bong added a commit that referenced this pull request Nov 17, 2026
* ci: name the open PRs that claim the same issue (engine#2807)

Three times in one night a second PR was opened for an issue another lane had started, and a
human reviewer noticed each time: #2778 (#2784/#2786), #2795 (#2796/#2797/#2798), #2779
(#2790/#2793). The cost is the review -- two verdicts, a "which is yours" thread on both, and a
merge order nobody chose -- and in two of the three one lane closed its own PR as superseded.

tools/ci/duplicate_fixes_check.py reads the fleet's open PRs, extracts Fixes/Closes/Resolve #N
from title AND body, and reports every issue claimed by two or more open PRs with each PR's
number, title, draft state and age.

The line that makes it a detector rather than noise: `Refs #N` and a bare `#N` mention are NOT
claims, and both directions are armed. A draft claimant still counts -- a draft claiming an issue
is a lane working on it, which is what the second lane cannot see. Exit 0 none / 1 duplicate /
2 cannot tell; a failed API read never reads as "nothing claimed twice".

Self-test: 12 arms on tonight's real numbers, hermetic. Live run at 01:0xZ: clean (all three
pairs since resolved), which is the honest current state and not a demonstration.

Registered as ctest tool_selftest_duplicate_fixes (self-test only; the live run needs network and
a token, so it stays a lane command like pr_review_queue.py).

* dupfix: the claim keyword must be adjacent to its reference (engine#2807)

Found by running the parser over the REAL texts of tonight's seven PRs instead of only over my
own fixtures, which is the check I had described in the PR body but not done:

  #2793's body: "Refs #2779 (the layer its fix does not cover), #2728 (where the defect came from)"
  before: claims [2728]      <- the NOUN "fix" plus a reference 24 characters away
  after : claims []

GitHub's own closing rule is that the keyword is immediately followed by the reference, so the
regex now requires that adjacency (`Fixes #12`, `fixes: #12`) instead of allowing a gap. Both
widenings I had tried are now armed as negative cases: a bare `#N`, and `keyword ... #N` with
anything between them.

Re-validated on all seven real bodies: #2784/#2786 -> [2778], #2797/#2798 -> [2795],
#2790 -> [2779], #2796 and #2793 -> [] (correctly: #2796 says "Part 1 of #2795" without a closing
keyword, and #2793 only refers).

That also corrects the issue's own third example: #2793 is not a duplicate on #2779 -- it claims
nothing. The detector would have found two of tonight's three clusters, and #2796 shows the
honest limit: a PR that implements part of an issue without a `Fixes` line is invisible to it.

* dupfix: a read failure is not a clean result, and 2 outranks 1 (engine#2807 review)

Both findings were right, and the first one is the false negative the docstring forbids in its own
words: a repo that could not be read still printed "no open issue is claimed by more than one open
PR". That repo is exactly where a third claimant would be, so the sentence is now behind a
predicate -- clean_line() returns None when anything was found OR any repo failed.

Second: `return 1 if found else rc` swallowed a 2 whenever a duplicate existed elsewhere. Now
exit_code() is 2 beats 1 beats 0.

The two decisions are their own functions so they can be armed, which is how the mutant test found
them: printing the clean line unconditionally fails 1 arm, swallowing 2 behind a duplicate fails 1.

Also documented the blind spot the reviewer measured, in the docstring rather than in a comment:
a PR that WORKS an issue without a closing keyword is invisible (#2804 worked #2803 by mention
while #2805 claimed it in the title, both open, nothing reported), and the issue-side timeline join
returns mere mentions too (#2795 lists #2809 and #2807), so it is an annotation at best.

---------

Co-authored-by: bong-water-water-bong <[email protected]>
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.

1 participant