Skip to content

metal: the dense Qwen3.8-27B from its MLX folder, and the qwen38d row of the e2e gate - #918

Merged
midagedev merged 6 commits into
mainfrom
mac-qwen38d
Oct 28, 2026
Merged

midagedev merged 6 commits into
mainfrom
mac-qwen38d

Conversation

@midagedev

Copy link
Copy Markdown
Owner

What and why

Metal runs the dense Qwen3.8-27B. Its MLX folder (mlx-community/Qwen3.8-27B-4bit) opens and is checked against
mlx-lm.

  • Dense FFN route. The instance's FFN axis is Routed or Dense.
    • Dense decode is the existing pair/fold at one slot: id 0, weight 1.
    • The dense prompt runs norm_rows → gate/up GEMM → swiglu_rows (a new kernel in route.metal) → down GEMM.
  • The qwen38d row of the Metal e2e gate.
    • Its fixture is a 4-layer cut of the real folder, in its stored bits (tools/mlx-fixture-cuts/qwen38d-mlx.json,
      fixture cut): three delta layers and one attention layer.
    • Its pins are mlx-lm f32 logits of that cut (pins/qwen38d.{txt,f32}). tools/mlx-logits.py now gathers only
      the dumped ids' embedding rows.
  • Three mutants: dense_slot_one, dense_weight_half, dense_pass_swiglu_swapped.
  • A dense band for q_free.
    • FREE_BAND (0.26) carries a router-flip term a dense session does not have. The swapped-SwiGLU mutant stayed
      inside it: worst 1.42e-2, against 2.77e-5 clean.
    • A session with no routed layer is now held to FREE_BAND_DENSE_LAYER × √layers (2.4e-3 at 4 layers): 3Δ a
      layer, where Δ is the pass's f16 operand rounding.

Release notes: Added — the dense Qwen3.8-27B runs on Metal from its MLX folder.

Code shape

  • No second copy. Dense decode reuses the routed pair/fold kernels at one slot.
  • Model code holds only architecture facts. The FFN kind is read from the file's layers.
  • Dead code is gone.
  • No silent failure.
  • Comments state what is true now.
  • No relaxed gate. The new band is tighter than the old one, for dense sessions only, and carries
    PIN(2026-10-28): and its derivation. FAIL-first: the swapped-SwiGLU mutant is red under it.
  • cargo fmt and cargo clippy are clean on what I touched.

Duplication found or removed: none.

What I ran

On the second M1 Pro, on this branch rebased on main (#916's drain included):

  • cargo test -p bloomery-metal --lib: 94 passed.
  • gate_metal_qwen35moe_e2e:
    • the default row, --row qwen3moe and --row qwen38d: PASS each;
    • qwen38d q_free: worst 2.769e-5 (dense band 0.0024); q_tensor, q_mark_cut and q_marked all under 3.3e-5.
  • --mutants-all:
    • qwen35moe row: PASS, 12 mutants each red on its clause, 3 kept;
    • qwen38d row: PASS, 3 mutants each red on its clause, 0 kept.
  • generate_metal smoke on the qwen38d split: 220,220,220,220,220,220,220,220, the same on two runs. Four of the
    27B's layers pick the space token. The smoke holds the CLI path; m_logits holds the numbers.
  • just remote-static origin/main: mac-static: ok.
  • tools/gate-batch.sh --ledger --tier fixture:
    • gate-fixture-budget green;
    • gate-fixture deferred to the real tier (real-only).

AI use: written and checked with Claude Code.

🤖 Generated with Claude Code

https://claude.ai/code/session_01X1hsQfNpqr2jqmpYe8SFXd

midagedev and others added 6 commits October 28, 2026 21:32
…ers the dumped ids' embedding rows

tools/mlx-fixture-cuts/qwen38d-mlx.json cuts layers 0-3 (three delta layers, one full attention) of
mlx-community/Qwen3.8-27B-4bit in their stored bits: 122 tensors, 2,286,737,728 bytes. The directory holds the
Metal-only MLX cuts; the CUDA fixture tier and the registry's Cut rows do not read it. Two cut tests plan the
fixture and edit the config from the committed real headers.

mlx-logits dump dequantizes only the dumped ids' embedding rows, by the rule floatize uses, so the 27B pin fits a
32 GB Mac. The qwen35moe and qwen3moe pins re-dump to the same fnv1a.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01X1hsQfNpqr2jqmpYe8SFXd
An instance's FFN axis is routed or dense. A dense layer's decode runs the experts' pair and fold at one slot, id
0, weight 1, over a one-expert stack; its prompt runs norm_rows, the gate/up GEMM, swiglu_rows and the down GEMM.
The e2e gate gains the qwen38d row (the 4-layer cut of Qwen3.8-27B-4bit, its mlx-lm pin at positions 0-3) and the
mutants dense_slot_one, dense_weight_half and dense_pass_swiglu_swapped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01X1hsQfNpqr2jqmpYe8SFXd
FREE_BAND (0.26) carries a router-flip term a dense session does not have,
so the dense prompt's swapped SwiGLU stayed inside it. A session whose
layers route nowhere is held to 3Δ a layer (the pass's f16 operand rounding)
over its layers in quadrature, and each verdict line names the band it used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01X1hsQfNpqr2jqmpYe8SFXd
@github-actions github-actions Bot added documentation Improvements or additions to documentation tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 28, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: CLEAN: I built several failure paths for the dense route and each one is blocked in code; the open items below are not blocking.

Non-blocking

⚠ The dense band's derivation does not add the mixer and the FFN: pass.rs:103. The PIN says a layer's update carries at most 3Δ: the mixer at 3Δ (U_L0_REL), the FFN at 1.9Δ. A layer has both, so the bound is about 3.5Δ in quadrature, not 3Δ. The band is still safe (clean worst 2.77e-5 against 2.4e-3). Fix the sentence or the constant before the 64-layer row is gated.

⚠ ffn() builds a router from four zipped options: arena.rs:894. The _ => arm also takes the impossible case "gate_inp present, another buffer absent" and would lay the dense route over a router layer. Build RouterBufs inside one gate_inp.map(..).transpose()?. The comment "made in the order the arena always made them" states no contract: allocation order does not change a result.

⚠ A measured result sits in a comment the comment check does not cover: justfile:152 ("Four of the 27B's layers pick the space token every step"). It has no conditions. Keep "the smoke holds the CLI path, m_logits holds the numbers".

Optimization headroom

  • G. Per-launch fixed cost: rows.rs:748. The prompt's dense FFN runs gate GEMM, up GEMM, swiglu_rows and down GEMM with 4 barriers. The decode pair and the grouped tile already fuse pair_swiglu into the epilogue. A fused pair would remove 1 launch, 1 barrier and 3·m·ff f32 of h/up traffic per layer per pass (m = rows, ff = 17,408 on the 27B) [derived].

Checked

  • Duplicates: 14 new items checked, none duplicated. GATED_ROUTED is now the one owner of the 256-expert axes. The dense-route skip in the four session.rs walk wrappers is one fact in four wrappers; walk.rs::ffn cannot own it because the CUDA route runs on FfnRoute::Dense. A new owner would add elements.
  • Silent failure: 9 sites followed. Each gives a named refusal. The dense route's ids and weights are laid once at open, and no reset zeroes them.
  • Tests: mutation checks on a_dense_layer_has_no_router_group, a_dense_layer_the_launches_cannot_run_is_refused_by_name and the three DENSE mutants are red.
  • Gates: one new band, tighter than before, dated PIN, FAIL-first in the PR body. No gate removed or relaxed.
  • Escape catalog: C1 to C4 do not match.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@midagedev
midagedev enabled auto-merge (rebase) October 28, 2026 13:04
@midagedev
midagedev merged commit e7eae36 into main Oct 28, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant