Skip to content

placement, gpu-gates: --place gate picks its card by room, and the qwen4exp gates read their ids from the fixture mirrors - #148

Merged
juliankang4 merged 2 commits into
midagedev:mainfrom
juliankang4:dgx-spark-place-gate
Oct 14, 2026
Merged

juliankang4 merged 2 commits into
midagedev:mainfrom
juliankang4:dgx-spark-place-gate

Conversation

@juliankang4

@juliankang4 juliankang4 commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

Part of #13. Two things keep fixture-tier gates closed on any machine without the workstation's cards, a DGX Spark
included. Answer 18 in #13 (comment) leaves
--place gate open to a contributor. Whether the gate plan fits a card depends on the card's bytes, so this branch
picks the card by room and keeps the plan the gate plan.

  • --place gate was Pick::Name("3090"), so generate_qwen3moe --place gate stopped before the plan with
    --place gate: no visible device is 3090 on a GB10, and gate-gpu-qwen38-serve could not run. The alias is now
    Pick::Room(RTX_3090). It takes the visible card with the fewest usable bytes among those with at least the 3090's
    24,176 MiB and those the census labels as a 3090, the lower ordinal on a tie (as Rank breaks ties). It then plans
    the 3090's bytes on that card: the device, its name, free reading, holders and integrated flag come from the
    census, and the total and the driver reserve from RTX_3090. That is the shape gate_card::census already gives the
    gate bins (AGENTS.md "Cards"), so docs/BUILD.md's "fewer routed experts on the card" holds on any card. With no
    census, workstation_spec gives RTX_3090, so plan_gate and every census-free plan are unchanged.
  • gate-gpu-qwen4exp-e2e and gate-gpu-qwen4exp-mtp opened the real sets (ref_qwen4exp, ref_qwen4exp_d3k,
    ref-mtp/qwen4exp_prose64_n64_k1 and the others) in both tiers for the ids they feed. Only the fx_ sets are
    published, so in the fixture tier both stopped right after their structure clauses with cannot read .../MANIFEST.tsv. tier::input_set now picks the set a clause reads only as input, and returns its name, family
    and path: the real set in the real tier, and in the fixture tier its mirror, opened through tier::fixture_set
    (missing, stale or foreign ends the gate by name). The mirrors are dumped for the same ids: REF_TOKENS, and the
    prose corpus the profile pins by sha256. refset::arch::qwen4exp::fixture::mirror owns which set mirrors which. The
    e2e gate's lines name the set they opened, so a fixture run prints fx_ref_qwen4exp_d3k where it read that set. The
    real tier opens the same sets as before.
  • The MTP gate's replay took the draft layer from the constant IK_LAYER = 48, which a set of another layer failed
    against because its rows were not found. It now takes the layer from the header (draft_layer(), which the real
    tier already witnesses as 48), and MtpSet::check_draft_layer holds the set's mtp_eh_proj-N rows to it. A set
    dumped for another layer is refused by name in both tiers, and in the fixture-oracle replay too.

In the fixture tier both qwen4exp gates now need the current fx_ mirror sets on the machine. A missing or stale
mirror ends the gate by name, where before a machine with the real sets read those.

Behavior that changes for gate:

  • On the workstation (3090 and A6000, either enumeration order) it is still the 3090, with the 3090's own spec.
  • A 3090 whose driver keeps a little more than the measured reserve (a MiB short of 24,176 MiB usable) is still the
    3090, alone or beside an A6000.
  • Two 3090s now give cuda0. Before, they were refused (--place gate: 2 visible devices carry the name 3090).
  • One larger card (an A6000, an RTX PRO 6000, a GB10) now takes gate alone and plans the 3090's bytes on it. Before,
    gate was refused there. On a GB10 the card plans 24,176 MiB and the unified pool is the census's reading.
  • A card under the 3090's usable bytes that is not a 3090 is refused (PickWhy::Missing).

