Skip to content

placement: build one card machine per expert-tier node - #321

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-p5-engine
Oct 16, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-p5-engine

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

Refs #127.

What and why

This is the placement half of the engine step in docs/contrib/dgx-spark.md 9.2 and answer 20 in its section 11, the next row of the plan in #127. workstation::plan_node_tiers (crate-internal and test-only until the engine load calls it) builds one independent card machine per node from the stage spec and the remote census specs, node 0 first. Until now a plan could describe a tier only as a card inside node 0's machine. A plan with several nodes had no entry point that gave each node its own card, its own pool and its own share of the batch reserves.

Release notes: internal: placement gains the per-node card machine planner that the multi-node engine load will plan through; until the load calls it, it is crate-internal and test-only.

What changes:

  • Node 0's machine plans the full model. Each remote plans routed_only with zero KV, as a card with the whole layer range and the one head stage that Stages::new requires of every independent machine. A remote's routed-only model has no head tensors, so nothing is placed there.
  • Each spec keeps its own free reading as its own unified pool. Device names and ordinals are local to a node, so they may repeat across nodes, and the new function does not compare devices between nodes.
  • The batch's returned rows are reserved on node 0's host once per remote. The batch staging and scratch are reserved on each remote card. plan_node_tiers takes no draft. A host-row sum past u64 is refused as plan_tiers refuses it, through one shared tier_service.
  • tier_card replaces the private tier as the one owner of a tier card with its service reserves. plan_tiers and the Qwen machine_bp_on both build their tier card through it, so the card literal that machine_bp_on carried is gone.
  • The standard nodes_scale cases and spark_nodes use plan_node_tiers. Cases that need a heterogeneous small pool keep their own inputs.
  • The contract that each node keeps its own census and its own service reserves is the unit test plan_node_tiers_keeps_each_census_and_service_on_its_node. gate_qwen38_nodes is unchanged.
  • docs/contrib/dgx-spark.md describes the entry point in 9.2, and section 10 lists the engine load's use of it as work left.

What this PR does not do

  • The engine load still plans through the single-node plan_tiers path. Nothing about a load, a kernel, a request or a token changes, so no timing is claimed.
  • The next PRs connect what the machines feed: the load's plan from the census with a budget per node, the router counts that assign routed sets, and the decode predictor with the selected node count. Node 1's host room joins the census with the plan term that reads it.

Code shape

  • No second copy. tier_card is the one builder of a tier card with its batch and draft reserves. plan_tiers and the Qwen machine constructor call it, and the draft and host-row checks of check_tiers and the host-row check of plan_node_tiers are one function, tier_service.
  • Model code holds only architecture facts. Qwen's machine_bp_on loses a card literal and keeps its stage scratch and MTP reserve. The common placement code gains no per-model branch.
  • Dead code is gone. The private tier and the TIER_BATCH_RESERVE import in the Qwen placement file are removed.
  • No silent failure. A host-row sum past u64 is a named error, and a draft past the tier list stays a named error in plan_tiers. The independent machine's head stage is checked by the existing Stages::new, which still refuses a machine with none or several.
  • Comments state what is true now.
  • No relaxed gate. No band, tolerance or lint moved, and tools/unsafe-ratchet.txt is unchanged.
  • cargo fmt and cargo clippy are clean on what I touched: cargo fmt --all -- --check returns 0, and the lint recipe's clippy returns 0 inside just mac-static.

Duplication found or removed (path:line), or "none": the tier card literal in machine_bp_on (crates/model/src/arch/qwen35moe/place.rs) and the private tier in workstation.rs are now tier_card (crates/placement/src/placement/workstation.rs:183). The draft and host-row validation in check_tiers is now tier_service, and plan_node_tiers uses it for the host rows. The tests' own reference cards (base_bp, qwen38_cards) keep explicit expected reserves, since they are the oracles the production builder is compared with.

What I ran

The head is 6135c48f, run on one DGX Spark unless a row says otherwise. Base logs that name another commit say which. The branch merges into upstream/main (d66ef090) without conflicts, as git merge-tree --write-tree shows.

Check Result
cargo fmt --all -- --check rc 0
cargo clippy --target x86_64-unknown-linux-gnu --workspace --all-targets --features gpu,... (the lint recipe's command, run by just mac-static on a Mac) rc 0; ^warning: 41 = the ratchet 41, so no new warning
cargo test -p bloomery-placement -p bloomery-levers, then cargo test -p bloomery-model arch::qwen35moe::place test result: ok. 40 passed; 0 failed for levers, test result: ok. 133 passed; 0 failed for placement, and test result: ok. 22 passed; 0 failed for the Qwen placement tests
just gate-placement rc 101, 6 passed; 5 failed. The base 278b7f79 ends the same way, with the same five hw_placement_* tests failing on the missing DeepSeek-V4.1 first shard, so this gate is not shown to pass
BLOOMERY_BOX_LOCAL=1 BLOOMERY_TIER=fixture just gate-gpu-qwen38-nodes PASSED: gate_qwen38_nodes, 8 clauses ran, 0 left to the real tier
Every gate just affected selects against 278b7f79, with the base run beside it gates-affected: 162 gates, ok 24, same as base 137, differs 1, unproven 0. See the notes below the table
just canon-check 278b7f79 (BLOOMERY_ARCH=sm_86) on b3a7baf9, which has the same place.rs as the head canon-check: 3 bins, 826 entries: 826 identical, 0 reordered-only, 0 differs, 0 only-on-one-side, so no PTX moved
FAIL-first: five production-path mutations, each run against the test that guards it (list below) Each of the 5 mutations fails with rc 101 on an assertion, and the restored tree returns rc 0
LC_ALL=C just contrib-check --tier t0 DONE tier=t0 total=84 red=1 wall=294s red: check-recipes. The base shows the same single red step: its --v41-queue self-test finds no tools/arch.sh in its temporary box tree
./tools/mac-static.sh on a Mac, compared with a base log One red step, check-recipes, because the ptx-compare self-test fails (33 cases, 1 failed). The base log is for fc47ee62, not for 278b7f79; it reads FAIL cold run and the same ptx-compare: self-test FAIL (33 cases, 1 failed)

The affected-gates line has three notes.

  • ok 24 is the count of gates that passed. same as base 137 counts gates where the head and the base ended alike, which is not a pass: 16 of them were refused with rc 64 on both sides because their models are not on the contributor machine, and I did not run them. They are gate-gpu-ds41-twocard, gate-gpu-ds41-callstream, gate-gpu-qwen38-twocard, gate-gpu-glm5next-twocard, gate-gpu-glm5next-serve, gate-gpu-serve-start-glm, gate-gpu-serve-start-ds41, six gate-gpu-glm5next-* variants, and two gate-gpu-qwen35moe-e2e variants.
  • gate-gpu-qwen38-nodes is the one that differs, and it is the gate this PR reaches. Its 5 unit tests pass on the head and on the base. Both then stop at the Qwen3.8 model shard, which is not on the machine, with rc 1. So the real-model part of this gate is not run. In the full run the base side also failed one process-cleanup unit test, and that test passed when I reran the gate on both sides.
  • The fixture-mode gate-gpu-qwen38-nodes run in the table is a single-card loopback run. It is not a real-model run and not a two-machine run.

FAIL-first mutations, each applied to the head's production code:

Mutation Guarding test
tiered no longer reserves the batch rows on node 0's host (the host_rows != 0 condition is removed) plan_node_tiers_keeps_each_census_and_service_on_its_node
A remote is planned from the stage spec instead of its own spec plan_node_tiers_keeps_each_census_and_service_on_its_node
A remote's tier card reserves are replaced with empty ones plan_node_tiers_keeps_each_census_and_service_on_its_node
plan_tiers builds its local tier card from an empty default card plan_tiers_is_plan_bp_a_and_gate
Qwen's tier card call is replaced with a default plan_on card arch::qwen35moe::place::tests::bp::the_machine_of_plan_bp

What I ran into

None of this blocks the PR.

contrib-check --tier t0 and just gate-placement end the same way on the base, and the branch adds no red step to either. just mac-static has one red step, and the base log I compared it with comes from fc47ee62, so that comparison is weaker than the others.

plan_node_tiers does not compare devices between nodes. Names and ordinals are local to a node, so two specs with the same card name, ordinal and UUID are accepted. On a loopback setup with one Spark, both machines would then sit on the same GB10 pool, and each would budget against it as if it were alone. Checking device identity across nodes belongs with the load that reads the census.

canon-check shows that no PTX moved. That the Qwen card is the same as before is shown by the model-card test arch::qwen35moe::place::tests::bp::the_machine_of_plan_bp, which is also one of the FAIL-first targets above.

Hardware (if the change is for a machine)

The unit tests, gates, the t0 check and the FAIL-first runs ran on one DGX Spark (NVIDIA GB10, 595.84, 12.1 in nvidia-smi). just mac-static and clippy ran on a Mac. These are pass and fail results, not timings.

AI help

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

Keep each census spec and unified pool on its own machine. Node 0 holds the returned batch rows; each remote holds its batch staging and scratch.

The local and remote plans and Qwen tier use one tier-card builder. The load keeps the existing single-node path.

2026-10-16: keep the separate-machine census contract in plan_node_tiers_keeps_each_census_and_service_on_its_node, not in the loopback census gate, whose two nodes share the same device. Node plans accept no draft until a load needs one.
@github-actions github-actions Bot added dgx-spark The DGX Spark (aarch64, GB10) port documentation Improvements or additions to documentation model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja placement Placement planning: crates/placement labels Oct 16, 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 shared builder preserves existing card plans, and the node planner keeps each census and service reserve on its own node.

Checked

Duplicates: 5 new functions checked by Grep; no duplicate owner found. The remaining card copies are independent test oracles. Dryer reported 0 pairs.

Complexity: crapper flagged no changed functions; no complex growth found.

Silent failure: 1 conversion chain followed. Failed conversion or host-row multiplication becomes TierBatchHost and propagates through both planners.

Tests: Static mutation checks at workstation.rs:503: reusing the stage census or dropping card/host reserves fails the new census test. At workstation.rs:554, wrapping multiplication fails the new overflow assertion. Existing full-machine and Qwen assertions catch missing tier reserves.

Boundaries: no remotes preserves plan_on; independent machines accept repeated device identities; invalid draft indices retain DraftOffPlan. Missing integrated-memory census readings retain a named panic.

Gates: no threshold, tolerance, lint level or gate clause moved. Fixture inputs now use the node planner.

Escape catalog: C1–C4 do not match this diff.

Notes

Tests were not executed in this review. The PR reports passing unit and fixture runs; real-model placement and node gates remain incomplete. The fixture GPU evidence omits the model-file path required by CONTRIBUTING.md.

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

Filed outside this PR: #322

@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 d0e8a8e into midagedev:main Oct 16, 2026
6 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 model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja placement Placement planning: crates/placement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant