Skip to content

placement, gpu-gates: a tier card on another host plans in its own node's pool - #503

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-glm-node-pool
Oct 19, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-glm-node-pool

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

두 개의 노드로 GLM을 올릴 때 각 노드가 자기 메모리만 보고 배치하도록 고쳐서, host로 밀려나던 expert를 6,767개에서 864개로 줄이는 결함 수정입니다.

What and why

On an expert-tier load across two DGX Sparks (--place 0+1 with BLOOMERY_TIER_NODES naming node 1), the planner charged node 1's card to node 0's unified pool. Place::machine built a one-node machine through workstation::plan_tiers, and the pool sums in placement (pool_bytes, the pool cards in totals, pool_need and the beside reserve) counted every tier card against node 0. plan_in_pool then lowered the common card budget to fit node 0 alone, so on GLM-5.3-Flash node 0 left 87.6 GB of experts to NVMe paging and ran about 6,800 experts on its CPU while node 1's card had room for them.

With this PR, a tier card on another host plans in its own node's pool. Node 0's pool holds the stage card and the host, and node 1's card is bounded by node 1's own census reading. On the same GLM load, node 0's host experts fall from 6,809 to 864 and nothing is paged. The 864 left are the experts the GLM placement keeps on the host for layers whose down stacks are Q6_K (see What I ran into).

What changed:

  • crates/placement/src/placement.rs: Machine::on_this_node says which cards take their bytes from node 0. pool_bytes, totals, pool_need and the beside reserve count only those cards. plan_rule takes one node, or one node plus one per tier card, and refuses any other count by name (PlacementError::Nodes { nodes, tiers }).
  • crates/placement/src/placement/workstation.rs: node_of is the node a card's spec plans on (its host and unified pool); plan_on and Qwen3.8's machine_for_experts build their node with it.
  • crates/placement/src/placement/nodes.rs: loaded_routed seeds an explicit node ownership on node 0 alone, so a machine with a node per tier card plans through plan_nodes too.
  • crates/gpu-gates/src/generate.rs: Place::on_nodes marks the placement when every tier node is off this host (off_host: not a loopback address, and a device that is not in this process's census). Place::machine_with takes a layout of the placement's cards and adds one node per tier card, tier t on node t + 1, when the placement is marked. Place::machine lays out the common plan through it. A loopback tier node still shares node 0's pool. Place::machine is common to every family, so the DeepSeek V4.1 and GLM loads with off-host tier nodes take the same path.
  • crates/gpu-gates/src/bin/shared/qwen38_place.rs: machine_bp38 lays out Qwen3.8's plan (b′) (machine_bp_on's cards and reserves) through Place::machine_with. The Qwen3.8 CLI, the serve seat, the unset-rule probe (tier_experts, which now takes the placement), the routed-leg gate and the node gate's placed plans all build it there.
  • crates/placement/src/placement/nodes_scale.rs: one assert follows the new error shape.
  • docs/contrib/dgx-spark.md: the two places that said the load charges remote cards to node 0's pool now describe the per-node pools.

Release notes: Fixed: on an expert-tier load across several hosts, each tier card plans in its own node's memory pool, so node 0 no longer pages experts to NVMe or runs them on its CPU for lack of room that node 1 has.

Code shape

The review reads these first. A box left unticked needs one line of why.

  • No second copy. One function decides which cards are in node 0's pool (Machine::on_this_node), and all four pool sums read it. One function adds the tier nodes (Place::machine_with), and both machines over a placement (Place::machine, machine_bp38) are laid out through it. workstation::node_of builds every card's node.
  • Model code holds only architecture facts. Qwen3.8's machine_for_experts only takes its node from node_of.
  • Dead code is gone. The comment about the single-pool bound in Place::machine is removed with the bound, and tier_experts no longer takes card specs its callers unpacked.
  • No silent failure. A machine whose node count fits neither one node nor one node per tier card is refused by name.
  • Comments state what is true now.
  • No relaxed gate. No gate or band moves.
  • cargo fmt and cargo clippy: fmt runs in t0 (What I ran); the results below include no separate clippy run on this head.

Duplication found or removed (path:line), or "none": none.

What I ran

Head e6f1da842e192b16891254476668f51cb16127da, one commit on main b36f8e916360005ce070b35e6e2308fef83fc18d. The two GPU runs below used d7b0620b, the same commit on the previous main 450db142: both have the same patch, and none of the main commits between them touch this PR's files.

Tests (FAIL-first: each new assertion fails with the fix undone and passes with it; on the head they pass in t0 and in the GPU run below):

  • placement::tests::a_tier_on_its_own_node_takes_nothing_of_this_nodes_pool: with main's node check it fails on plans: Nodes { nodes: 2, tiers: 1 }; with every card still summed into node 0's pool it fails on left: 0, right: 2304; with every card's census context in node 0's pool it fails on left: Some(1099511627777), right: Some(1099511627776); with the beside reserve charged for every card it fails on left: 2, right: 1.
  • placement::tests::a_node_host_projection_keeps_non_routed_rows_on_node_zero: with loaded_routed seeding both nodes it fails on a machine of 2 nodes for 0 tier cards.
  • generate::tests::loopback_census_is_required_without_adding_a_pool (bash tools/gate.sh --oxide -p bloomery-gpu-gates --features gpu --release --lib -- generate::tests) resolves a tier at a loopback and at another host's address without overriding the placement, then lays out the common plan and a family's own layout over it: with own_pools starting false it fails on left: [], right: [Node { .. }]; without the added nodes it fails on the node list; with node 0's host reserves dropped it fails on node 0. On an RTX 5090 machine (nvidia-smi: NVIDIA GeForce RTX 5090, 595.99.02, 12.0): test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 136 filtered out; finished in 0.01s
  • GPU build on a DGX Spark (nvidia-smi: NVIDIA GB10, 595.84, 12.1) in the CUDA 13.3.1 container, RUSTFLAGS='-C target-cpu=native' cargo check --workspace --all-targets --features bloomery-gpu-gates/clef,bloomery-gpu-gates/deepseek41,bloomery-gpu-gates/gemma-embedding2,bloomery-gpu-gates/gemma4a,bloomery-gpu-gates/glm5next,bloomery-gpu-gates/mimo2,bloomery-gpu-gates/vision,gpu: Finished `dev` profile [unoptimized + debuginfo] target(s) in 29.99s
  • LC_ALL=C just contrib-check --tier t0 on the head: DONE tier=t0 total=94 red=0 wall=479s

On two DGX Sparks, the GLM-5.3-Flash load with generate_glm5next --tokens-from <prose-en ids>:50000:4096 -n 24 --ctx 4224 --place 0+1 --prefill steps, one run of main and one of the head, each from a fresh load with a fresh tier_server of the same build on node 1. Both GLM tables in this section come from 47699763, this change on main 7de31349. At e6f1da84 the GLM load plans the same machine; the later edits touch the Qwen3.8 paths, the explicit node-ownership seed (which this load does not use) and tests. These runs are untimed (one observation each), so the timing rows are a single sample:

main 7de31349 head 47699763
host_experts, --plan run 6,762 (17,102,077,952 B) 864 (14,703,132,672 B)
host_experts, load run 6,809 (17,502,830,592 B) 864 (14,703,132,672 B)
card_budget (load) 47,031,905,992 105,741,707,552
paged (load) 87,590,174,720 0
load_s 192.3 474.6
prompt 4,096 as steps 1,113,683.5 ms (3.68 tok/s) 365,318.7 ms (11.21 tok/s)
decode 23 steps p50 / mean 228.97 / 273.72 ms 153.18 / 157.75 ms
24 greedy ids [16013, 11, 293, 8311, ...] equal, all 24

The 24 greedy ids of the head are main's, id for id: the experts that moved from node 0's CPU to the cards give the same tokens.

