Skip to content

placement: workstation owns the placed machine's arena (placed_with_arena, counted_arena_bytes) - #386

Closed
midagedev wants to merge 3 commits into
mainfrom
bolt-b2-lift
Closed

midagedev wants to merge 3 commits into
mainfrom
bolt-b2-lift

Conversation

@midagedev

Copy link
Copy Markdown
Owner

What and why

A placed load's machine and the arena the body counts in its scratch were laid out by a qwen3moe-only wrapper (qwen3moe::place::machine, counted_arena_bytes). The qwen35moe fixture, the two gpu bodies' load checks and four gate files called it. Any family that places one card the same way would have copied it.

This moves both into their common owner, workstation: placed_with_arena(spec, layers, arena) is placed_on(spec, layers, SCRATCH + arena), and counted_arena_bytes(card) is the card's scratch past SCRATCH. The qwen3moe copy is gone and every caller reads the common one. No kernel, launch or byte formula moves.

Release notes: internal — one owner for the placed machine's arena.

Per-model copies

  • Removed: crates/model/src/arch/qwen3moe/place.rs machine and counted_arena_bytes (they were at lines 43 and 50 of the base file).
  • Added: none. The two functions are new in crates/placement/src/placement/workstation.rs, the common owner.

Move proof

  • just canon-check 402f9abc6 on the box: canon-check: 3 bins, 908 entries: 908 identical, 0 reordered-only, 0 differs, 0 only-on-one-side; rows equal (jit columns not compared: no-jit both). Bins scanned: gate_glm5next_e2e, gate_kquant, gate_swap.
  • just check rc 0 and just lint rc 0 on the box. Of its 62 warning: lines none points at a line this change touches (the one in qwen3moe_place.rs is main's dead-code dense_shortage_halves_the_default_context).

GPU Evidence

Box: RTX 3090 and RTX A6000, driver 615.71.09. Base 402f9abc6 (origin/main), head dc729e8e3. All jobs through the box queue, tools/gate-batch.sh --round-ledger.

Fixture tier, DONE total=7 red=0 tier=fixture wall=924s deferred=12 real_only=1 real_file=1:

  • gate-gpu-gates-lib s2386, A6000, rc 0: test result: ok. 122 passed; 0 failed; 3 ignored and ok. 5 passed.
  • gate-gpu-lib s2387, 3090, rc 0: ok. 273 passed; 0 failed; 0 ignored; 0 measured; 4 filtered out (and three more ok results).
  • gate-gpu-qwen35moe-e2e s2392, A6000, rc 0: gpu-gate.sh: gate_qwen35moe_e2e ran 17 s (exit 0).
  • gate-qwen35moe-meta s2396, A6000, rc 0: ok. 2 passed.
  • gate-qwen3moe-meta s2395, 3090, rc 0: ok. 5 passed and ok. 3 passed.

The two gates the fixture tier defers by name ran in the real tier on the real files, DONE total=2 red=0 tier=real wall=326s:

  • gate-placement s2402, 3090, rc 0: ok. 11 passed and ok. 138 passed.
  • gate-gpu-qwen3moe-e2e s2401, A6000, rc 0: gpu-gate.sh: gate_qwen3moe_e2e ran 118 s (exit 0).

Code shape

One owner for the placed machine's arena in workstation; the callers' docs name it. No comment carries a date or an issue number. No gate or lint was relaxed.

This PR was written by a bot (a Claude Sonnet 5.5 agent in the Claude Code harness) under the lead's direction.

🤖 Generated with Claude Code

…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]>
@midagedev midagedev added gpu The card engine: crates/gpu*, crates/app model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja placement Placement planning: crates/placement needs-gpu Changes code a card must check, and carries no gate run on a card gpu-gates The card engine's gates and their shared bins: crates/gpu-gates labels Oct 17, 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: MUST_FIX: The move leaves a duplicate scratch reader and an unnecessary builder layer.

Must fix

1. Use the common scratch reader on the Qwen3.8 path (kind B)

workstation.rs:285 and qwen35moe/place.rs:1173 both compute card.scratch_bytes.saturating_sub(SCRATCH) and document the same arena-byte contract. R14 requires one owner. The Qwen3.8 loader still uses the per-model copy.
Consolidating now removes one function while this rule's ownership is being changed.

Delete counted_ubatch_bytes, its documentation and attribute from qwen35moe/place.rs. Replace its sole call at body38.rs:1313 with:

        let counted = model::placement::workstation::counted_arena_bytes(spec);

2. Fold the sole-use builder into placed_with_arena (kind B)

workstation.rs:277 forwards to placed_on. Every other caller of placed_on has moved, leaving two public builders for one operation. The raw-scratch builder has no independent user. This violates the fewest-elements contract and R13's public-visibility rule.
Folding it now removes one function and an unused public entry point.

Delete placed_on and its documentation. Keep #[must_use] on placed_with_arena, describe its SCRATCH + arena contract directly, and use this definition:

pub fn placed_with_arena(spec: CardSpec, layers: usize, arena: u64) -> Machine {
    let mut machine = plan_on(spec, layers);
    let card = &mut machine.cards[0];
    card.token_embedding = true;
    card.scratch_bytes = SCRATCH + arena;
    machine
}

Checked

Duplicates: 2 relocated functions checked with Grep; the reader duplicate is above. Dryer reported 0 pairs.
Complexity: crapper flagged no functions; neither moved body adds branches.
Silent failure: 1 saturation site followed through both loaders and 3 gate consumers. Insufficient scratch reaches a named GpuError::shape; gates compare the counted bytes with the arena requirement.
Tests: by inspection, dropping + arena at workstation.rs:278 fails the card assertion at :1615; returning zero at :286 fails :1599. Gate lookup changes preserve their accounting comparisons. The context-halving helper retains its existing assertions.
Gates: no threshold, pin, case or test removed or relaxed.
Escapes: none of C1–C4 matched.
Performance: the changed executable paths run during planning and loading; no per-token work changes.

Notes

Review and mutation checks were static; builds and gates were not run here. The PR body reports gate results but lacks the required nvidia-smi output and exact just gate-* commands with output. GPU evidence is recorded as false.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen35moe_e2e.rs, crates/gpu-gates/src/bin/gate_qwen3moe_e2e.rs, crates/gpu-gates/src/bin/shared/qwen35_open.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

Narrow list and the gates this PR kept (asked for by the lead).

Narrow result. tools/affected-gates.sh 402f9abc6..dc729e8e3 --narrow with the three scan pairs gate_glm5next_e2e, gate_kquant, gate_swap (all identical, no kernel moved; canon-check 908/908) does not narrow: 162 of 179 gate-recipes selected in its header, and its recipes: line names 171. The move touches two common owners, placement/workstation.rs (rows 219 -> 135 recipes) and qwen3moe/place.rs (101 -> 157), and the gpu bodies (115 -> 39). The file crates/model/src/arch/qwen35moe/fixture/qwen35moe.rs has no gate-paths row, so the run also says narrow: full list for it. recipes.py reach shows two gates reach that file through a dependency (gate-gpu-gemma-embedding2-e2e, gate-fixture); a row for them takes that file from 154 to 2 recipes, but the union stays at 171 because of the other files. I did not add the row.

The gates that run the changed host path are the 20 recipes that read the four changed gate files as their own targets (recipes.py why: shared/qwen3moe_place.rs 19, shared/qwen35_open.rs 12, gate_qwen35moe_e2e.rs 2, gate_qwen3moe_e2e.rs 1; union 20). Their list is ~/orca/briefs/reports/b2-files/lift-gateside.list (the lead's machine).

Run so far (7 of the 171, all green): gate-placement, gate-qwen3moe-meta, gate-qwen35moe-meta, gate-gpu-lib, gate-gpu-gates-lib, gate-gpu-qwen3moe-e2e, gate-gpu-qwen35moe-e2e. Two of them are in the 20. I had picked these 7 by hand, so the 18 others of the 20 were not covered, gate-qwen3-plan and the serve, media and routed-legs gates among them. They are running now in the fixture tier (--round-ledger); results will follow here.

Not run: the other 146 of the 171 (list: ~/orca/briefs/reports/b2-files/lift-notrun.list, 164 names including the 18 now running). I name no dated reason for them; they are the lead's landing batch or a dated reason.

This comment was written by a bot (a Claude Sonnet 5.5 agent in the Claude Code harness) under the lead's direction.

… directory

crates/model/src/arch/qwen35moe/fixture/qwen35moe.rs had no row, so a change to it kept the full list (just affected --narrow: 'no row of tools/gate-paths.tsv maps it'). python3 tools/recipes.py reach names two gates that reach it through a dependency, gate-gpu-gemma-embedding2-e2e and gate-fixture; the other 147 of the 150 gates that link the model lib do not. The row covers the directory and lists the two.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-actions[bot]
github-actions Bot previously approved these changes Oct 17, 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.

Since the last review: the new commit adds one fixture-subtree gate-selection row at tools/gate-paths.tsv:154.

Verdict: CLEAN: No must-fix finding remains within the incremental diff.

Checked

Duplicates: 0 new functions, types or constants; dryer reported 0 pairs.
Complexity: crapper reported no qualifying changed functions.
Silent failure: no executable error-handling code changed.
Tests: no tests changed; mutation review does not apply to the added table row.
Gates: the row maps the fixture subtree to gate-fixture and gate-gpu-gemma-embedding2-e2e. No threshold, assertion or test case changed.
Escapes: none of C1–C4 match the added row.
Performance: tool metadata only; no hot path changed.

Notes

Validation was static; builds and gates were not run. The PR body lacks the required nvidia-smi output and exact just gate-* commands with output. GPU evidence remains false.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen35moe_e2e.rs, crates/gpu-gates/src/bin/gate_qwen3moe_e2e.rs, crates/gpu-gates/src/bin/shared/qwen35_open.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

midagedev commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner Author

The 18 call-site gates (the recipes that run the four changed gate files as their own targets, beyond the first 7), as PR evidence. Box: RTX 3090 and RTX A6000, driver 615.71.09, head dc729e8e3 (the gate-paths row below is a later commit and moves no gate), tools/gate-batch.sh --round-ledger. The other 146 of the 171 run in the 0.3.4 train, as the lead decided.

Fixture tier, DONE total=18 red=1 tier=fixture wall=1468s deferred=18; 9 ran:

  • gate-qwen3-plan s2440 rc 0 (210 s; it was red on main before fix(qwen): consume checked Card reserves after merged context policy #372 with E0308 in qwen3moe_place.rs).
  • gate-gpu-nemotron-h-moe-serve s2441 rc 0 (446 s, 3090). gate-gpu-qwen3moe-types s2445 rc 0 (A6000). gate-gpu-routed-legs s2446 rc 0 (3090). gate-gpu-qwen38-serve s2448 rc 0. gate-gpu-qwen38-twocard s2449 rc 0. gate-gpu-serve-start-glm s2451 rc 0. gate-gpu-serve-start-ds41 s2453 rc 0.
  • gate-gpu-nemotron-serve s2443 rc 66: the fixture tier has no Nano fixture; it ran in the real tier below.

The 10 the fixture tier deferred by name (real-only 4, real-file 5) or had no fixture for ran in the real tier on the real files, DONE total=10 red=1 tier=real wall=1304s:

  • rc 0: gate-gpu-clef-serve s2457 (3090), gate-gpu-qwen3-serve s2458 (A6000), gate-gpu-clef-hidden s2460 (A6000), gate-gpu-lev-serve s2462, gate-gpu-minicpm-text s2463, gate-gpu-nemotron-serve s2464, gate-gpu-qwen35-media s2465, gate-gpu-qwen35moe-media s2466 (all 3090), gate-gpu-glm5next-serve s2469 (572 s).
  • rc 1, not from this change: gate-gpu-gemma-embedding2-serve s2461: /models/embeddinggemma-2/embeddinggemma-2-Q8_0.gguf: No such file or directory. The box has no such file, so no tree can pass it (its sibling gate-gpu-gemma-embedding2-e2e failed on the same path on origin/main earlier; I did not run this serve gate there).

Also pushed: a tools/gate-paths.tsv row for crates/model/src/arch/qwen35moe/fixture/** (gate-gpu-gemma-embedding2-e2e gate-fixture, the two gates recipes.py reach names; check-recipes 134 rows, rc 0). just affected 402f9abc6..HEAD --narrow: before narrow: full list — crates/model/src/arch/qwen35moe/fixture/qwen35moe.rs: gate-gpu-p1 reads it through a dependency (...) and no row of tools/gate-paths.tsv maps it; after narrow: file crates/model/src/arch/qwen35moe/fixture/qwen35moe.rs: own target of 12; rows 154 -> 2 recipes. The union of the narrowed list stays at 171 because of the other changed files.

This comment was written by a bot (a Claude Sonnet 5.5 agent in the Claude Code harness) under the lead's direction.

@midagedev

Copy link
Copy Markdown
Owner Author

Merged origin/main into this branch (75dcbe2ee, plain push); parked for the 0.3.4 train as decided.

  • Conflict: tools/gate-paths.tsv only. Took main's file and put my crates/model/src/arch/qwen35moe/fixture/** row back; python3 tools/recipes.py check --fill added main's new gate-fixture-budget to it, so the row now lists gate-gpu-gemma-embedding2-e2e gate-fixture gate-fixture-budget (134 rows, rc 0). No leftover caller of the removed qwen3moe::place::machine or counted_arena_bytes.
  • Box just check: rc 0.
  • Box, fixture tier, --round-ledger, DONE total=2 red=0: gate-gpu-lib s2529 rc 0 (ok. 273 passed; 0 failed; 0 ignored; 0 measured; 4 filtered out and two more ok), gate-gpu-gates-lib s2530 rc 0 (ok. 124 passed; 0 failed; 3 ignored and ok. 5 passed). A first run of the pair was cut: offload's pkill killed the batch, and its rerun's gate-gpu-lib hit the gate bound (rc 124, 1835 s) while the box was loaded; the numbers above are the clean rerun.
  • Mac static tier at 75dcbe2ee: fmt-check, combos, check-arch, check-comments, check-defaults, check-levers, check-loads, check-ptx-names, check-records, check-rustflags, check-unsafe, check-waits rc 0. Red, not from a line this change touches: lint (68 warning: lines against the ratchet 41) and check-recipes (its script self-tests; the same on main).
  • gate-gpu-gemma-embedding2-serve (red in the real tier above) wanted /models/embeddinggemma-2/embeddinggemma-2-Q8_0.gguf, which the box does not hold.

This comment was written by a bot (a Claude Sonnet 5.5 agent in the Claude Code harness) under the lead's direction.

@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: no must-fix or non-blocking items were open. The fixture selection row now also selects gate-fixture-budget.

Verdict: CLEAN: The placement refactor preserves the scratch formulas, caller guards and machine layout.

Checked

Duplicates: 2 relocated functions checked against existing owners; no new duplication introduced. Dryer reported 0 pairs.
Complexity: crapper flagged no functions; the moved functions remain straight-line calculations.
Silent failure: 1 moved saturation site followed through both GPU loaders; an arena above the counted budget returns a named shape error.
Tests: static mutation review of workstation.rs:1599 and :1615 rejects dropping SCRATCH or arena at :278, and returning zero or raw scratch at :286. The unlisted runner-test change is caught by the existing contrib-check t0 self-test and is excluded under the review rules.
Gates: no threshold, tolerance or assertion was relaxed; the fixture row adds gate coverage.
Escapes: none of C1–C4 match the tree changes.
Adversarial checks: empty-card plans retain named errors; zero-arena planning and the shared type re-exports preserve base behavior. Changes affect load-time planning, not decode or prefill execution.

Notes

diff.patch contains 65 paths and overlaps files.txt only at tools/gate-paths.tsv. Review used direct tree comparisons. files.txt also omits the change to tools/ref/source-inspection-test.py.
Validation was static; builds and gates were not run. GPU evidence lacks nvidia-smi output, model paths and exact just gate-* commands. Its reported head hash differs from pr.json.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen35moe_e2e.rs, crates/gpu-gates/src/bin/gate_qwen3moe_e2e.rs, crates/gpu-gates/src/bin/shared/qwen35_open.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

Superseded by #508 (rebased onto main).

@midagedev midagedev closed this Oct 19, 2026
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 gpu-gates The card engine's gates and their shared bins: crates/gpu-gates 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant