Skip to content

placement: plan each census card at its own figures and allocation granule - #1031

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-device-plan-facts
Oct 30, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-device-plan-facts

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

census가 읽은 카드의 allocation granule을 계획까지 전달하고 두 워크스테이션 카드용 driver 이름 표를 지워, 어떤 CUDA 카드든 자기 숫자로 계획하게 하는 PR입니다.

What and why

Placement planned a census card through KNOWN, a table of two driver names (the A6000 and the 3090), and priced every card's allocations at one fixed granule constant. A card with another name or another allocation granule was planned at the workstation's figures, and the Qwen3 serve cache bytes did the same.

This PR makes the census the source:

  • crates/device/src/lib.rs: DeviceInfo.granule_bytes: Option<NonZeroU64>, None for a backend that cannot read it (Metal, mock).
  • crates/gpu/src/lib.rs, crates/gpu/src/host/node.rs, node/wire.rs: the census reads the granule with cuMemGetAllocationGranularity, a granule of no byte is a named error, and the tier node census carries it (node protocol version 6 to 7).
  • crates/placement/src/placement/devices.rs, workstation.rs: KNOWN is deleted, CardSpec.granule_bytes is new, and fn card() plans at the spec's granule. The workstation constants (A6000, RTX_3090, CARDS, machine_bp, and the census-less alias) are documented as the named reproduction of the maintainer's workstation.
  • crates/placement/src/placement/pool.rs: plan_in_pool lowers a round by card.granule_bytes.max(workstation::GRANULE), so a card with a smaller granule still searches the full POOL_ROUNDS range.
  • crates/gpu-gates/src/bin/shared/qwen3moe_place.rs, gate_qwen3_serve.rs, crates/placement/src/placement/qwen38_cards.rs: Qwen3 serve cache bytes, the gate's five cache expectations and the Qwen3.8 stage and tier cards use the planned card's granule.
  • The other files add one field to a DeviceInfo or CardSpec literal.

Release notes: Changed: placement plans each census card at its own allocation granule instead of a fixed constant and a two-card driver-name table.

Code shape

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

  • No second copy. The granule has one reader, the census; planning, Qwen3 serve and the gate read it from there.
  • Model code holds only architecture facts. The one model-side edit is the doc of machine_bp in crates/model/src/arch/qwen35moe/place.rs; no common owner gained a per-model branch.
  • Dead code is gone. KNOWN and the GRANULE imports it left unused are removed.
  • No silent failure. A card whose granule reads as no byte stops the census with a named error.
  • Comments state what is true now.
  • No relaxed gate. No band, tolerance or lint moved; the gate's cache clause now uses a context length whose planes are never a granule multiple, so a raw plane sum cannot match it.
  • 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": none.

What I ran

Base d72572f1a5b687ca12b1cf01fdf2fb9d0fd44341, head d459b0a7a773330d0639b83acb9a0bb875fedc67.

Census gate on a GB10 (bloomery-serve model nvidia/Qwen3.8-Flash-Next-FP4-Local) and on an RTX 5090, then the node census tests on the GB10:

./tools/box.sh 'cargo oxide build --arch sm_121a -- -p bloomery-gpu-gates --features gpu --release --bin gate_gpu_device && BLOOMERY_GATE_CARD=${BLOOMERY_GATE_CARD:-any} bash tools/gpu-gate.sh gate_gpu_device'
gate_gpu_device: device=NVIDIA GB10 ordinal=0 backend=cuda fault_none=0xffffffff
gate_gpu_device: PASS
test result: ok. 8 passed; 0 failed; 1 ignored; 0 measured; 459 filtered out; finished in 0.18s

On the RTX 5090 the same gate prints gate_gpu_device: device=NVIDIA GeForce RTX 5090 ordinal=0 backend=cuda fault_none=0xffffffff and gate_gpu_device: PASS. The library gate on the RTX 5090 (just gate-gpu-lib):

test result: ok. 457 passed; 0 failed; 0 ignored; 0 measured; 10 filtered out; finished in 30.59s
test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 457 filtered out; finished in 3.33s

The real server plans from the census, loads and answers one request (bloomery-serve --plan, then bloomery-serve --host 127.0.0.1 --port 18741 --ctx-size 8192 and one /v1/completions request, "The capital of France is", 16 tokens, temperature 0).

On the GB10:

plan place=a card=GB10 experts=card ctx_max=262144 host_experts=0 card_experts=24576 devices=[stage:GB10:cuda0:130595946496]
HTTP 200
server alive

On the RTX 5090 with Qwen3.6-35B-A3B-Q4_K_M.gguf:

whole fit at ctx 262144: the whole load on GeForce_RTX_5090: fits: need 29084308836 B
HTTP 200
server alive

The Qwen3 serve gate compares the server's cache bytes with the planes rounded to the card's granule. Its whole_fit_counts_the_planes_granules clause, first with kv_bytes summing the raw planes, then with the granule:

./tools/box.sh "bash tools/gpu-gate.sh gate_qwen3_serve --model Qwen3-30B-A3B-Instruct-2507-Q4_K_M.gguf --dir $D"
granule arm: the verdict's cache 503414784 B of 503414784 B of planes, the allocator's bytes 603979776 B
check whole_fit_counts_the_planes_granules: FAIL
gpu-gate.sh: gate_qwen3_serve ran 143 s (exit 1)
granule arm: the verdict's cache 603979776 B of 503414784 B of planes, the allocator's bytes 603979776 B
check whole_fit_counts_the_planes_granules: PASS
serve granule: 2097152 B, the unplaced card's
gpu-gate.sh: gate_qwen3_serve ran 126 s (exit 0)

Hardware (if the change is for a machine)

NVIDIA GB10, driver 595.84, CUDA 13.3, one DGX Spark, Linux aarch64.

NVIDIA GeForce RTX 5090, driver 595.99.02, CUDA 13.3, Linux x86_64.

AI help

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

…anule

The census reads each device's allocation granule
(cuMemGetAllocationGranularity) beside its memory, a tier node's census
carries it (protocol version 7), and a card spec plans with it: the stage
and tier cards' allocator, the pool budget's lowering step and the Qwen3
serve's cache bytes. Every census device now plans its own figures; the
driver-name table that gave the A6000 and the 3090 their nvidia-smi
totals is gone, as their usable bytes are the census rule's already.
The workstation's cards, plan (b') by name and the census-free aliases
are named reproductions of that workstation; the context, scratch and
margin terms are the program's figures and say so.
@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 labels Oct 30, 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 merge-blocking defect found in the changed paths.

Checked

Duplicates: 3 added or renamed functions and 1 static checked against existing owners; none duplicated. Dryer reported 0 pairs. GPU and gate code were also searched by hand.

Complexity: ctx_default rose 56→57 and NodeCensus::read rose 29→30. Both add a fallible granule read; neither adds a new placement policy. No split requested.

Silent failure: 4 sites followed through census conversion, wire encoding, wire decoding and the planner fallback. A zero CUDA reading returns a named error. Wire zero represents the supported absence of a backend reading; only that absence selects the documented fallback.

Tests, static mutation analysis: hardcoding the granule in spec_of_device:159 or card:216 contradicts the new 64 KiB assertions, including the gate placement and unplaced-card checks.

Tests, static mutation analysis: returning a raw plane sum at kv_bytes:760 makes the fine/coarse assertion fail. The PR also supplies FAIL-first output for the server cache clause at the changed context.

Tests, static mutation analysis: replacing pool:58 with either granule alone breaks the coarse-card or fine-card call-count assertion. Dropping the field at NodeCensus::read:224 breaks census round-trip equality.

Gates: no tolerance or acceptance band relaxed. The cache clause's context changes to keep raw sums distinguishable from rounded allocation totals.

Adversarial checks: empty census, zero CUDA granule, heterogeneous card selection and old protocol frames reach named refusals or preserve the selected card's granule. Changes affect census, planning and gate setup; no per-token work was added.

Escape catalog: C1–C4 have no matches in the changed code.

Notes

Tests and GPU gates were not run in this review. The supplied runs name head d459b0a7a773330d0639b83acb9a0bb875fedc67, not the reviewed head, and omit nvidia-smi output. GPU evidence is marked false.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen3_serve.rs, crates/gpu-gates/src/bin/generate_glm5next.rs, crates/gpu-gates/src/bin/shared/qwen3moe_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 0ce2cef into midagedev:main Oct 30, 2026
7 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant