Skip to content

metal: a prompt call on a file with no recurrent store runs to its end - #856

Merged
midagedev merged 3 commits into
mainfrom
mac-q30fix
Oct 27, 2026
Merged

midagedev merged 3 commits into
mainfrom
mac-q30fix

Conversation

@midagedev

Copy link
Copy Markdown
Owner

What

A prompt call walks its checkpoint marks. A file with no recurrent store (Qwen3-30B-A3B) has none, so the walk ran no batch. The first prompt failed in both prefill modes: qwen35moe target: a prompt of 30 ids at position 0 stepped no id. Now the call's end is its one point.

Evidence (second M1 Pro, Qwen3-30B-A3B-Instruct-2507-Q4_K_M.gguf, [dev])

  • main (e489cd3): generate_metal --prompt … ends rc 1 with the error above (--prefill batch and steps).
  • This branch: rc 0. --prefill batch and --prefill steps give the same 32 greedy ids. The 64-token text is coherent ("The bicycle has its origins in the draisine, invented by German Baron Karl von Drais in 1817, …"). decode_rest_ms 22.0.
  • Against llama.cpp (930e2fa59, CPU, same file, same 30 prompt ids): the first pick agrees. At the second pick, llama.cpp gives logprob −0.496 to 14311 and −1.443 to our 34986. Given our first two ids, llama.cpp follows ours for 30 of 30 tokens. Given its two ids, ours follows llama.cpp for 21 of 30.
  • The Qwen3.6 fixture e2e gate (lab-metal-e2e) passes every clause on main on the same Mac.
  • A gate clause over the qwen3moe fixture that turns red on this bug follows in this PR.

AI use: written and checked with Claude Code.

🤖 Generated with Claude Code

checkpoint_marks is empty without a recurrent store, so the prompt walk had
no point and ran no batch: Qwen3-30B-A3B's first prompt failed with
"stepped no id". The call's end is now its one point.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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: MUST_FIX: the fix still fails for a marked prompt call on a file with no recurrent store, which is the server's normal call.

Must fix

1. A marked call with no recurrent store fails in the batch path

crates/metal/src/arch/qwen3moe/target.rs:127 The new fallback sets points = [to] but still passes the caller's marks to call.run (line 149). The server always passes its chat-message marks (crates/serve/src/genloop.rs:1252, crates/metal/src/server.rs:109). Path: Qwen3-30B-A3B, --prefill batch, a prompt of more than PASS_ROWS ids with one mark inside → Call::run takes the pass branch (line 226) → Session::pass gets non-empty after_rows and no rows.snaps (session.rs:1141) → SnapBufs::open returns copies of a model with no delta layer (rows.rs:157). The server request fails. Your test used generate_metal, which passes no marks, so it did not reach this path.
Cost: the same bug moves from generate_metal to bloomery_serve_metal; fixing it in this PR is one line.
Fix: with no store a mark has nothing to copy, so drop the marks together with the empty points.

        let mut points = self.checkpoint_marks(from, to);
        let marks = if points.is_empty() {
            points.push(to);
            &[][..]
        } else {
            marks
        };

points is empty only with no store (Checkpoints::marks returns [to] for any to > from, and ids is not empty here). Put this after the inside check so bad marks are still refused by name.

Non-blocking

⚠ The gate is not in this PR: the body says "A gate clause over the qwen3moe fixture … follows in this PR", but files.txt lists one file. No test turns red if the if points.is_empty() branch is removed (mutant: drop the branch → stepped no id returns, nothing fails). Add the clause, with a marked call over the batch path, or remove the sentence.

Checked

  • Duplicates: 3 new items checked (the fallback, points.push, the marks shadow), none duplicated. Checkpoints::marks (crates/gpu/src/checkpoint.rs:288) already returns [to] for no ledger. Dryer: 0 pairs.
  • Complexity: prompt_marked 16 → 17, one branch added to an existing function. Folded into finding 1.
  • Silent failure: 2 sites followed (checkpoint_marks empty return, last_pick None). The stepped no id error stays as the guard.
  • Tests: none added; mutation result is in the ⚠ above.
  • Gates: no pin moved.
  • Escape catalog: not read in full; no listed pattern matched this diff (one Rust hunk, no shell).

Notes

  • The PR body has Apple M1 Pro evidence, no nvidia-smi line. The change touches only the Metal crate.

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

…ts marks

The server passes chat marks; with no store the batch arm asked for
checkpoint copies a model with no delta layer cannot open.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@midagedev

Copy link
Copy Markdown
Owner Author

Fixed in ed32927 as suggested: with no recurrent store the marks are dropped together with the empty points, after the inside check. On the second M1 Pro, bloomery-serve-metal with Qwen3-30B-A3B Q4_K_M answers a two-message chat request ("1. Rhine 2. Danube 3. Thames"). With the previous fallback, which keeps the marks, the same request gets 500 engine: qwen35moe rows arena: copies of a model with no delta layer. Clippy -D warnings rc 0. The e2e gate row over the qwen3moe fixture, with a marked batch-prefill call, follows in this PR.

github-actions[bot]
github-actions Bot previously approved these changes 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: the new commit drops the marks together with the empty points, so a marked call on a file with no recurrent store no longer reaches SnapBufs::open.

Since the last review:

  • Must fix 1 (marks passed to call.run with no store): fixed at target.rs:128. The inside check at line 115 still runs first, so bad marks are refused by name.
  • ⚠ Gate not in this PR: still open. files.txt lists one file.

Non-blocking

⚠ The gate clause is still missing: the PR body says it "follows in this PR", but the diff has one file. Mutant: remove the points.is_empty() branch → stepped no id returns and no test fails. Add a clause over the qwen3moe fixture that includes a marked call with more than PASS_ROWS ids, or remove the sentence from the body.

Checked

  • Duplicates: 2 new items checked (marks shadow, &[][..]), none duplicated. Dryer: 0 pairs.
  • Complexity: prompt_marked 16 → 17, one branch added to an existing function; the branch is the owner of the "no store" case, so no split is asked.
  • Silent failure: 2 sites followed. checkpoint_marks returns empty only when checkpoints is None (session.rs:1549). Session::checkpoint at the end point with no store is a no-op copy by its own doc. The stepped no id error stays as the guard.
  • Failure scenario built: a marked server call, batch mode, no store → marks are empty, after is empty, Session::pass leaves no snaps, no checkpoint_copy runs. Blocked.
  • Tests: none added; mutation result is in the ⚠ above.
  • Gates: no pin moved.
  • Escape catalog: no listed pattern matched this diff (one Rust hunk, no shell).

Notes

  • The PR body has Apple M1 Pro evidence, no nvidia-smi line. The change touches only the Metal crate.

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

The gate's clauses run over a row table: the qwen35moe fixture and the
qwen3moe one (no shared expert, no recurrent store; a delta clause prints
SKIP with its reason). q_marked holds a marked batch prompt call to the
unmarked one bit for bit and to the stepped run within q_free's band;
lab-metal-e2e runs both rows and a generate_metal smoke on each fixture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo 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: the new commits add the gate clause the earlier review asked for, and I found no failure path in them.

Since the last review:

  • ⚠ Gate not in this PR: fixed. q_marked is added at pass.rs:728 and runs on both rows through --row.

Non-blocking

⚠ No gate output in the PR body: the body says "a gate clause follows in this PR", but it shows no run of q_marked and no FAIL-first. Add the lab-metal-e2e output for both rows, and the red line of q_marked with the points.is_empty() branch in target.rs:128 removed.

⚠ Second pick differs from llama.cpp: the body reports 14311 (−0.496) against our 34986 (−1.443). The gate checks this file against ik's fx_ref_qwen3moe sets, not llama.cpp. Say in the body which clause (q_ref, a_free) bounds this difference, or that the difference is a known quant effect.

⚠ Self-pinned ids: justfile:130 pins 8 ids, and only the first has a reference (ik). A legitimate kernel change will move the other 7. When one moves, re-pin it with a dated PIN(YYYY-MM-DD): line.

Checked

  • Duplicates: about 12 new items checked (row.rs, teacher_forced, conv_rows, kv_row, prompt_bits_marked, and the others). teacher_forced is an extraction of free_run's loop, so it adds no copy. Dryer: 0 pairs.
  • Complexity: q_marked is new at 16 and linear, one clause. mac::main 63 → 77 is flag handling in the entry point. the_refusals 30 → 35, h_prompt and s_serve +1 to +2 are branches on row.recurrent, so no split is asked.
  • Silent failure: 4 sites followed. Session::instance_of and the row against delta-layer count check fail by name (clause open: FAIL). row::current() panics by name if no row is selected. FfnRoute::Dense returns an error. None returns a default.
  • Tests: mutation on q_marked, drop the points.is_empty() branch: Target::prompt_marked returns stepped no id and the clause is red. Mutation, keep the marks with no store: checkpoint_positions().contains(&MARKED_AT) != recurrent is red. Mutation, a recurrent file drops its mark: the same check is red. I could not run the gate (macOS only).
  • Gates: no pin moved. New clause and row skips each carry a reason.
  • Performance: gate and tools only, no hot path.
  • Escape catalog: no pattern matched (one justfile hunk, || die after each substitution).

Notes

  • The PR body has Apple M1 Pro evidence and no nvidia-smi line. The change touches only the Metal crate.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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