Served, one request per fresh server on the same two nodes: bloomery-serve --place 0+1 --prefill steps --ctx-size 4224 with BLOOMERY_DRAFT=off, a 4,096-id prompt at offset 50,000 of a code or English prose corpus, 128 tokens decoded, main and head alternating in one lease. Each arm ran once, so these numbers carry no noise floor. Load + prompt is load_s plus the server's prompt_ms, the time from start to the end of the first prompt.

arm prompt ms (tok/s) decode tok/s step p50 ms (client gaps) TTFT ms load_s load + prompt s host_experts card / tier experts cpu_s node 0 MemAvailable min, SwapFree min GB check
main-base-code-fn-4096 1,530,858 (2.676) 2.932 309.8 1,530,921 202 1,732.9 6767 2360 / 2944 16,105 75.2, 16.31 n=128 stop=limit
head-base-code-fn-4096 980,469 (4.178) 4.224 248.1 980,480 434 1,414.5 864 6246 / 5014 18,377 16.5, 16.32 n=128 stop=limit
main-base-prose-en-4096 1,224,311 (3.346) 3.292 251.3 1,224,344 199 1,423.3 6765 2361 / 2940 16,898 75.6, 16.32 n=128 stop=limit
head-base-prose-en-4096 979,185 (4.183) 4.276 247.0 979,195 469 1,448.2 864 6238 / 5022 18,070 16.4, 16.29 n=128 stop=limit

Head against main, from the table above:

code-fn 4,096 prose-en 4,096
decode tok/s +44.1 % +29.9 %
step p50 -19.9 % (309.8 to 248.1 ms) -1.7 % (251.3 to 247.0 ms)
prefill tok/s +56.1 % +25.0 %
load + prompt -18.4 % (1,732.9 to 1,414.5 s) +1.7 % (1,423.3 to 1,448.2 s)
load_s 202 to 434 s 199 to 469 s

The head's load is longer, and it makes more bytes resident: node 0 took 103.8 GB during the load against main's 45.2 GB, and node 1 took 76.2 GB against 45.0 GB. Main leaves those experts to NVMe paging and reads them during the prompt instead.

What I ran into

None of this blocks the PR. After the fix, node 0's CPU still computes 864 experts on this load. card_down_runs (crates/placement/src/kernels.rs:595) has no Q6_K arm, so glm5next/place.rs keeps every expert of a layer with a Q6_K down stack on the host. Moving them to the card needs a Q6_K down arm in the card leg, which this PR does not add.

Hardware (if the change is for a machine)

Two DGX Sparks (GB10, driver 595.84) joined by their direct link, BLOOMERY_TIER_LINK=rdma, with GLM-5.3-Flash UD-Q4_K_XL (unsloth GGUF). Node 1 runs tier_server --listen <node 1 address>:<port> -m <model>, and node 0 runs the stage with BLOOMERY_TIER_NODES=<node 1 address>:<port>. Main and the head were built the same way in the CUDA 13.3.1 container.

AI help

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

…de's pool

A two-node load put node 1's tier card in node 0's unified pool (Place::machine always built plan_tiers' one-node machine), so node 0's NVMe floor lowered the one card budget for both cards and left the experts neither card took on node 0's host. Place::on_nodes marks the placement when every tier node is off this host, and Place::machine_with then adds a node per tier card (workstation::node_of) to the machine a layout makes; Machine::on_this_node keeps a remote tier's bytes out of the pool sums. Place::machine and Qwen3.8's plan (b′) machine (machine_bp38 in the shared Qwen3.8 placement file, used by the CLI, the serve seat, the unset-rule probe, the routed-leg gate and the node gate's placed plans) both lay out through it. nodes::loaded_routed seeds an explicit node ownership on node 0 alone. Loopback nodes keep sharing the pool.
@juliankang4

juliankang4 commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

ARM CPU인 스파크에서는 실사용이 불가능한 작업을 계속하는 것 같아 계획 자체를 바꾸었습니다.
현재 문제를 설명해 드리자면 두 개의 노드 구조(PP=2 expert tier)는 차례로 넘기는 형식입니다.
앞 노드가 자기 층을 다 끝내야 뒤 노드가 시작할 수 있고, 카드에 다 못 올린 것은 host 메모리에 두고 CPU로 돌아갑니다.
그래서 노드를 아무리 다듬어도 매 토큰마다 노드 사이를 건너고 호스트 메모리를 오가는 시간이 그대로 남습니다.
이건 튜닝으로 풀 문제가 아니라 PP=2 커널 구조 자체의 한계라고 보고 있습니다.

그래서 앞으로 스파크 작업은 전부 TP 구조로 가려고 합니다. 물론 Bloomery의 철학을 존중하고 있기 때문에 많은 구조 변경은 없습니다. 최대한 짜놓으신 아키텍쳐 안에서 진행하겠습니다.
다만 이건 스파크에만 적용되는 것이고, 기존 다른 GPU들은 지금처럼 x86 구조에서 돌아가도록 그대로 두겠습니다.
TP는 각 층을 반으로 잘라 두 개의 노드가 동시에 계산하고 결과만 합치는 방식이라, 모든 weight가 두 카드 위에 올라가고 호스트 메모리를 오갈 일이 없습니다.
계산상으로는 GLM FP4-Local 기준 20 tok/s 중반에서 30 tok/s 초반이 나와야 하는데, 이건 아직 실측 전이라 결과 나오면 #494에 올리겠습니다.
아마 이 작업을 하면 RTX Spark 한 대에서도 무난히 엔진이 지원될 것으로 예상됩니다!

PP 쪽 구조적 한계는 더 다듬지 않고, 이 PR은 결함 수정으로만 봐 주시면 될 것 같습니다!

(AI 코딩 에이전트가 작성한 코멘트이며, 내용은 제가 확인했습니다.)

@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 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 labels Oct 19, 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: No reachable behavior defect or proven quality defect remains in the changed paths.

Checked

Duplicates: 8 new functions checked, including the new test; no duplicate owner found. Dryer reported 0 pairs. Its skipped gpu-gates additions were checked with Grep.
Complexity: plan_rule rises 35 → 37 through node-count validation and locality filtering; totals rises 21 → 22 through the locality condition. Both changes belong to existing memory accounting.
Silent failure: 0 new suppression/default sites. Census and layout errors propagate; invalid node counts return PlacementError::Nodes.
Tests: Static mutation review only. Removing locality filters at crates/placement/src/placement.rs:366 and lines 2571, 3826 and 4135 breaks the new pool assertions. Restoring the old node-count rejection at crates/placement/src/placement.rs:2450 breaks the remote-tier test; accepting two nodes without tiers breaks nodes_scale::named_refusals.
Tests: Dropping the node-0 projection at crates/placement/src/placement/nodes.rs:58 breaks the extended explicit-ownership test. Dropping remote-node construction at crates/gpu-gates/src/generate.rs:773 breaks the extended topology test. The adjusted zero-node fixture still checks error propagation at crates/placement/src/placement.rs:3704.
Gates: No pin moved and no gate clause was removed. The body supplies FAIL-first results for the new assertions.
Adversarial checks: Missing/mismatched nodes are refused. Remote cards retain their census free-memory caps and floor checks. Repeated device UUIDs are refused. Explicit ownership seeds only node 0.
Performance: Load-time planning only; no decode or prefill work was added.
Escape catalog: No C1–C4 pattern matched.

Notes

No build or gate was run during this review. GPU evidence is incomplete: the body includes unit-test output, builds and timings, but no just gate-* run with output. Supply the exact model filename and complete commands/output for the performance tables.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen38_nodes.rs, crates/gpu-gates/src/bin/generate_qwen3moe.rs, crates/gpu-gates/src/bin/shared/qwen38_place.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)

@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 3f6df1b into midagedev:main Oct 19, 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 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant