Repository navigation
metal: Qwen3-30B-A3B's decode as a second build-time instance - #849
Conversation
…ntion, a router without a shared expert, the 30B fixture's kernel clauses and mutants, the open's checks for the instance The host build picks one instance by the host-qwen3moe-a3b feature at one point (instance.rs's HOST); a default build refuses a 30B file by name at open and in --plan. The rows arm stays refused for the 30B instance. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tests too Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Verdict: MUST_FIX: one fact ("the host's experts run a shared slot") has two owners in this diff; the kernels and the head-generic attention otherwise hold up.
Must fix
1. HAS_SHARED is defined twice, and router::SHARED already owns the fact
experts.rs:21 defines EXPERT_SLOTS > ROUTED_IDS. clauses_experts.rs:29 defines SHARED_SLOT < EXPERT_SLOTS. Both read router.rule.gated through different expressions, and router_geom::SHARED (router_geom.rs:19) is a third spelling. If one changes (for example a shared expert with no gate), the launch check and the gate disagree and the gate no longer tests what the launch accepts.
Cost: the gate is where a drift would show, so it must not carry its own copy.
Fix: one owner next to SHARED_SLOT, two deletions (net minus one const).
// crates/metal/src/kernels/experts_geom.rs, after SHARED_SLOT
/// Whether the host instance's experts run a shared expert's slot after the routed ones.
pub const HAS_SHARED: bool = SHARED_SLOT < EXPERT_SLOTS;In kernels/mod.rs:67 add HAS_SHARED to the experts_geom re-export. In experts.rs import it from super::experts_geom and delete lines 19 to 21 (they also sit between two use lines). In clauses_experts.rs import it from bloomery_metal::kernels and delete lines 28 and 29.
Non-blocking
⚠ GATED in the gate is a second spelling of key.attn.q_gate: clauses_attention.rs:48 derives it from QG_STRIDE == 2 * HEAD_DIM, while build.rs (agated) reads HOST.key.attn.q_gate. HOST is already imported in the gate's mac.rs; HOST.key.attn.q_gate removes the inference.
⚠ Fourteen tests end at once in a host-qwen3moe-a3b build: check.rs:1530 and the same if !judged_here() { return; } in 13 more. cargo test reports them green with no assertion run. Prefer #[cfg(not(feature = "host-qwen3moe-a3b"))] on the test so the report does not count them, or say in the PR body that they are skipped by design.
⚠ The 30B session takes its prompt in PrefillMode::Steps (session.rs:786), one decode step per prompt token, because the rows arm needs a shared expert (rows.rs:654). The PR body says it is a stepping stone, so this is a question: is the rows arm without a shared expert the follow-up PR?
Checked
- Duplicates: about 30 new items checked; hits are
HAS_SHARED(item 1) andGATED(⚠). dryer pairclauses_attention.rs:553-570~572-589isdequant_kanddequant_v: two short K/V mirrors, only the Q8 constants changed, no fix asked. - Complexity:
ffn_checks18 to 24 is thejoineddecision added in its one owner (fine).check_pair,check_fold,router::checkgrow by match arms for the no-shared case (even growth). The other flagged functions grow by 1 to 3 branches. No#[kernel]or#[target_feature]body is split. - Silent failure: 8 sites followed.
shared.unwrap_or(p.down)andp.shared.unwrap_or(&p.routed)are reached only whenHAS_SHARED/SHAREDis false, and the checks refuse the mismatch by name first.cutwith no store refusesnpast the position;SnapBufs::openandshared_ofreturn named errors.select_f32'sunwrap_or(0)is unchanged code. - Performance: hot path is the decode attention kernel. At head 256 the diff adds no launch, copy, allocation or sync, and the sum order (warp sums, fold) is unchanged.
metal-comparein the PR body covers the changed pipelines. - Kernel shapes at head 128, read by hand: shared block 16 KB (factors 32 heads x 64 segments x 2 floats; tiles 8 KB), q8 tile offsets 8 and 12 and 16 words a row fit it, the fold is 8 threads a head x 32 heads = 256, and the prefill stage fills
2 * PF_TILE_HALVESexactly (the assert holds). - Tests (mutation):
q30_target_folded_within_64(a dropped Q6 second dispatch gives 313, red);each_shape_selects_its_instance(a 30B row withq_gate: trueselects no instance, red); the fourQ30_MUTANTSeach edit a line only the 30B geometry exercises. - Gates: no band or tolerance moved.
model-tax.tsvcount 4 to 13 stays under its existingPIN(2026-10-27)row. - Escape catalog: no match (no shell script in the diff).
Notes
The evidence is an Apple M1 Pro run, not the nvidia-smi list in CONTRIBUTING.md; this change has no CUDA path.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
…her and the gate read it Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Fixed in 13a28bb: |
There was a problem hiding this comment.
Verdict: CLEAN: the one must-fix from the last review is fixed, and the new commit adds no new defect.
Since the last review:
- Must fix 1 (
HAS_SHAREDdefined twice): fixed. experts_geom.rs:28 is now the only definition.experts.rsandclauses_experts.rsimport it. The value is the same as before:SHARED_SLOTistop_k, which equalsROUTED_IDS, soSHARED_SLOT < EXPERT_SLOTSequals the oldEXPERT_SLOTS > ROUTED_IDS. - ⚠
GATEDsecond spelling (clauses_attention.rs:48): still open, not blocking. - ⚠ Fourteen
judged_here()tests that end at once in a 30B build: still open, not blocking. - ⚠ 30B prompt in
PrefillMode::Steps(question): no answer yet.
Checked
- Duplicates: 1 new item checked (
HAS_SHARED), Grep finds one definition. The dryer pair was read in the last review (dequant_kanddequant_v, no fix asked). - Complexity: the new commit adds no function. The earlier crapper outcome stands.
- Silent failure: no new site. The commit removes two consts and adds one re-export.
- Tests: no test added or changed.
ROUTED_IDSandEXPERT_SLOTSare still used inexperts.rs, so no unused import under-D warnings. - Gates: no pin moved.
- Escape catalog: no match.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
Adds Qwen3-30B-A3B (
qwen3moe_a3b) as the second Metal instance next to Qwen3.6-35B-A3B. The attention kernels become head-generic (head dim 128 or 256), the router runs without a shared expert, and the open checks a 30B file against its instance.A host build picks the 30B instance only with the cargo feature
host-qwen3moe-a3b. A default build refuses a 30B file by name, also under--plan. This is a stepping stone: the host lift (follow-up PRs) makes one build open both, and removes the feature. The 30B is not claimed as supported until then.Evidence (second M1 Pro, macOS 27.0.1, on ac7647b):
-D warningsrc 0, default build and--features host-qwen3moe-a3b.just lab-metal: PASS, 155 mutants, each red on its clause.--mutants-allPASS (29 mutants).orphan-testsok;check-model-taxok (a dated PIN row forinstance.rs).metal-compareagainst the instance base: 5 attention pipelines changed (the head-generic attention), ids identical at depth ~0 and 600. The encode trace differs only in one buffer's identity number (dgx-spark: P1, qdot runs the host tier off x86_64 through its scalar mirrors (design S) #15 to dgx-spark: is prefill byte-bound or tensor-bound on GB10? (grouped GEMM time, pp512/pp4096) #18, same size and offset), from the shared expert becoming anOption.just affectedselects 0 of 247 gate recipes (the Metal crate builds on macOS only). The e2e gate is not run: it is barred on the maintainers' Macs.AI use: written and checked with Claude Code.
🤖 Generated with Claude Code