Skip to content

metal: the instance's geometry header is rendered at open, and a shape no row registers compiles from source - #874

Merged
midagedev merged 1 commit into
mainfrom
mac-b1m
Oct 27, 2026
Merged

midagedev merged 1 commit into
mainfrom
mac-b1m

Conversation

@midagedev

Copy link
Copy Markdown
Owner

What

The Metal instance's #define header is now rendered at open, from the file's Geometry. A shape the kernels take opens without a registry row.

  • One renderer (crates/metal/src/kernels/header.rs) writes the header for build.rs and for the open. For each registered row, the rendered text is the text build.rs writes, byte for byte.
  • holds → Geometry::check. Each kernel's const fn holds becomes Geometry::check, a named refusal at open: which kernel, which axis, which value.
  • Unregistered shapes: a geometry every kernel takes but no row registers compiles from source at open (instance::open_key). A metallib build falls back to the source path for it. generate_metal and bloomery-serve-metal then print that no gate checked that shape.
  • Docs: docs/research/metal-all-models.md struck through its "no load-time path for an unregistered shape" and corrected it in place.

Evidence (second M1 Pro, [dev])

  • The .metal sources build.rs writes for the registered instances (main and tensor × two) have the same sha256 as on the base.
  • metal-compare against the parent: rc 0, 194 pipelines the same, traces equal at depth ~0 and 600, ids equal.
  • just lab-metal rc 0, with 161 + 59 mutants, each red on its clause. just lab-metal-e2e rc 0. Clippy -D warnings passes on the three builds.
  • FAIL-first: six mutants of the renderer and of check turn red.
  • Off the registry: two probe shapes (hidden 3072 and 4096) went through library compile and every pipeline build on the GPU. No gate checks their numbers; the binaries say so when such a file opens.
  • just affected: no box gate.

AI use: written and checked with Claude Code.

🤖 Generated with Claude Code

…e no row registers compiles from source

One renderer writes the #define header from a Geometry, for build.rs and for
the open. A registered row's rendered text is the text build.rs writes, byte
for byte. The kernels' holds become Geometry::check, a named refusal at open.
A geometry every kernel takes but no row registers opens on the source path,
and the binaries say no gate checked that shape.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Oct 27, 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 three failure paths and the code blocks each one. Two non-blocking items remain.

Non-blocking

⚠ The fault table in the header has no content assertion: crates/metal/src/kernels/header.rs:17. the_header_is_the_geometry skips every FAULT_* and LAYER_NONE define. the_rendered_sources_are_the_built_ones compares two outputs of the same header::program. Mutant: write 0 in place of *site as u32. No test turns red, and the kernels then raise a fault under the wrong site code. The sha256 check in the PR body ran once. Direction: in header.rs tests, assert that fault_sites() holds one #define BLOOMERY_FAULT_SITE_<NAME> <code> per FaultSite::ALL, and LAYER_SHIFT and FAULT_WORDS.

⚠ The router hidden 3136 refusal text is pinned in three tests: geom.rs:394, instance.rs:851 and library.rs:694. Each test guards a different wrapper, so none is a duplicate today. The full-string assertion in geom.rs repeats the instance.rs one, though. Drop the last assert_eq! of a_geometry_a_kernel_cannot_take_is_refused_by_name; the table already pins kernel, axis and value.

Checked

  • Duplicates: 14 new items checked (KernelRefused, yes_no, registered, open_key, OPENED, header::*, rendered, differs_at, Display for Instance, and others), none duplicated. define_of moved, it was not copied. The dryer found 0 pairs. The refusal message in generate_metal.rs and bloomery_serve_metal.rs is the same 4 lines; two short copies cost less than an owner, so no finding.
  • Complexity: attention_geom::holds 1→18 and router_geom::holds 1→6 are new functions, each a flat list of one-refusal guards, one clause each. No split needed. The two bin open and generate functions grew by one branch each, harmless.
  • Silent failure: 7 sites followed. scale_of NaN is refused by check before any header is written. ring_rows saturating_sub is refused by the ring_rows != 11 clause. gqa divides by n_kv, and select_gqa already refuses n_kv == 0 (shape.rs:869). The OPENED lock poison recovery is safe, because the guarded Vec is only appended to after the check. No _ => {}, ok() or unwrap_or(0) on a value that reaches a consumer.
  • Adversarial: (1) two keys opened in one process both named unregistered: no cache in the library or kernels is keyed by name, the pipeline sizes read Geometry; OPENED is keyed by Key. (2) HOST_GEOMETRY shims sizing a buffer for another geometry: the arch reads geom (arena.rs, check.rs, rows.rs), not the shims. (3) An unregistered file reaching a gate: the kernels gate refuses it by name (gate_metal_qwen35moe_kernels/mac.rs:549), and the e2e gate needs its own row.
  • Tests (mutation): the 14-row table turns red on each clause, a flipped check order included. Removing .check() in open_key or rendered turns a test red. Removing the OPENED cache turns ptr::eq red. Dropping a define from the header turns the defined list comparison red. The fault table is the gap (see ⚠).
  • Gates: no pin moved, none removed. Several per-axis clauses moved from const asserts to runtime check, each still covered by the table.
  • Performance: load-time only (open and build). No hot path touched.
  • Escape catalog: no pattern matched (no shell scripts changed).

Notes

  • The evidence is from an M1 Pro (lab-metal, lab-metal-e2e, metal-compare). No nvidia-smi gate run is in the PR text, so gpu.json says no evidence. The PR touches no CUDA crate.

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

@midagedev
midagedev merged commit 95b962c into main Oct 27, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant