Skip to content

placement: cap the NVMe tier room at the unified pool - #716

Merged
juliankang4 merged 6 commits into
midagedev:mainfrom
juliankang4:fix-unified-tier-room
Oct 23, 2026
Merged

juliankang4 merged 6 commits into
midagedev:mainfrom
juliankang4:fix-unified-tier-room

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

통합 메모리 pool에 들어가는 모델이 NVMe 계획 단계에서 PoolOver로 거부되는 결함을 고칩니다.

Part of #565. Tracked in #699.

What and why

On a machine with a unified memory pool, the planner could refuse a model that fits. When it splits experts between RAM and the NVMe tier, it sizes the host share from the host reading (workstation::plan_room). That reading can be larger than the unified pool, and the final pool check still holds the plan to the pool. The split then kept more experts in RAM than the pool could hold, and the plan ended in Broken(PoolOver) although paging more experts to NVMe would have fit. The split and the pool check came together in c05b502 ("glm5next: GLM on the NVMe tier").

Fixing it turned up a second gap in the same budget. When loaded_routed lowers node ownership it rebuilds the plan's totals, and that drops the bytes the caller plans beside the plan on each local card (the reserve). A node-owned GLM plan was then split against a budget that missed the reserve and failed the pool check. That came in with 6b95421 (#411).

The changes:

  • Plan::plan_at now returns, and records in HostTotals::room, one effective room: the host reading, capped by the machine's host room and by the unified pool. The cards' context cost, card share and bytes beside the plan are already counted by HostNeed, so none is subtracted again. A Given room sets the headroom from this capped room.
  • The pool reserve is summed in one private method, Plan::reserve_beside. plan_rule uses it in place of its inline sum, and loaded_routed calls it once after ownership lowering to restore the reserve. A product or sum past u64 is a named Metadata error and leaves the totals and headroom unchanged.
  • The doc comments in the DeepSeek, hybrid, GLM and Qwen placers now point at Plan::plan_at for the effective room.

Only where weights are stored changes: RAM or NVMe. For the same model and card budget, the tight-room and wide-room fixtures give the same card counts, tier counts, rows and headroom. No kernel, CPU or card compute path, gate, pin or tolerance changed, and no public signature changed. I make no speed or output-bit claim.

Release notes: Fixed: a model that fits the unified memory pool is no longer refused with PoolOver when the host reading is larger than the pool.

Code shape

  • No second copy. The reserve sum had one inline copy in plan_rule; it moved into Plan::reserve_beside, which plan_rule and loaded_routed share. The room cap lives only in Plan::plan_at.
  • Model code holds only architecture facts. The fix is in the common placement owner. The model files gained tests and comment updates, no logic.
  • Dead code is gone. The inline reserve sum in plan_rule is removed.
  • No silent failure. The reserve sum uses checked arithmetic and returns a named Metadata error on overflow.
  • Comments state what is true now. The comments describe the effective-room contract only.
  • No relaxed gate. No band, tolerance or lint moved. One existing GLM boundary test now expects the one-byte-short plan to be refused as HostRoomFloor, which fires before the pool check; the test carries a dated PIN with that reason, and it also compares a separately computed physical total.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up. cargo fmt --all and git diff --check are clean; clippy has not been run on this head.

Duplication found or removed (path:line), or "none": removed the inline reserve sum in crates/placement/src/placement.rs (plan_rule), now Plan::reserve_beside. The duplicate scan found no other candidate.

What I ran

The tested head is 9aeaef0b183575374f97f627ef3d4132af5c7c28, based on 6c5cc348c96314a89ae9990d34b47edfc92330fa. The tests are host-only planner tests on synthetic fixtures. They ran on CPU in a Linux container on a DGX Spark, and no GPU was used. The base moved from 648dd75 while the work ran; the moved files do not touch placement or model code, and the final test ran on the new base.

FAIL-first, with the original Plan::plan_at planted back in place of the fix (rc 101 in every case):

  • cargo test -p bloomery-placement --lib plan_room_uses_the_host_and_unified_limits_once: the returned room assertion failed, left: 1610612936, right: 1073741724.
  • cargo test -p bloomery-model --lib nvme_room_is_capped_by_the_unified_pool: test result: FAILED. 0 passed; 6 failed; 0 ignored; 0 measured; 465 filtered out. The six callers (GLM trunk, NextN and node-owned, Qwen, Qwen node-owned and DeepSeek) failed with PoolOver or HostOver.
  • cargo test -p bloomery-model --lib unified_room_still_refuses_an_unserved_nvme_tier: the shared hybrid caller returned Broken(PoolOver) where the explicit NoNvmeTier refusal is expected.
  • With only the reserve_beside call removed from loaded_routed, the GLM node-owned test failed with PoolOver. With it removed from plan_rule, the GLM trunk test failed with PoolOver.
  • With the checked arithmetic in reserve_beside replaced by wrapping arithmetic, a_pool_reserve_counts_local_cards_without_overflow failed on assertion failed: plan.reserve_beside(reserve).is_err().
  • On the final head with the original Plan::plan_at, the changed GLM boundary test slot_plans_on_one_pool_count_the_bytes_beside_once failed: test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 470 filtered out.

With the fix:

  • plan_room_uses_the_host_and_unified_limits_once: test result: ok. 1 passed.
  • a_pool_reserve_counts_local_cards_without_overflow: test result: ok. 1 passed.
  • nvme_room_is_capped_by_the_unified_pool: test result: ok. 6 passed; 0 failed.
  • unified_room_still_refuses_an_unserved_nvme_tier: test result: ok. 1 passed.
  • cargo test -p bloomery-model --lib arch::qwen35moe::place::tests::slots: test result: ok. 8 passed; 0 failed.
  • cargo test -p bloomery-model --lib arch::glm5next::place::tests on the final head: test result: ok. 17 passed; 0 failed; 0 ignored; 0 measured; 454 filtered out.

The first five results ran on 7eba55cd40ff57ee0176542df483d8ba5c679805. The later commits change one existing GLM boundary test and remove an unused import in the same file, and touch no production code, so those results carry over. The GLM module ran again on the final head.

The new tests cover the room cap and the reserve sum in the placement crate, and the GLM trunk, NextN, node-owned, Qwen, DeepSeek and hybrid callers. The tests that take a rank count run it at 1, 2 and 4 ranks on one host. That is a local planner simulation, not a run on several machines.

Not run: clippy, t0, the full workspace test run, the device-linked CLI --plan path and any GPU gate. No CUDA kernel, launch or device arithmetic changed, so I ran no timing comparison or model generation.

Reproduction

cargo test -p bloomery-placement --lib plan_room_uses_the_host_and_unified_limits_once
cargo test -p bloomery-placement --lib a_pool_reserve_counts_local_cards_without_overflow
cargo test -p bloomery-model --lib nvme_room_is_capped_by_the_unified_pool
cargo test -p bloomery-model --lib unified_room_still_refuses_an_unserved_nvme_tier
cargo test -p bloomery-model --lib arch::qwen35moe::place::tests::slots
cargo test -p bloomery-model --lib arch::glm5next::place::tests

What I ran into

This does not block the PR. A fixture that can never fit still goes through the existing 64 retry rounds in plan_in_pool before it is refused. Failing earlier when the floor stops moving would save startup work, but it needs a way to tell that apart from a floor that moves late, so I left the retry loop as it is.

AI help

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

@github-actions github-actions Bot added model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja placement Placement planning: crates/placement labels Oct 23, 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 behavior or quality defect survived the placement accounting checks.

Checked

Duplicates: 10 new functions checked; no duplicate owner or unneeded item. The model tests exercise distinct caller paths. The reserve helper serves both planning paths.
Complexity: The production changes replace inline accounting, restore one reserve call, and add room caps; the new helper has one branch.
Silent failure: 1 fallback followed. An absent unified pool supplies an unbounded cap. Both reserve overflow paths return named Metadata errors before changing totals or headroom.
Tests: Static mutation checks cover all 10 new or changed tests. Removing either cap at crates/placement/src/placement.rs:3885 breaks the room test; restoring the uncapped room breaks the six model caller regressions. Wrapping arithmetic at crates/placement/src/placement.rs:3859 breaks the overflow assertions. Dropping the reserve call breaks the GLM trunk or node regression. Counting the reserve twice breaks the changed GLM test's independent physical-total assertion. Removing the refusal at crates/model/src/arch/place_hybrid.rs:317 makes the Solar test fail.
Gates: Exact-fit acceptance and one-byte-short refusal remain asserted. The changed GLM refusal has a dated PIN, a reason, and author-reported FAIL-first evidence. No tolerance or band moved.
Adversarial paths: Checked oversized host readings, context costs, local versus remote card reserves, overflow, and machines without a unified pool. The caps, ownership filter, checked arithmetic, and existing refusal paths block the constructed failures.
Performance: Load-time planning only; no decode, prefill, or kernel work changes.
Escape catalog: No C1–C4 pattern matches.

Notes

Tests were inspected, not executed in this review. Passing runs and FAIL-first results are author-reported. No GPU gate evidence was supplied.

🔨 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 608f83b into midagedev:main Oct 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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