Repository navigation
glm5next: a split NextN plan's host headroom keeps the draft's routed experts, as an unsplit one's does, so the residency rule and the load take them out once - #93
Merged
Conversation
… experts, as an unsplit one's does, so the residency rule and the load take them out once plan_nextn_slots splits the trunk through the NVMe tier at the host room less the NextN layer's routed experts, and expert_nvme_tier sets the split plan's host headroom from that room, so the headroom had already lost them. The readers that host them beside the plan take them out again: the residency rule's PlanRoom, the residency record's headroom_after and the load's ChurnPool::check_beside. An unsplit plan's headroom never took them out, so only a split plan read short, by the draft's routed experts. The split plan's headroom now gets them back: both plans' headroom means the same, every reader takes them out once, and host_headroom_bytes keeps its value on both paths. On a DGX Spark, GLM-5.3-Flash UD-Q4_K_XL with MTP on under a card budget printed "the plan leaves -4378278012 B" and left residency off; with the fix it plans mid-p0-s1, as MTP off does at the same budget.
73 of 79 tasks
Owner
|
Thank you. The cause and the mutant table are clear. This goes into today's last train before the 0.3.2 cut. I merge it after the train now on the box lands, then run the GLM gates on the box, The review bot failed on this PR because a workflow setting refuses fork checkouts. That is ours to fix, not yours. |
Owner
|
Merged. The commit on main is 7a7a282, with the same patch as your head. The GLM gates run on the box in today's last train before the 0.3.2 cut. I will write here if one goes red. |
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Part of #13. With MTP on, GLM-5.3-Flash UD-Q4_K_XL on a plan the NVMe expert tier split leaves residency off on a DGX
Spark, because the seat's unset rule reads a negative host headroom. The NextN layer's routed experts were taken out of
that headroom twice. With this change they are taken out once, and the seat with MTP on resolves residency the way it
does with MTP off at the same budget.
plan_nextn_slots(crates/model/src/arch/glm5next/place.rs) runs the trunk's split at the host room less the NextNlayer's routed experts (
draft_host), andexpert_nvme_tiersets the split plan'shost.headroom_bytesfrom thatroom. A split plan's headroom has therefore already lost
draft_host. An unsplit plan's headroom comes fromPlan::plan_ator the machine's figure and still holds it. Three readers take the NextN layer's host bytes(
NextnPlan::host_runs, the same bytes) out ofplan.host.headroom_bytesthemselves:PlanRoom::headroom,crates/gpu-gates/src/residency.rs:43(the unset residency rule the GLM seat runs)residency_host_beside,crates/gpu-gates/src/record.rs:4003(the record'sheadroom_after)ChurnPool::check_beside,crates/placement/src/placement/churn.rs:121(the load's own check)On a split plan each of them took the bytes out a second time.
NextnPlan::host_headroom_byteshandled both kinds ofplan correctly, which is why the plan's own
HostOvercheck never showed it. The split path came in withc05b502c,and the bug with it.
On a DGX Spark with
BLOOMERY_CARD_BUDGET=100691449484and--plan,8fb237f2(itscrates/tree is the same asdc76bbb8's) printed:The split plan's headroom was 575364 B: the
plan_roomof 124455665664 B less the cache line's need of 124455090300 B,which counts the NextN bytes once [derived]. The rule printed 575364 - 4378853376 = -4378278012 B. 4378853376 B is this
file's
blk.45.ffn_{gate,up,down}_exps[derived from the tensor sizes]. With the change:headroomlessheadroom_afteris 4378853376 B, the NextN bytes taken out once.headroom_afterequals that run'splan_roomof 124101840896 B less its need of 124094511228 B.With MTP off at the same budget the seat already planned
mid-p0-s1with an empty pool (churn_experts=0 churn_bytes=0,headroom=2680980). With MTP on it now gets the same word. The pool stays empty on this plan becauseChurnPool::ofskips a stack with a segment on the NVMe tier. So the change moves the residency word and the residencyrecords. I did not measure decode with and without it; with an empty pool I expect no difference [inferred]. The prompt
cache is 0 on this plan with and without the change: the default budget is under one saved state (
cache ram=0 ... why=the default budget 153385922 B is under one saved state's 358962176 B).I fixed it on the plan side. The docs of
ChurnPool::check_besideandPlanRoomalready say that the bytes beside arebytes the plan does not count, and an unsplit NextN plan keeps that contract. The three readers are shared with the
Qwen3.8, V4.1 and MiMo seats, so fixing them would put a GLM case into common code. Right after the split, the split
plan's headroom now gets
draft_hostback.host_headroom_bytestakes it out on both paths and keeps its value, so theHostOvercheck does not move. One assumption: the fix addsdraft.host.expert_bytesand the readers subtracthost_runs().1; they are equal becauseplan_host_routedputs every routed stack of the NextN layer on the host asfile bytes.
MTP off (
plan_slots), V4.1, MiMo2 and the Qwen plans do not go through this function. An unsplit NextN plan takes nonew path, and its headroom and
host_headroom_bytesare as before.On main at serving defaults the GLM plan is refused before residency is read (
HostRoomFloor; my next PR, the unified pool floor, fixes that case), sothis bug shows only under a card budget. With that change applied (commit
51541b79on my fork'sdgx-spark-unified-floor, serving defaults, no lever set), thedefaults reach it:
the plan leaves -4376524924 B. Please take this PR first. Both change the same lines ofplan_nextn_slots, and I will open that PR on top of this one, where the correction moves into itsplan_in_poolclosure,right after the split.
Code shape
The review reads these first. A box left unticked needs one line of why.
readers are untouched.
plan fact; no common owner gained a branch.
host_headroomexpression became one line.HostOverand by the load'scheck.
tools/check-comments.shis green.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": none. The test fixturerouted()is the one the unified pool floorchange's test uses too; it is added here once.
What I ran
The test
slots::a_nextn_plan_leaves_the_draft_experts_in_its_host_headroomplans a synthetic four-layer file with Q4_Krouted stacks twice: at an ample room, where the trunk's host experts fit, and at one byte under that plan's host need,
where they split through the NVMe tier. For each plan it checks that it split or not as expected, and that
host_headroom_bytesandChurnPool::check_beside(a pool of 0 B, the NextN bytes beside) both equal the room lessHostNeed::of(plan, beside).bytes(), a figure that does not read the headroom.On one DGX Spark in the dev container,
cargo test -p bloomery-model --lib a_nextn_plan_leaves_the_draft_experts_in_its_host_headroom, each mutant applied alone:With the unified pool floor change stacked on this commit, both plan tests pass, and
cargo test -p bloomery-model --lib glm5nextpasses 38 of 38.On the Mac (each step's line cut after its time; the lint step counts 41 warnings, the ratchet's 41; the combos step ran
19 shapes, 0 red):
bloomery-modelis not one of the Mac's pure crates, so the new test runs on Linux only (above).On the DGX Spark,
bloomery-serve -m GLM-5.3-Flash-UD-Q4_K_XL-00001-of-00006.gguf --planwithBLOOMERY_CARD_BUDGETset and nothing else, base
8fb237f2and the change. The numbers above are from commita2c329f6, which has the samecode as this commit outside the comments and the test. Each line reads
MemAvailable, so the headroom moves a littlefrom run to run.
8fb237f2residency=off, the plan leaves -4378278012 Bmid-p0-s1,headroom_after=7329668residency=off, the plan leaves -4366862460 Bmid-p0-s1,headroom_after=5416836mid-p0-s1,headroom=12232852mid-p0-s1,headroom=2680980The load with the change at
BLOOMERY_CARD_BUDGET=99500000000(at 100691449484 the session's own plan is refusedby the NVMe tier's floor, the case the unified pool floor change fixes):
residency=mid-p0-s1,draft=mtp layer=45, loaded in 48.2 s, and one chatrequest answered "Paris" (40 tokens, the draft's 5 of 5 accepted).
GPU gates:
On the DGX Spark in local mode (
BLOOMERY_BOX_LOCAL=1), base79e5afbeand the change (a2c329f6;gate-glm5next-metaalso at96ebc823, this commit before its rebase onto the latest main, which changed only the review bot). The GLM shards were mounted read-only at the pathglm5next_meta.rsnames.gate-glm5next-meta: green on both. The library runs 31 tests on base and 32 with the change (the new test);hw_glm5next_specpasses.gate-gpu-glm5next-residency: its first 10 clauses pass on both, line for line the same. The NextN clauses stop onboth at the missing
glm5next/corpus-prose.ids, which the published refsets do not carry.gate-gpu-glm5next-mtp,-nvtier,-e2eand-staggerstop on the same missing file on both;-media-seatneeds theGLM mmproj file, which is not on this machine.
gate-gpu-glm5next-twocard,gate-gpu-glm5next-serveandserve-start-glm(local mode refusesBLOOMERY_CARD=both), the GLM fixture variants (not in the published fixtures) andweekly-gpu-glm5next-e2e-long(the same corpus file).
So the gates that ran show no change, but none of them reaches a split NextN plan.
gate-gpu-glm5next-nvtier@q6kdownis the one that plans this path, and it needs the box's fixture variants and corpus.
Hardware (if the change is for a machine)
--versionbloomery-serve 0.3.1 (commit 8fb237f2),(commit a2c329f6),(commit 96ebc823)nvidia-smi), Ubuntu 24.04.5, kernel 6.17.0-1032-nvidia--plan, one load, the gates and the unit tests above; built in a CUDA 13.3.1 container with cargo-oxide87bc9518just mac-static,just mac-test