Skip to content

train: Bolt placed prompt batches (b3d) + workstation owns the placed arena (#508) - #525

Closed
midagedev wants to merge 17 commits into
mainfrom
train-b3d-508
Closed

midagedev wants to merge 17 commits into
mainfrom
train-b3d-508

Conversation

@midagedev

Copy link
Copy Markdown
Owner

One train for two pieces whose gate sets overlap. It replaces #499 (b3c → b3d) and #508.

b3d (13 commits): placed Nemotron-3.5 Bolt.

  • When the whole model does not fit the card, it loads placed: card experts plus a host leg.
  • The placed prompt runs in batches through the common prompt pass, not as decode steps.
  • The host run keeps one scratch per feed-forward width.
  • The watchdog counts a token's pass inside a guarded call as progress.
  • resident_bytes counts the scratch through scratch_bytes, its one owner.
  • gate_nemotron_h_moe_e2e holds the placed prompt batch equal to the whole-card batch.

#508 (3 commits): placement::workstation owns the placed machine's arena (placed_with_arena, counted_arena_bytes). Qwen3.8's plan counts the ubatch arena through it, and the model's own copy is gone.

Gates (box, fixture tier, tools/gate-batch.sh --ledger, derived from just affected):

  • Union at 146c130: 185 items, 184 green.
    • gate-gpu-qwen38-nodes-remote was deferred (needs-env).
    • gate-glm5next-meta went green after just dump-ref-glm5next-hf-map. Its set from 4aca14a was not on the box yet.
  • Real tier: gate-placement and gate-gpu-nemotron-e2e green.
  • Rebased onto fda5eca (misaligned vector views refused at launch, plus Mac tools). On that tree the interaction set ran green: the gates that run this train's new launches and placement (gate-gpu-lib, the six nemotron gates, gate-placement, gate-gpu-nemotron-e2e).
  • Reason, 2026-10-20: the other 170 items were green at 146c130. fda5eca landed with its own gates. The remaining risk is a misaligned view in this train's new launches, which the interaction set covers. The full list runs again in the release batch.
  • Static (just remote-static): lint 33 = the ratchet. check-emb2 and check-recipes failed only on the remote Mac under load; check-emb2 passes alone. The reds differ each run (timing self-tests), the known flake class round leaseflk2b fixes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K8ndZ5qubx9kYLVxTgbvEq

midagedev and others added 16 commits October 20, 2026 11:02
HostRun keeps one Option<HostLayer> per model layer, built by build_at from
the strictly ascending set of layers that carry a host share, so a body that
interleaves MoE layers with others (Nemotron 3.5 Bolt) can place routed
experts on the host. A layer with no host share is refused by name at its one
lookup (view_of); a set out of order or a view count that differs is refused
at load. model::host_run takes the set; V4.1, GLM-5.3 and placed Qwen3.8 pass
the contiguous run they had, so for them this is a move: canon-check 922/922
identical against bc4bf07, and the owning gates green (fixture tier, plus
gate-gpu-hybrid, qwen3moe-e2e and mimo2-flash on the real tier).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rompt run as steps is not read as wedged

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the whole model does not fit the card

The seat picks the placed load by itself, so a 12 GiB card serves Bolt with no flag.
gate_nemotron_h_moe_e2e gains host_tier_near_whole_card (card, mid, host and room12g arms).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s names.w without a reborrow (clippy)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…run whose layers differ in ff serves batches

prepare_union refused a mixed-ff run because its slabs had one width. It now makes one slab set per width,
in the order of the step scratch, and a layer serves through union[scratch_of[layer]]. A one-width run
(qwen3moe placed) holds the one set it held before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mmon prompt pass, not as decode steps

Whole-card and placed share one layer body (PassWalk). The placed pass runs the card experts as batches
(BatchLeg, remap past 8 columns, ColPlaces up to 8, no card call for a layer with no card expert) and the
host experts as the host union over the batch. The serve seat wraps the call in prompt_pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…le-card batch; the b3d prediction card

The card arm is bit-identical to the whole-card batch; the mid and host arms hold the family's host-arm
band, and the greedy continuation is equal. The steps path is held at the last position by a floor and the
argmax band. Mutants: a width's host union dropped, and the remap rows reversed, each red.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es, its one owner; Placed drops two forwarding methods

The stores, the prompt pass and scratch_bytes() make up resident_bytes; the routes and the placed maps were
counted in both. The record lines of the whole-card load and every placed arm print the same bytes as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01K8ndZ5qubx9kYLVxTgbvEq
…e; watchdog_progress holds a prompt pass to one progress tick a token

With the walk faulting the gate passed (rc 0) before and fails host_tier_near_whole_card after. With
watchdog::pass_done removed, the new clause sees 1 tick against 17 and fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01K8ndZ5qubx9kYLVxTgbvEq
…rena, counted_arena_bytes)

qwen3moe::place carried `machine` (placed_on at the m = 1 scratch plus an
arena) and `counted_arena_bytes` (the scratch past the m = 1 scratch), and
qwen35moe's fixture spelled `SCRATCH + arena` out again. Both now have one owner
beside `placed_on`: `workstation::placed_with_arena` and
`workstation::counted_arena_bytes`. The qwen3moe copies are gone and their
callers (the gates' shared placement, the qwen35 open, the Qwen3 bodies'
refusal of an arena past the plan's count) call the owner. `placed_on` keeps its
scratch argument. A move: no kernel, launch or byte formula changes.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… directory

crates/model/src/arch/qwen35moe/fixture/qwen35moe.rs has no row, so a change to it keeps the full list (just affected --narrow: 'no row of tools/gate-paths.tsv maps it'). python3 tools/recipes.py reach names three gates that reach it through a dependency: gate-gpu-gemma-embedding2-e2e, gate-fixture and gate-fixture-budget. The row covers the directory and lists the three.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…_bytes; the model's copy goes

counted_ubatch_bytes in qwen35moe::place was the same subtraction (scratch past SCRATCH) as the workstation's
counted_arena_bytes. body38 reads the common one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01K8ndZ5qubx9kYLVxTgbvEq
@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja needs-gpu Changes code a card must check, and carries no gate run on a card placement Placement planning: crates/placement tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 20, 2026
@midagedev
midagedev enabled auto-merge (rebase) October 20, 2026 02:22

@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: placed fault recovery is incomplete; the band rule is duplicated and prompt buffers gain an unused absent state.

Must fix

1. Clear skipped expert rows when recovering from a fault

crates/gpu/src/arch/nemotron_h_moe/placed.rs:416 and crates/gpu/src/arch/nemotron_h_moe/prefill.rs:797 quantize every slot after the up launch skips host slots. With only expert 0 resident, an invalid token makes the NaN router select expert 0 for all nine slots, filling their up rows with NaNs. Reset clears stores but retains those rows. Valid routing then leaves at least eight slots on the host; quantization reads the skipped slots' stale NaNs and faults again. The GEMM arm at line 964 has the same problem.
Cost: a rejected request can require reloading the model.

In prefill.rs's impl Prompt, add:

pub(super) fn clear_expert_up(&mut self, stream: &CudaStream) -> Result<(), GpuError> {
    self.b.up.zero_async(stream)?;
    Ok(())
}

At the start of Body::reset, insert these lines, using item 3's direct field:

self.ms.up.zero_async(gpu.stream())?;
self.prompt.clear_expert_up(gpu.stream())?;

Add an invalid-token → reset → valid-call case to the placed gate for decode and both prompt arms.

2. Reuse the new band checker

crates/gpu-gates/src/bin/gate_nemotron_h_moe_e2e.rs:1328 repeats the cosine, maximum delta and margin rule owned by crates/gpu-gates/src/bin/gate_nemotron_h_moe_e2e.rs:1369 (R14).
Cost: remove the copy before later gate changes update only one rule.

Replace lines 1328–1331 with:

let (host_near, cos, dmax, _) = in_band((*want_ids, want), (*got_ids, logits));

Use host_near as the else expression of near. Replace that arm's println! with:

println!(
    "{CLAUSE}: arm {}: graph_nodes={nodes} resident_bytes={resident} (runtime value) \
     handoff_9={handoff}/{} card_acc_9={acc}/{} weighted_sum={wsum}/{moe_whole}; \
     eager == replay {} finite {} fault clean {clean}; last id {got_ids} vs \
     whole-card {want_ids}, cosine {cos:.6}, max|Δ| {dmax:.3e}; host band {host_near} {}",
    arm.name,
    hosted.len(),
    with_card,
    same(&eager, &replay),
    finite(&replay),
    verdict(arm_pass)
);

3. Keep the prompt buffers mandatory

crates/gpu/src/arch/nemotron_h_moe/body.rs:84 changes Prompt to Option<Prompt>, but both load arms construct Some and no code takes or clears it. The absent state adds an accessor, error branches and a zero-byte fallback without a caller.
Cost: remove these paths before more callers depend on them.

Apply these replacements and delete Body::prompt:

-    pub(super) prompt: Option<Prompt>,
+    pub(super) prompt: Prompt,
-                (Some(Prompt::new(stream, &sizes, rows)?), None)
+                (Prompt::new(stream, &sizes, rows)?, None)
-                (Some(prompt), Some(placed))
+                (prompt, Some(placed))
-        stores + self.prompt.as_ref().map_or(0, Prompt::bytes) + self.scratch_bytes()
+        stores + self.prompt.bytes() + self.scratch_bytes()

In enqueue_pass, replace the optional-buffer lookup with:

let p = &mut self.prompt;

Replace the three prompt()?.rows() expressions in prefill.rs with prompt.rows().

Non-blocking

⚠ Attach the dispatch proof: crates/gpu/src/arch/nemotron_h_moe/placed.rs:473 adds one sum launch per mixed card/host layer per token and changes float sum order. Under AGENTS.md's float-sum and dispatch rules, supply the error model and same-lease base/head A/B, plus FAIL-first output for the new gate clauses. The PR body supplies green summaries.

Checked

Duplicates: both band implementations read and confirmed. Dryer reported zero qualifying pairs; gpu and gpu-gates were excluded.
Complexity: diagnostics flag new placement orchestration and added placement/remap/storage branches.
Fault handling: traced invalid embedding, router selection, skipped expert writes, quantization and reset.
Tests: the added placed gate exercises valid decode and batch runs, without a fault → reset → valid-call case. GPU gates were not run during validation.
Gates: the duplicated band uses the same COSINE_FLOOR and margin rule.
Escape catalog: C1–C4 do not match these findings.

Notes

The supplied evidence has no card/driver line or gate command output; gpu.json records false.

Card check: needs-gpu. This pull request changes crates/gpu-deepseek41/src/body.rs, crates/gpu-gates/src/bin/gate_nemotron_h_moe_e2e.rs, crates/gpu-gates/src/bin/gate_qwen35moe_e2e.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

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

…e2e gate reads in_band; prompt is no Option

- Body::reset zeroes ms.up and the prompt's slot up rows on a placed load. The up launch skips the slots the host
  serves and the quantize after it reads every slot, so rows a faulted call left non-finite faulted the next valid
  call. A whole-card load writes every slot each call and is not cleared.
- gate_nemotron_h_moe_e2e: fault_recovery on the decode step, a gemv batch of 8 and a GEMM batch of 16 (invalid
  token, reset, then a valid call fault-free and bit-identical to before). The band reads go through in_band.
- Body.prompt is a Prompt again, and Body::prompt() is gone.

FAIL-first (fixture, arm mid): without both clears, "the walk after a fault raised the fault word: layer 1 site
quant_column"; without the prompt clear, "gemv batch of 8: raised true, then bit-identical false". Fixture batch
--round-ledger: DONE total=4 red=0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01K8ndZ5qubx9kYLVxTgbvEq

@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.

Since the last review:

  • Fault recovery: fixed. body.rs:539 clears both expert-up buffers before reuse.
  • Band duplication: fixed. gate_nemotron_h_moe_e2e.rs:1334 reuses in_band.
  • Optional prompt buffers: fixed. body.rs:84 holds Prompt directly.
  • Dispatch proof: the prior request concerns code unchanged in this increment and is outside this review's scope.

Verdict: CLEAN: the earlier must-fix items are resolved, and no new must-fix defect remains.

Non-blocking

⚠ Supply recovery FAIL-first evidence: crates/gpu-gates/src/bin/gate_nemotron_h_moe_e2e.rs:1537 adds fault → reset → valid-call checks for decode and both prompt arms. Attach failing gate output with each reset clear at body.rs:539–540 deleted separately. This verifies that the new clauses catch recurrence; the supplied green summaries do not demonstrate it.

Checked

Duplicates: the band comparison reuses in_band; dryer reports no qualifying pairs and excludes gpu and gpu-gates.
Complexity: Body::load changes buffer wiring; host_tier_near_whole_card adds recovery to its verdict. Other crapper targets are unchanged in this increment.
Silent failure: raised accepts only GpuError::Fault; missing before/after runs fail the recovery comparison.
Tests: recovery checks compare ids and logits before and after a fault and reset. GPU gates and FAIL-first were not run during validation.
Gates: no pins or thresholds moved; recovery failures feed the arm verdict.
Escape catalog: C1–C4 do not match the added code.

Notes

The supplied evidence lacks a card/driver line and gate command output. gpu.json records false.

Card check: needs-gpu. This pull request changes crates/gpu-deepseek41/src/body.rs, crates/gpu-gates/src/bin/gate_nemotron_h_moe_e2e.rs, crates/gpu-gates/src/bin/gate_qwen35moe_e2e.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

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

@midagedev

Copy link
Copy Markdown
Owner Author

Landed on main by fast-forward with the 0.3.6 release (a0288c5); tag v0.3.6.

@midagedev midagedev closed this Oct 20, 2026
auto-merge was automatically disabled October 20, 2026 14:39

Pull request was closed

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

Labels

gpu The card engine: crates/gpu*, crates/app model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja needs-gpu Changes code a card must check, and carries no gate run on a card placement Placement planning: crates/placement 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