Repository navigation
metal: build-time instances, the model geometry a body is compiled for, picked at open - #836
Conversation
…r, picked at open by the file's facts in the one check Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Verdict: MUST_FIX: the move is sound, but one lookup is copied out of its owner and one new refusal clause can never decide anything.
Must fix
1. gqa_row is a second copy of models::shape::gqa_row
crates/metal/src/instance.rs:69 re-implements the lookup of shape::gqa_row_v (head == value, first row that takes(group)) in const form. The doc comment says so. A new test (the_registered_rows_are_the_shape_tables, first assert) exists only to keep the two copies equal. The shape table already owns the const form for routers (router_row, shape.rs:501), so the const lookup belongs in models.
Cost: a change to the lookup rule (a new GroupRule, a tie-break) must be made twice, and one copy can drift without a build error.
Fix: make the owner const, delete the copy and the first assert of that test.
pub const fn gqa_row_v(head: u32, value: u32, group: u32) -> Option<GqaInst> {
let mut i = 0;
while i < GQA.len() {
let r = GQA[i];
if r.head == head && r.value == value && r.takes(group) {
return Some(r);
}
i += 1;
}
None
}gqa_row in shape.rs:869 becomes pub const fn too (it only calls gqa_row_v). In instance.rs the row is then row: match shape::gqa_row(256, 16 / 2) { Some(r) => r, None => panic!("the shape table has no GQA row for this head at this group") },.
2. The new hidden-width clause in head_checks never decides a refusal
crates/metal/src/arch/qwen3moe/check.rs:765 refuses a hidden that is not a multiple of the head type's block. The check a few lines above already refuses every hidden != router::K, and router::K (2048) is a multiple of every block size (32, 256). So the clause fires only when an earlier item has already refused, and adds a second item for the same cause. No test covers it: deleting the clause turns nothing red.
Cost: dead code with a message that implies a case that does not exist. Add it with the first instance whose hidden width is not a block multiple.
Fix: delete the else if !hidden.is_multiple_of(...) { ... return false; } branch.
Non-blocking
⚠ Key equality includes the shape rows' at text: crates/metal/src/instance.rs:18 stores a whole RouterInst/GqaInst, so Key == also compares the at: &'static str provenance. A reworded at in models makes every file "no instance" with the same axes. Compare the axes, not the row, or say in the doc that the row is identity.
⚠ shared_slot ignores the gate: crates/metal/src/kernels/experts_geom.rs:19 returns top_k while slots adds the shared slot only when rule.gated. For an ungated instance the header would name a slot past the end. Not reachable with one row; add the row's own check when the second row comes.
Checked
- Duplicates: 24 new items checked; one hit (finding 1). dryer pair
library.rs:349-356~363-370: two thin wrappers that differ in the language version; not one fact. - Complexity:
check::read16→17,open_as15→16,generate28→29,with_geometry38→39. Each is one added branch or call, even growth; no split asked. - Silent failure: 7 sites followed (
selectmap_err,instance_of,sources,METALLIBSlookup,HOST_BUILT,agree, the instance compare inopen_as). Each ends in a named refusal or a build panic. - Tests:
a_shape_no_instance_is_built_for_is_the_opens_first_itemprotects theselectcall inread; the mutant "fall back toREGISTERED[0]" turnsof_key's test red. The newhead_checksclause has no test (finding 2). - Gates: no pin moved. One new const assert (
SCALE² · HEAD_DIM == 1) tightens, does not relax. - Hot path: none touched (build, open and load time only). Escape catalog: no pattern matched.
Notes
- The Metal e2e gate was not run (the PR body says so); the box fixture batch result is promised in a later comment. Evidence is an M1 Pro, not an
nvidia-smicard.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
… a module-level include orphan-tests cannot read the items a module-level include! brings in; BUILT and METALLIBS are now ordinary consts whose values are included. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Verdict: MUST_FIX: the new commit is correct, but both must-fix items of the last review are still open.
Since the last review
- Must fix 1 (
gqa_rowcopy): still open. instance.rs:69 is unchanged, andshape::gqa_row_vatcrates/models/src/shape.rs:860is still notconst. - Must fix 2 (dead hidden-width clause): still open. check.rs:765 is unchanged.
- ⚠
Keyequality includesat: still open (instance.rs:18). - ⚠
shared_slotignores the gate: still open (experts_geom.rs:19).
Must fix
1. gqa_row is a second copy of models::shape::gqa_row
instance.rs:69 re-implements the lookup of shape::gqa_row_v (head == value, first row that takes(group)) in const form. A test exists only to keep the two copies equal.
Cost: a change to the lookup rule must be made twice, and one copy can drift without a build error.
Fix: make the owner const, delete the copy and the first assert of the_registered_rows_are_the_shape_tables.
pub const fn gqa_row_v(head: u32, value: u32, group: u32) -> Option<GqaInst> {
let mut i = 0;
while i < GQA.len() {
let r = GQA[i];
if r.head == head && r.value == value && r.takes(group) {
return Some(r);
}
i += 1;
}
None
}gqa_row (shape.rs:869) becomes pub const fn too. In instance.rs the row is then row: match shape::gqa_row(256, 16 / 2) { Some(r) => r, None => panic!("the shape table has no GQA row for this head at this group") },.
2. The hidden-width clause in head_checks never decides a refusal
check.rs:765 refuses a hidden that is not a multiple of the head block. An earlier check already refuses every hidden != router::K, and router::K (2048) is a multiple of 32 and 256. The clause fires only after another item has refused. No test covers it.
Cost: dead code with a message for a case that does not exist. Add it with the first instance whose hidden width is not a block multiple.
Fix: delete the else if !hidden.is_multiple_of(...) { ... return false; } branch.
Non-blocking
⚠ shared_slot ignores the gate: see the item above; add the row's own check with the second row.
⚠ Key equality compares at text: compare the axes, not the row.
Checked
- Duplicates: the new commit adds 2 items (
built.rs,metallibs.rstables), none duplicated. dryer pairlibrary.rs:354-361~368-375: two wrappers that differ in the language version; not one fact. - Complexity:
check::read,open_as,generate,with_geometryeach rose by 1 in the full PR (even growth). The new commit changes none. - Silent failure: 2 sites followed in the new commit. A missing
metallibs.rscannot happen, becauseMETALLIBSand the file share thetoolchaincondition.HOST_BUILTstill ends in a build panic. - Tests: none added or changed in the new commit.
- Gates: no pin moved. Escape catalog: no pattern matched. Hot path: none (build time).
Notes
- The new commit splits the
instances.rsinclude into two typedconstexpressions. Thecfg(metal_lib = "metallib")guard onMETALLIBSmatches the build script. I found no defect in it. - The Metal e2e gate was not run (the PR body says so). The evidence is an M1 Pro, not an
nvidia-smicard.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
Rebased on main after #837 (branch On 7aea0c7, an M1 Pro: clippy |
…tecture registers its own Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Verdict: MUST_FIX: the new commit is correct, but both must-fix items of the last review are still open.
Since the last review
- Must fix 1 (
gqa_rowcopy): still open. instance.rs:69 is unchanged, andshape::gqa_row_vatcrates/models/src/shape.rs:860is still notconst. - Must fix 2 (dead hidden-width clause): still open. check.rs:765 is unchanged.
- ⚠
Keyequality includesat: still open (instance.rs:18); compare the axes, not the row. - ⚠
shared_slotignores the gate: still open (experts_geom.rs:19); add the row's own check with the second row.
The new commit only adds one row to tools/model-tax.tsv.
Must fix
1. gqa_row is a second copy of models::shape::gqa_row
instance.rs:69 re-implements the lookup of shape::gqa_row_v (head == value, first row that takes(group)) in const form. A test exists only to keep the two copies equal.
Cost: a change to the lookup rule must be made twice, and one copy can drift without a build error.
Fix: make the owner const, delete the copy and the first assert of the_registered_rows_are_the_shape_tables.
pub const fn gqa_row_v(head: u32, value: u32, group: u32) -> Option<GqaInst> {
let mut i = 0;
while i < GQA.len() {
let r = GQA[i];
if r.head == head && r.value == value && r.takes(group) {
return Some(r);
}
i += 1;
}
None
}gqa_row (shape.rs:869) becomes pub const fn too. In instance.rs the row is then row: match shape::gqa_row(256, 16 / 2) { Some(r) => r, None => panic!("the shape table has no GQA row for this head at this group") },.
2. The hidden-width clause in head_checks never decides a refusal
check.rs:765 refuses a hidden that is not a multiple of the head block. An earlier check already refuses every hidden != router::K, and router::K (2048) is a multiple of 32 and 256. The clause fires only after another item has refused. No test covers it.
Cost: dead code with a message for a case that does not exist. Add it with the first instance whose hidden width is not a block multiple.
Fix: delete the else if !hidden.is_multiple_of(...) { ... return false; } branch.
Non-blocking
⚠ PIN date is in the future: tools/model-tax.tsv:137 says PIN(2026-10-27). The review ran on 2026-10-26, and the other new rows use the day they were written. Set the date of the commit.
Checked
- Duplicates: the new commit adds 1 item (the tax row), none duplicated. Earlier dryer pair
library.rs:354-361~368-375: two wrappers that differ in the language version; not one fact. - Complexity:
check::read,open_as,generate,with_geometryeach rose by 1 in the full PR (even growth). The new commit changes none. - Silent failure: no new site in the new commit.
- Tests: none added or changed in the new commit.
- Gates: no pin moved except the new tax row above. Escape catalog: no pattern matched. Hot path: none (build time).
Notes
- The Metal e2e gate was not run (the PR body says so). The evidence is an M1 Pro, not an
nvidia-smicard.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
… not a copy; the head check drops a branch no file reaches Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Verdict: CLEAN: the new commit fixes both must-fix items of the last review and adds nothing that breaks.
Since the last review
- Must fix 1 (
gqa_rowcopy): fixed.gqa_row_vandgqa_rowin shape.rs:860 areconst fn, and the copy ininstance.rsis gone.GQAis aconstslice,GqaInstisCopyandtakesisconst fn, so the const loop compiles. - Must fix 2 (dead hidden-width clause): fixed. The branch is gone from check.rs:765; the
hidden != router::Kcheck at line 731 still refuses every other width. - ⚠ PIN date in the future: still open, tools/model-tax.tsv:137 says
PIN(2026-10-27). Set the date of the commit. - ⚠
Keyequality includesat: still open (instance.rs:18). - ⚠
shared_slotignores the gate: still open (experts_geom.rs:19).
Checked
- Duplicates: the new commit adds 0 items and removes one copy. The earlier dryer pair
library.rs:354-361~368-375is two wrappers that differ in the language version; not one fact. - Complexity:
check::read,open_as,generate,with_geometryeach rose by 1 in the full PR (even growth). The new commit changes none. - Silent failure: no new site. The
Nonearm ofgqa_rowininstance.rs:77is a constpanic!, so it fails the build. - Tests: the removed assert in
the_registered_rows_are_the_shape_tablesonly checked the deleted copy against the owner. No test lost a contract. - Gates: no pin moved. Escape catalog: no pattern matched. Hot path: none (build time and open).
Notes
- The Metal e2e gate was not run (the PR body says so). The evidence is an M1 Pro, not an
nvidia-smicard.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
The Metal kernels are compiled for one model geometry: head size, KV heads, expert width, router size. This change makes that geometry a build-time instance.
build.rscompiles the MSL once per instance row. The open picks the row from the file's facts, inside the one check owner (check.rs). A file whose shape no instance is built for is refused by name, and--planprints that refusal as an item.Today there is one row, Qwen3.6-35B-A3B's. So this is a move: no kernel or pipeline changes.
Evidence:
just metal-compareagainst the base: 181 pipelines same, added 0, changed 0. Decode trace equal at depth ~0 and 600, ids differ 0.-D warningsfor both feature sets, 46 lib tests,just lab-metalPASS (155 mutants, each red on its clause).check::tests::a_shape_no_instance_is_built_for_is_the_opens_first_item, went red on a mutant that falls back to the first row.Cargo.lockchanges: bloomery-metal gains a dependency. The result follows in a comment.AI use: written and checked with Claude Code.
🤖 Generated with Claude Code