On a card larger than the 3090's bytes, the plan line's card_free is still the device's free reading, so it can be
above the 24,176 MiB the card plans. The expert rule fills within the smaller of the two (capped), and on a GB10 the
same reading is the unified pool, so no plan number moves. Two serve gates held card_free to the stage card's usable
bytes from the plan line: plan_names_the_cards_free_bytes in gate-gpu-qwen38-serve and in gate-glm5next-serve.
Before this branch those bytes were always the device's. They now take the device's free limit from the gate's own
census: its usable bytes held under its total (record::device_free_limit, which record::stage_device_free_limit
reads for the stage's device, beside plan_devices). Only the totals count there, and no load moves them. A plan
line that names the device's total in place of its free reading, the case the clause was added for, is still red on
every card. That includes a device whose total is a whole number of MiB: the census gives such a device usable bytes
equal to its total, so the limit is one byte under the total. A census device with a zero total is a named error. Both
clauses carry a PIN(2026-10-14): line with this reason. The old bound was wrong on a GB10: at an earlier head of this
branch (87dc9198 on ce422577), before the clause took the device's bytes, gate-gpu-qwen38-serve rejected the
device's own reading.

plan names the stage card's free bytes false: card_free=Some(124245848064), usable 25350373376
check plan_names_the_cards_free_bytes: FAIL

The memory guard's census clause in gate-gpu-qwen3moe-e2e (--memguard-only) had the same gap, on a path this
branch did not otherwise touch. It held the census's free reading to the usable bytes alone, so a census that read a
whole-MiB total as the free bytes passed that clause. It now reads the same record::device_free_limit, with its own
PIN(2026-10-14): line. The budget it sets above the free reading is still the usable bytes. This clause has no test
of its own: the record test covers the helper it reads, and --memguard-only was not run (see "What I ran").

On the workstation, the default card pick and gate-batch's lanes keep --place gate on the 3090. Every --place gate
call in the justfile goes through tools/gpu-gate.sh without the any card form, so it runs under the 3090's gate
lock, and a recipe that shows both cards (BLOOMERY_CARD=both) gets the 3090, the smaller of the two. A manual run
that shows only the A6000 (BLOOMERY_GATE_CARD=a6000 or BLOOMERY_CARD=a6000) now plans the 3090's bytes on the
A6000 under the name gate, where it was refused before. The timing runners still refuse a gate arm unless the
timing card is the 3090 (tools/ref/arm-place.sh), so an A6000 run cannot label gate plan rows as the 3090's.

The docs and the comments that said gate opens the card named 3090 now say what it plans. docs/BUILD.md "Picking
the card" and its --place a table row are rewritten for the current rule of all three aliases: they still said a
and bp pick cards by name, which has not been true since they became size ranks. The tools/gpu-gate.sh and
tools/gate-batch.sh comments that called the V4.1 gate loads 3090-only now name the lane that keeps them there.
tools/ref/arm-place.sh still refuses gate in local mode; its message now says why (the arm's rows are the 3090's),
and tools/ref/card-tests/run.sh matches the new message. docs/contrib/local-check.md drops the two items from its
list of known reds, and docs/contrib/dgx-spark.md drops them from P1's open work, drops its note that BUILD.md
still names the A6000 for a, and cites the merged commit (86022f32) in the Closed entry for gate-engram's
eviction clause.

Code shape

  • No second copy. One Pick arm decides gate for every binary that resolves --place through the census;
    both gates go through one tier::input_set, which also owns the set's path, and one fixture::mirror names the
    pairs. The mtp_eh_proj-N parse lives once, on MtpSet. One record::device_free_limit bounds a census
    device's free reading for both serve clauses and the memory guard.
  • Model code holds only architecture facts. fixture::mirror lists the qwen4exp sets the fixture already
    mirrors; no model branch was added to placement or to tier.
  • Dead code is gone. The MTP gate's IK_LAYER constant is removed.
  • No silent failure. A set with no mirror, a mirror that fixture_set refuses, and a set whose draft layer is
    not the header's end the gate by name. A census with no card large enough and no 3090 refuses gate as
    Missing. A census device with a zero total has no free limit and is a named error.
  • Comments state what is true now.
  • No relaxed gate. No band changed. Two clauses changed their bound, each with a dated PIN line and the
    reason. plan_names_the_cards_free_bytes holds card_free to the stage device's usable bytes, under its total,
    in place of the stage card's planned bytes. On every card that is not a gate stage on a larger card the two
    are the same number, or the new one is a byte lower when the total is a whole number of MiB. The line that names
    the device's total is still red (the new record test, a whole-MiB total included). The memory guard's census
    clause holds the free reading to the same limit: a byte lower than before on a whole-MiB total, the same number
    on every other card. In the fixture tier the gates now feed the mirrors' ids, and every oracle clause against
    the real sets is still deferred(real). The draft layer the MTP replay reads is now checked against the header
    rather than only found by name.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": the memory guard's own bound on the free reading,
d0.free_bytes <= usable at crates/gpu-gates/src/bin/gate_qwen3moe_e2e.rs:1130 on the base, a second copy of the
bound the serve clauses take. Both now read record::device_free_limit (crates/gpu-gates/src/record.rs:3802); the
guard keeps usable only as its budget above the free reading.

What I ran

Head ca734196 on base 0c92fb40. Every run below is at this head and base unless the line names another commit.

On a Mac (Apple M5, macOS 27.0.1), just mac-static upstream/main: fmt-check, lint, combos and all eleven
check-* scripts end rc 0, and lint prints ^warning: 41 = the ratchet 41. In that run tools/check-recipes.sh
started at most three of its blocks at a time. That was a one-line local change to its scheduling, undone after the
run; the checks themselves are the same. This Mac has four performance cores, and on it timing-bound self-tests have
missed their bounds with every block started at once. The run prints gate-batch self-test: 572 of 572 ok,
gpu-gate self-test: 99 of 99 ok and card-tests: 634 tests, 0 failed. just mac-test:

bloomery-placement: test result: ok. 147 passed; 0 failed; 0 ignored
bloomery-refset:    test result: FAILED. 169 passed; 1 failed; 1 ignored

The one red is arch::draft::tests::a_plain_target_with_no_draft_beside_is_the_family_path, listed in #137. It fails
the same way on the base: just mac-test at 0c92fb40 on the same Mac gives 167 passed; 1 failed; 1 ignored for
bloomery-refset, with the same test red. The other ten crates of mac-test end rc 0.

An earlier just mac-static upstream/main at 3d1ef2f5 (this branch before the zero-total and memory-guard changes,
which touch only crates/gpu-gates) ran on an Apple M4 Pro Mac mini, with every check-recipes block at once while
other builds loaded the machine. Its check-recipes step ended rc 1, and every other step ended rc 0. The red cases
all have wall-clock bounds:

  • depth-serve.sh --self-test: r1 nh D=6: llama-server did not answer /health within 3 s, so card-tests: 634 tests, 1 failed.
  • gate-batch.sh --self-test: parts 5, 7 and 15.
  • gpu-gate.sh --self-test: eight cases of part 2 (queue class, exit sign, hold over the queue, the batch hold), each
    gave no sign or rc 124, for 96 of 104 ok.
  • boxq.py --self-test: int-cancel, the daemon saw fewer than 2 of the requests it waited for.

A second run of check-recipes alone on that Mac failed only the depth-serve case, with gate-batch self-test: 572 of 572 ok and gpu-gate self-test: 99 of 99 ok. Run alone after that, depth-serve.sh --self-test gave 52 checks ok
and tools/ref/card-tests/run.sh gave 634 tests, 0 failed. Of the scripts that went red, this diff leaves
depth-serve.sh and boxq.py unchanged and changes only comments in gate-batch.sh and gpu-gate.sh;
card-tests/run.sh changes one expected message to match arm-place.sh.

FAIL-first, each a mutation of this branch at 87dc9198 on ce422577 (an earlier head whose placement and refset changes are this branch's) that
undoes one fix, under just mac-test. With Pick::Room's filter taking bytes only (no 3090 label) and
check_draft_layer taking any one layer:

assertion `left == right` failed: one 3090 a MiB short of its measured total: --place gate
  left: Err(Missing)
 right: Ok([("3090", 0)])
test result: FAILED. 145 passed; 1 failed; 0 ignored                  (placement)
test mtpref::tests::the_draft_layer_is_the_files ... FAILED
thread 'mtpref::tests::the_draft_layer_is_the_files' panicked at crates/refset/src/mtpref/tests.rs:387:14:
another draft layer: ()
test result: FAILED. 168 passed; 2 failed; 1 ignored                  (refset, with a red the base also has)

With Pick::Room's filter reading the free bytes in place of the usable bytes:

assertion `left == right` failed: 1 cards, cuda0 held: gate
  left: Err(PickError { pick: Room(CardSpec { name: "3090", ... }), why: Missing, visible: "cuda0 NVIDIA RTX PRO 6000 Blackwell Max-Q Workstation Edition 0000:41:00.0 97339 MiB usable, 8192 MiB free" })
 right: Ok([("RTX_PRO_6000_Blackwell_Max-Q_Workstation_Edition", 0)])
test placement::devices::tests::gate_plans_the_3090s_bytes_on_its_card ... FAILED
test result: FAILED. 144 passed; 2 failed; 0 ignored                  (placement)

The gpu-gates library tests are Linux only, so the new test in record.rs does not run on the Mac. Its FAIL-first
runs are on the DGX Spark below.

On a DGX Spark (GB10), in the dev container (bloomery-dev:cuda13.3.1), with BLOOMERY_BOX_LOCAL=1 and
BLOOMERY_BOX_ENV="BLOOMERY_TIER=fixture BLOOMERY_GATE_BOUND=1800", with clean trees. The fixture files and the fx_
sets are the published ones.

$ nvidia-smi --query-gpu=name,driver_version,compute_cap --format=csv,noheader
NVIDIA GB10, 595.84, 12.1
recipe 0c92fb40 ca734196 (this branch)
gate-gpu-qwen38-serve stops before the plan, exit 1: generate_qwen3moe: --place gate: no visible device is 3090 (visible: cuda0 NVIDIA GB10 ...) exit 0, all 76 checks print PASS
gate-gpu-qwen4exp-e2e stops after its two structure clauses, exit 1: cannot read .../ref_qwen4exp/MANIFEST.tsv exit 0: clauses: 26 ran, 8 left to the real tier
gate-gpu-qwen4exp-mtp stops before its first clause, exit 1: cannot read .../ref-mtp/qwen4exp_prose64_n64_k1/MANIFEST.tsv exit 0: clauses: 25 ran, 4 left to the real tier

The commands, run from the repository root, and the last lines of each run at ca734196. The gate-gpu-qwen38-serve
recipe runs gate_qwen38_serve twice, the plain arm (161 s) and then the drafted arm (29 s), so its last line below is
the drafted arm's; the card_free lines further down are the plain arm's.

$ export BLOOMERY_BOX_LOCAL=1 BLOOMERY_BOX_ENV="BLOOMERY_TIER=fixture BLOOMERY_GATE_BOUND=1800"
$ just gate-gpu-qwen38-serve
...
gate-gpu-qwen38-serve: PASS
gpu-gate.sh: gate_qwen38_serve ran 29 s (exit 0)
$ just gate-gpu-qwen4exp-e2e
...
clauses: 26 ran, 8 left to the real tier
gpu-gate.sh: gate_qwen4exp_e2e ran 356 s (exit 0)
$ just gate-gpu-qwen4exp-mtp
...
clauses: 25 ran, 4 left to the real tier
gpu-gate.sh: gate_qwen4exp_mtp ran 288 s (exit 0)

The first row is the bug this PR fixes. The other two stop on the base because they open the real sets, and this Spark
holds only the fx_ sets. The changed card_free clause passes at the head with the device's bound:

plan names the stage card's free bytes true: card_free=Some(125145370624), usable 130660958208
check plan_names_the_cards_free_bytes: PASS

Unit and library tests on the Spark, in release mode:

  • bloomery-placement has 147 passed, bloomery-refset has 170 passed; 1 ignored.

  • gate-ds41-place has 8 passed. On a tree that is 0c92fb40 with only this branch's two-3090 test in generate.rs
    it has 7 passed; 1 failed. The one red is that test, generate::tests::resolved_on_the_box_plans_as_before:
    --place gate: 2 visible devices carry the name 3090 (cuda0, cuda1). That is the old name rule refusing two 3090s,
    which the test expects to be accepted. The other seven tests pass on the old rule too.

  • gate-gpu-gates-lib at ca734196 has 105 passed; 0 failed; 3 ignored and 5 passed. FAIL-first, on three trees
    that are this head with one change each to record::device_free_limit (each log shows bloomery-gpu-gates compiled
    again), the new test is the only red, each time at the case that change breaks:

    # without .min(below_total): the usable bytes alone, the memory guard's old bound
    thread 'record::tests::card_free_is_held_to_the_stage_devices_usable_bytes' (1117) panicked at crates/gpu-gates/src/record.rs:5160:9:
    assertion `left == right` failed: a whole-MiB total 130595946496
      left: 130595946496
     right: 130595946495
    test result: FAILED. 104 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 0.01s
    # saturating_sub(1) in place of the zero-total error
    thread 'record::tests::card_free_is_held_to_the_stage_devices_usable_bytes' (291) panicked at crates/gpu-gates/src/record.rs:5158:14:
    called `Result::unwrap_err()` on an `Ok` value: 0
    test result: FAILED. 104 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 0.01s
    # the limit rounded down to a whole MiB, too low on a whole-MiB total
    thread 'record::tests::card_free_is_held_to_the_stage_devices_usable_bytes' (292) panicked at crates/gpu-gates/src/record.rs:5160:9:
    assertion `left == right` failed: a whole-MiB total 130595946496
      left: 130594897920
     right: 130595946495
    test result: FAILED. 104 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 0.01s
    

    At an earlier head (ea72a1e5 on a7ed8b58), with the helper reading the plan's stage bytes again, as the clause
    did before this branch, the same test was the only red (105 passed; 1 failed; 3 ignored there). Its message showed
    the GB10 line the clause must not accept: card_free=124798394368 ... devices=[stage:GB10:cuda0:25350373376], a free
    reading far above the 25,350,373,376 stage bytes.

  • tools/contrib-check.sh --tier t0 has 77 of its 78 items green. The red one is check-recipes: the gpu-gate.sh
    self-test case --v41-queue runs under BLOOMERY_BOX_READONLY=1 and syncs nothing. It fails the same way on the base:
    with BLOOMERY_BOX_LOCAL=1 set, gpu-gate.sh --self-test at 0c92fb40 gives 99 of 100 ok with that case red,
    and at this head with the variable unset it gives 100 of 100 ok. This diff changes only a
    comment in gpu-gate.sh. The cause is in tools, gpu-gates, gpu, engram, gguf, qdot, refset: problems found on the side of the DGX Spark work, by severity #137: the case's env -u list leaves BLOOMERY_BOX_LOCAL set, so
    box.sh leaves the box path the case stubs. On the Mac the variable is unset and the same case passes (see the
    static run above).

tools/recipes.py affected <main> --no-box selects most gate recipes: placement sits under bloomery-model, and
generate.rs and tier.rs under every gate binary. The change is host code, but I have no just narrow scan for it:
ptx-scan --no-jit needs cargo oxide and ptxas on Linux, and I did not run it for this head. So no narrowed list
is claimed, and the selected gates beyond the ones above, the Mac static tier aside, are not covered by a run of mine.
They stay for the maintainer's batch.

Not run here: the real tier of the three gates. It needs the workstation; there, gate still resolves to the 3090
with the 3090's spec, and both qwen4exp gates open the same real sets as before. gate-glm5next-serve is not run
either: its changed clause reads plan lines under a, bp and gate, and bp needs two cards. On the workstation
each of those stages is its device's own spec, so its bound is the same number as before. gate-gpu-qwen3moe-e2e --memguard-only is not run here either: it holds all but 512 MiB of the device's free bytes in one buffer, and on a
GB10 those bytes are the host's own memory. Its binary builds on the Spark at ca734196 (cargo oxide build ... --bin gate_qwen3moe_e2e), and the Mac's lint checks it at this head. Its census clause has no test of its own; the
record test above covers the helper it reads.

What I ran into

None of this blocks the PR.

  • gate-gpu-gates-lib does not build generate.rs's tests, which sit behind the deepseek41 feature. The two-3090 case
    there runs under gate-ds41-place.
  • gate-gpu-qwen4exp-e2e and -mtp both print named difference: the card's name "GB10", the old literal's "3090"
    before their clauses. It is informational and does not fail the gate; I left it alone.

Other problems I ran into on the way are in #137.

Hardware

DGX Spark (NVIDIA GB10, compute capability 12.1, 128 GB unified memory), aarch64, Linux 6.17, driver 595.84, CUDA
13.3.1 in the dev container, rustc 1.100.0-nightly (e457a7b0d 2026-08-27), cargo-oxide 0.2.1, LLVM 21.1.8, just 1.58.0.
The Mac checks ran on an Apple M5 MacBook, macOS 27.0.1, with the same nightly (the earlier run at 3d1ef2f5 on an
Apple M4 Pro Mac mini, macOS 27.0.1). I have no 3090 or A6000; the
workstation's two-card census and the two-3090 case are covered by the placement unit tests and gate-ds41-place.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

@github-actions github-actions Bot added dgx-spark The DGX Spark (aarch64, GB10) port documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset 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 13, 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 changed free-byte gate misses total-as-free records at a supported boundary, and both changed bounds lack required dated pins.

Must fix

1. Reject total-as-free records when the device total is MiB-aligned

Kind B (gate coverage): crates/gpu-gates/src/record.rs:3815 returns the total unchanged for an unknown card with a MiB-aligned total. The synthetic 4090 at crates/placement/src/placement/devices.rs:697 has this shape and is accepted by the new gate placement. A record mutated to card_free = total_bytes passes the serve clauses' f <= usable comparison; the old planned-byte bound rejected it under gate. The new record test covers only totals with nonzero tails.
Add this boundary now to preserve the gate's total-as-free check on other cards.

Document the helper's result as the inclusive free-byte limit, and replace its final statement with:

    let below_total = device
        .total_bytes
        .checked_sub(1)
        .ok_or("a plan's stage device has zero total bytes")?;
    Ok(spec_of_device(device).usable_bytes().min(below_total))

Append this case to the existing record test, after its loop:

        let aligned = [device(
            0,
            "NVIDIA GB10",
            gb10[0].total_bytes / workstation::MIB * workstation::MIB,
            true,
        )];
        let plan = Log::of(gb10_gate, BLOOMERY_SERVE_QWEN38)
            .one(&PLAN38)
            .unwrap();
        assert!(aligned[0].total_bytes > stage_device_usable(&plan, &aligned).unwrap());

Removing .min(below_total) must turn this assertion red.

2. Pin both changed serve-gate bounds

Kind B (unpinned gate change): crates/gpu-gates/src/bin/gate_qwen38_serve.rs:4836 and crates/gpu-gates/src/bin/gate_glm5next_serve.rs:1048 replace planned stage capacity with device capacity, increasing the accepted card_free range on larger cards. Neither change has the dated PIN(YYYY-MM-DD): comment required by AGENTS.md and CONTRIBUTING.md. The PR describes the larger-card mismatch that motivates the correction.
Record that reason beside each bound now so later changes can identify why it moved.

Insert immediately above both bound calls:

// PIN(2026-10-14): card_free is a device reading; gate-plan bytes can be smaller.

Checked

Duplicates: both serve clauses use the same new record helper.
Complexity: Room selection and the capacity override stay in resolve; no kernel body changed.
Silent failure: the helper returns a named error for invalid or absent stage ordinals.
Tests: the record test rejects total-as-free for its three fixtures; MiB-aligned totals escape it. The proposed boundary assertion fails without the stricter limit.
Gates: both bound changes lack dated pins. No numeric band or tolerance moved.
Escape catalog: C1–C4 do not apply to these findings. No ledger lessons are in force.

Notes

The reported card runs lack a nvidia-smi output line. The PR acknowledges missing ptx-scan and unrun selected gates.
Validation used source inspection and boundary arithmetic. No builds or GPU gates ran here.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_glm5next_serve.rs, crates/gpu-gates/src/bin/gate_qwen38_serve.rs, crates/gpu-gates/src/bin/gate_qwen4exp_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)

let plan = seat_log(&err_log)?.one(&record::PLAN38)?;
let free = plan.opt_u64("card_free")?;
let usable = stage_usable(&plan)?;
let usable = record::stage_device_usable(&plan, &census)?;

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.

CONTRIBUTING.md requires a dated PIN and reason when a gate threshold moves.

Suggested change
let usable = record::stage_device_usable(&plan, &census)?;
// PIN(2026-10-14): card_free is a device reading; gate-plan bytes can be smaller.
let usable = record::stage_device_usable(&plan, &census)?;

let plan = seat_log(lines).one(&record::PLAN)?;
let free = plan.opt_u64("card_free")?;
let usable = stage_usable(&plan)?;
let usable = record::stage_device_usable(&plan, &census)?;

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.

CONTRIBUTING.md requires a dated PIN and reason when a gate threshold moves.

Suggested change
let usable = record::stage_device_usable(&plan, &census)?;
// PIN(2026-10-14): card_free is a device reading; gate-plan bytes can be smaller.
let usable = record::stage_device_usable(&plan, &census)?;

…s on the smallest visible card with the room for them, not on the card named 3090

The gate alias was Pick::Name("3090"), so on any machine without a card of
that name --place gate stopped before the plan, and gate-gpu-qwen38-serve
could not run on a DGX Spark. Pick::Room(card) takes the device of the
fewest usable bytes among those with at least the card's and those the
census labels as that card, ties by the lower ordinal, as Rank does, and
plans the card's bytes on it: the device, its name, free reading, holders
and integrated flag are the census's, the total and the driver reserve
RTX_3090's, the shape gate_card's census gives the gate plan. A 3090 whose
driver keeps a MiB more than the measured one is still the 3090. On the
workstation the census lands on the same device as before in both
enumeration orders and its spec is the 3090's own, so the box's plans are
unchanged; with no census it is RTX_3090 (workstation_spec), so the
census-free plan is plan_gate. On a GB10 the card plans the 3090's usable
bytes and the unified pool is the census's reading.

On a card larger than the 3090's bytes the plan line's card_free is still
the device's free reading, which can pass the card's usable bytes; the
expert rule fills within the 3090's usable bytes all the same (capped),
and on a GB10 that reading is also the pool. The serve gates' clause that
holds card_free to the stage's usable bytes (gate-gpu-qwen38-serve,
gate-glm5next-serve) now takes the device's usable bytes from the gate's
own census, whose totals no load moves, and holds them under the device's
total (record::device_free_limit, which stage_device_free_limit reads beside
plan_devices): a device whose total is a whole number of MiB has usable
bytes equal to it. So a line that names the device's total in place of
its free reading is red on every card, and a zero total is a named error.
Both clauses carry a PIN line for the moved bound. The memory guard's
census clause in gate_qwen3moe_e2e held the free reading to the usable
bytes alone, which a reading of a whole-MiB total passes; it now reads
the same limit, with its own PIN line. The test holds the box's 3090 and
A6000 lines, a GB10's gate line, a whole-MiB total as a plan line's
device and a zero total to it; the memory guard's clause has no test of
its own beyond reading the same helper.

Two 3090s now give cuda0 instead of a refusal. A card under the 3090's
bytes that is not a 3090 is refused. The docs and the timing runners'
comments that said gate opens the card named 3090 now say what it plans,
the comments that called the V4.1 gate loads 3090-only name the lane that
keeps them there, and arm-place.sh's local-mode refusal names why it keeps
gate off. dgx-spark.md's Closed entry for gate-engram's eviction clause
cites the merged commit, 86022f3.
…s from the fixture's mirror sets in the fixture tier

Both gates opened the real sets in both tiers for the ids they feed: the
e2e gate its batch, step and prose sets, the MTP gate its draft set and
D3K's prompt. A contributor has only the published fx_ sets, so both
stopped right after their structure clauses. tier::input_set picks the
set a clause reads only as input, with its name, family and path: the
real set in the real tier, and in the fixture tier its mirror, opened
through fixture_set. The mirrors are dumped for the same ids (REF_TOKENS,
and the prose corpus the profile pins by sha256), and refset's
qwen4exp::fixture::mirror owns which set mirrors which. The e2e lines name
the set they opened. The real tier opens the same sets as before.

The MTP gate's replay reads the draft layer from the header in place of
the real file's 48, and MtpSet::check_draft_layer holds the set's
mtp_eh_proj rows to it, so in both tiers a set dumped for another layer
is refused by name.
@juliankang4

Copy link
Copy Markdown
Collaborator Author

Both findings hold, and both fixes are in the first commit. The branch is also rebased onto 0c92fb40, because upstream main changed crates/gpu-gates/src/record.rs, which this PR changes too. The rebase had no conflicts, and the upstream change there (the nvtier parts) does not touch the code below. main has moved on since, and git merge-tree shows no conflict with it, so the base stays 0c92fb40. The new head is ca734196: b194432a (the --place gate pick and the bound) and ca734196 (the qwen4exp mirror sets). git range-diff shows the second commit as equal to a7b97aa5. The PR body is updated to the new head.

1. Reject total-as-free records when the device total is MiB-aligned. Fixed. The case is real. A device that no measured card names gets census_usable(total) as its usable bytes, which is the total rounded down to a whole MiB. A whole-MiB total, such as the synthetic 4090's 24_564 * MIB in devices.rs, therefore has usable bytes equal to its total, and a line with card_free = total_bytes passed f <= usable.

The limit now has one owner, record::device_free_limit (crates/gpu-gates/src/record.rs:3802): the device's usable bytes held under its total, with total_bytes.checked_sub(1) and a named error for a zero total (census device cuda0 (...) reads a zero total), as suggested. record::stage_device_free_limit (record.rs:3819) finds the stage's device in the census and returns that limit. On a card whose total has a tail under one MiB (the 3090, the A6000 and the GB10 in the test), the limit is the same number as before.

The same gap was on one more path, which this PR did not touch before: the memory guard's census clause in gate_qwen3moe_e2e (--memguard-only) held the free reading to census_usable(total) alone, so a census that read a whole-MiB total as free passed that clause. It now reads device_free_limit too (gate_qwen3moe_e2e.rs:1128), with its own PIN(2026-10-14): line. That clause has no test of its own: the record test below covers the helper it reads, and --memguard-only was not run for this change (it holds all but 512 MiB of the device's free bytes, and on a GB10 those bytes are the host's memory). No other clause compares a free reading with usable bytes.

The record test gets two cases after its loop (record.rs:5153 on): the GB10's total rounded down to a whole MiB, as the stage device of the same GB10 gate line, which must give exactly the total minus one; and a zero total, which must be the named error. FAIL-first on a DGX Spark, just gate-gpu-gates-lib on the head with one change to device_free_limit each (every log shows bloomery-gpu-gates compiled again):

# without .min(below_total): the usable bytes alone, the memory guard's old bound
thread 'record::tests::card_free_is_held_to_the_stage_devices_usable_bytes' (1117) panicked at crates/gpu-gates/src/record.rs:5160:9:
assertion `left == right` failed: a whole-MiB total 130595946496
  left: 130595946496
 right: 130595946495
test result: FAILED. 104 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 0.01s
# saturating_sub(1) in place of the zero-total error
thread 'record::tests::card_free_is_held_to_the_stage_devices_usable_bytes' (291) panicked at crates/gpu-gates/src/record.rs:5158:14:
called `Result::unwrap_err()` on an `Ok` value: 0
test result: FAILED. 104 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 0.01s
# the limit rounded down to a whole MiB, too low on a whole-MiB total
thread 'record::tests::card_free_is_held_to_the_stage_devices_usable_bytes' (292) panicked at crates/gpu-gates/src/record.rs:5160:9:
assertion `left == right` failed: a whole-MiB total 130595946496
  left: 130594897920
 right: 130595946495
test result: FAILED. 104 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 0.01s

At the head the same recipe gives 105 passed; 0 failed; 3 ignored and 5 passed.

The commit message and the PR body said such a line is red "on every card". That was not true for a whole-MiB total before this fix, nor for a zero total. It is true now, and both texts say how.

2. Pin both changed serve-gate bounds. Fixed. Both clauses now begin their comment with PIN(2026-10-14): and the reason (gate_qwen38_serve.rs:4828, gate_glm5next_serve.rs:1038). The bound is the stage device's limit (its usable bytes under its total), because under --place gate on a larger device the card plans fewer bytes than the device has, and card_free is still the device's reading. I put the PIN line at the top of the comment each clause already had, so the reason and the FAIL-first note sit in one comment block, as the other PIN comments in crates/gpu-gates do. The suggestion put it as a separate line above the call.

The evidence that the old bound was wrong comes from a GB10 run. At an earlier head of this branch (87dc9198 on ce422577), before the clause took the device's bytes, gate-gpu-qwen38-serve printed:

plan names the stage card's free bytes false: card_free=Some(124245848064), usable 25350373376
check plan_names_the_cards_free_bytes: FAIL

That reading is the GB10's free memory, and 25,350,373,376 is the 3090's bytes that the stage plans. The PR body quotes these lines. At the new head the clause prints check plan_names_the_cards_free_bytes: PASS on a GB10.

Notes. "What I ran" now gives the nvidia-smi query and its output line for the DGX Spark runs: NVIDIA GB10, 595.84, 12.1. The Spark gate table and the Spark test runs are at ca734196 on 0c92fb40, with the commands and the last lines of each gate run, and the older runs the body quotes name their head and base. At the head, gate-gpu-qwen38-serve prints PASS for all 76 checks, and the two qwen4exp gates end with clauses: 26 ran, 8 left to the real tier and clauses: 25 ran, 4 left to the real tier.

@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: No must-fix behavior or quality defect survives the review.

Non-blocking

⚠ Cover mixed draft layers: crates/refset/src/mtpref/tests.rs:367 only supplies one layer at a time.
Changing found == [want] at crates/refset/src/mtpref.rs:323 to found.contains(&want) passes every assertion while accepting layers 48 and 47 together.
Add that mixed case to the existing test and assert Malformed. This closes the shared reader's rejection contract before another gate uses it.

Checked

Duplicates: 16 new functions, types and constants searched; none duplicated. Dryer reported zero pairs in placement/refset and skipped gpu-gates; its changed helpers were searched manually.
Complexity: resolve 11→16 adds the Room arm and spec override. MTP run 90→92 and GLM unset_rule 64→65, Qwen38 plain 29→30, Qwen3 memguard 18→19 add validation. Crapper also reports GLM ctx 85→86; that body is unchanged. No correctness defect found.
Silent failure: three sites followed. Invalid stage ordinals and absent mirrors return named errors; missing/wrong MTP layers fail the check or required-row lookup.
Tests (static mutations): crates/placement/src/placement/devices.rs:427 protects selection: dropping the label exception (430), reversing ties (432), dropping the byte override (458), and dropping the reserve tail (124) turn the host-table, equal-card, spec and reserve assertions red; reverting Room to Name turns generate's two-3090 assertion red. A wrong D3K mapping at crates/refset/src/arch/qwen4exp/fixture.rs:64 fails the mirror assertion. Dropping the total cap at crates/gpu-gates/src/record.rs:3809 or saturating zero at line 3803 fails the free-limit test. Restoring the old refusal text at tools/ref/arm-place.sh:95 fails the shell expectation. The mixed-layer mutant survives, as noted above.
Gates: three changed bounds have PIN(2026-10-14), reasons and FAIL-first evidence. Real oracle clauses remain tier-gated.
Escape catalog: C1–C4 do not match added executable code.
Adversarial checks: empty/undersized censuses, equal cards, held-card readings, integrated memory, stale fixture sets and wrong draft layers have guards. Whole-MiB and zero totals are covered. Changes affect planning and gate code; no per-token work was added.

Notes

No build or GPU run was performed in this review. The author supplies GB10 gate output. Real-tier runs, GLM serve, memguard and ptx-scan are not supplied; the PR states the reasons.

Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/gate_glm5next_serve.rs, crates/gpu-gates/src/bin/gate_qwen38_serve.rs, crates/gpu-gates/src/bin/gate_qwen3moe_e2e.rs … and carries a gate run on the author's card, which counts as verified.

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

@github-actions github-actions Bot added gpu-evidence Verified on the author's card: the pull request carries the gate run and its output and removed needs-gpu Changes code a card must check, and carries no gate run on a card labels Oct 14, 2026
@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit 1678b4f into midagedev:main Oct 14, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dgx-spark The DGX Spark (aarch64, GB10) port documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app gpu-evidence Verified on the author's card: the pull request carries the gate run and its output host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset 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