Skip to content

placement, model, gpu, gpu-glm5next, gpu-gates: glm5next's card leg runs its routed stacks by its arms, NVFP4 in its planes and the 32-value downs included; the leg's buffers hold the forms its layers' downs read - #651

Merged
juliankang4 merged 3 commits into
midagedev:mainfrom
juliankang4:dgx-spark-routed-by-type
Oct 22, 2026

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

GLM-5.3-Flash의 카드 leg가 routed expert stack을 arm 표대로 돌리게 하고, leg buffer가 층의 down이 읽는 형식을 담게 합니다.

Part of #565. Builds on #629 and #640.

What and why

GLM-5.3-Flash's card leg now runs its routed expert stacks through the arm table that #629 and #640 set up for the other models (leg_arms, LegStacks::of_arms, routed_rule). Its arm adds NVFP4 in its planes and both down forms: the 128-value Q8Act and the 32-value Q8Blocks32. A Q6_K down still runs on the host.

The diff is 29 files, +1103/-427. It has six parts:

  1. GLM arm. leg_arms(Glm5nextBody) and routed_rule(Glm5nextBody) name the same set, and plan and load both read it. card_stacks in gpu-glm5next/src/ffn.rs builds the stacks with LegStacks::of_arms, so the GLM CardStacks, Stack and unrun are gone. The Qwen3.8 arms are now written on the same planes_leg_* functions. Their set is main's plus IQ3_S gate and up stacks: the rule admits a gate and up type whose prompt GEMM the table names, and gemm: an IQ3_S grouped prompt GEMM (gemm_iq3s), so IQ3_S expert stacks reach the card leg #645 added the IQ3_S one. Qwen3.8's card leg runs the same CardLeg launches that gate-gpu-qwen35moe-leg covers for IQ3_S.
  2. Leg buffers hold a set of forms. One GLM load can mix K-quant and IQ layers (Q8Act) with NVFP4, Q5_1, Q8_0 and IQ4_NL layers (Q8Blocks32). The card rows and rank rows hold the forms of the carded layers, and the prompt buffer holds only the forms of layers whose tile does not run. Each run picks the form its down entry reads. A form the buffers do not hold is a named GpuError::Shape.
  3. One byte formula. kernels::leg_bytes (with q8_blocks32_bytes and DownForms) counts the leg's buffers. The card leg, the relu2 leg, workstation::tier_chunk_scratch_bytes and GLM's card_leg_bytes all read it. A load whose layers are all NVFP4 no longer reserves the 413,696 B Q8Act column buffer, and a K-quant-only load no longer reserves the 163,840 B 32-value column buffer.
  4. A tier card names the layers its leg cannot read. A tier card plan over a file with an NVFP4 layer or a 32-value down is refused before load with PlaceError::TierLeg.
  5. Fewer copies. The common plan arm that place_hybrid::card_routed and the re-exports in mimo2, raon1, solar2, minimaxm3 and glm5next each carried is now accepts::common_leg_card (private, read by routed_rule). In routed_legs.rs, outcome_by reads a wrapped placement refusal by name, so the gate no longer scores it as a failure.
  6. Fully card-resident layers run without host views. A routed layer with all 288 experts on the card opens with no host view and no host service. Decode and captured steps skip the host go and wait operations, and the prompt pass skips the route download and adds the card sum directly. This is what lets a carded NVFP4 layer load at all, since the host has no NVFP4 qdot kernel. A load with residency, or one made for a route trace (BLOOMERY_ROUTE_TRACE), keeps the host leg, because the host service serves swaps and writes the trace. The per-layer diagnostic Body::forced_row follows the same rule: on a fully resident layer it serves no host row and reports a zero host sum.

Coverage still uses the per-program type union, as main does. TP code is unchanged, and the rank leg uses of_rank with the form-set buffers. gate-gpu-glm5next-tp passes for 1 and 2 ranks.

I did not time this change, so it carries no speed claim. That includes the hostless path in part 6, which removes two graph memory operations per fully resident layer.

Card leg check Reference Result
NVFP4, K-quant and Q8_0 arms, 13 card-leg tests the _sel launches 13 passed

The NVFP4 arms run as their _sel launches and the K-quant and Q8_0 arms run as theirs, as the 13 passing card-leg tests check.

Release notes: Added: GLM-5.3-Flash's card leg runs NVFP4 and 32-value down stacks, and the leg's buffers are sized by the forms of the layers it runs.

Code shape

  • No second copy. The leg's byte formula has one owner, kernels::leg_bytes. The GLM CardStacks, place_hybrid::card_routed with its re-exports, mimo2's place_gate and the card_leg.rs copies of q8_blocks32_bytes and the byte formula are gone. crates/gpu/src/model/fit.rs:41 act_col_bytes(k) is an older copy of kernels::q8_act_bytes(1, k) that this change leaves in place.
  • Model code holds only architecture facts. The GLM arm is a match arm beside the other programs in accepts.rs, and the buffers and the byte formula are common.
  • Dead code is gone. The items above had no caller left and are deleted. The new common_leg_card and card_leg_forms are private.
  • No silent failure. A buffer without the needed form, a program without an arm, a stack without a down entry in the table and a layer a tier card cannot read are each a named error.
  • Comments state what is true now. The docs that named removed items point to the current owner.
  • No relaxed gate. No band or tolerance moved, and no test was removed.
  • cargo fmt is clean on this tree. cargo clippy was not run on this head, so the lint count is unchecked.

Duplication found or removed (path:line): crates/placement/src/accepts.rs:309 and crates/placement/src/kernels.rs:39 look alike but differ: kernels::up is the entry for a stack with no gate, and qwen38_down adds the Qwen3.8 arm and the prompt GEMM condition over the same 32-value form. crates/placement/src/kernels.rs:115 and crates/placement/src/kernels.rs:101 count different layouts: the 32-value form has 256 * ceil(k/32/32) code words per column plus a sum and a scale per block, and the 128-value form has five permutation planes.

What I ran

The GLM fixture gate, the card-leg hardware tests, the GLM model tests and the PTX comparison ran on f8cb0fbc. The PR head is that tree on current main plus three changes: forced_row serves no host row on a fully resident layer, the Qwen3.8 arm test lists IQ3_S, and the gate fixture names its architecture key by the shared constant. Main's changes in between share one file with this branch, crates/model/src/arch/coverage.rs, where they touch only the Nemotron rows. The hostless clause ran again on 18cb411b, the same commits before the last rebase onto main. The TP gate, the routed-legs A/B, the Qwen3.6 leg gate, the host test sweep and t0 ran on earlier revisions of this branch. The later revisions are rebases onto current main and the hostless path of part 6, which changes nothing for a layer that keeps its host leg: the PTX comparison against main is identical.

GLM fixture gate on a DGX Spark. The decode graph has 172 nodes, and the card holds 163, 163 and 162 experts on its three routed layers. The new hostless clause opens a synthetic one-layer trunk with all 288 routed experts on the card and nonzero weights, once as NVFP4 and once as Q4_K. The NVFP4 load holds no host view and its eager, graph and batched prompt paths agree. The Q4_K load for a route trace keeps its host views and gives the same logits as the hostless load:

just gate-gpu-glm5next-e2e
hostless: nvfp4 no_host_views=true host_memops=0 eager=graph=batch finite logits tokens=4,4 PASS
hostless: q4_k no_host_views=true traced_host_views=true traced_rel=0.000e0 PASS
structure the plan's card experts on 3 routed layers [2, 3, 4], per layer [163, 163, 162], the slot map the same (true); none on a dense layer or on [5], and a card budget set PASS
structure decode graph_nodes=172 (want 172
gpu-gate.sh: gate_glm5next_e2e ran 206 s (exit 0)

With the trace condition removed from the load's keep flag, the route-trace load drops its host leg and the clause fails; with host views built for every layer, the NVFP4 load fails on the host union:

hostless: q4_k no_host_views=true traced_host_views=false traced_rel=0.000e0 FAIL
no fused qdot kernel for weight type NVFP4 in this build

On 18cb411b, the hostless clause also runs a forced row of the NVFP4 layer: the host sum is zero and the block output equals the card sum plus the shared expert's. With forced_row serving the host row unconditionally, the row waits for a host go that never comes and the gate fails:

BLOOMERY_TIER=fixture just gate-gpu-glm5next-e2e --only hostless
hostless: nvfp4 forced_row host_sum_zero=true ffn_out_vs_card_plus_shared_rel=0.000e0 PASS
hostless: q4_k no_host_views=true traced_host_views=true traced_rel=0.000e0 PASS
gpu-gate.sh: gate_glm5next_e2e ran 1 s (exit 0)

gate_glm5next_e2e: Hybrid::serve: the go of layer 0 did not land in 10s (generation 0, want 1)
GPU GATE RED: gate_glm5next_e2e (exit 1)

PTX comparison against main on f8cb0fbc (just canon-check):

canon-check: 3 bins, 1040 entries: 1040 identical, 0 reordered-only, 0 differs, 0 only-on-one-side; rows equal (jit columns not compared: no-jit both)

GLM model tests on f8cb0fbc (cargo test -p bloomery-model --lib arch::glm5next): test result: ok. 37 passed; 0 failed.

Two-rank GLM gate on the second DGX Spark, with 4 ranks refused by name because the fixture's 512 rows do not split into whole 256-value blocks:

just gate-gpu-glm5next-tp
(fx) 1 ranks: 12 flips, the first on their paths within the pair rule true
(fx) 2 ranks: 12 flips, the first on their paths within the pair rule true
(4) 4 ranks: the open refused "parts::load: blk.2.ffn_down_exps.weight: glm5next tp source: tp: blk.2.ffn_down_exps.weight: dim 0 of 512 into 4 ranks cuts off its format's 256-value block"
gpu-gate.sh: gate_glm5next_tp ran 93 s (exit 0)

Card-leg hardware tests on a DGX Spark (cargo test -p bloomery-gpu --lib card_leg:: through the gate runner):

test card_leg::tests::hw_the_leg_runs_the_nvfp4_arms_as_their_sel_launches ... ok
test card_leg::tests::hw_the_leg_runs_the_kquant_arms_as_their_sel_launches ... ok
test card_leg::tests::hw_the_buffers_hold_the_counted_bytes_of_each_form ... ok
test result: ok. 13 passed; 0 failed; 0 ignored; 0 measured; 363 filtered out; finished in 10.62s

Qwen3.6 placed leg gate on an RTX 5090 machine (the Qwen3.6 default fixture):

just gate-gpu-qwen35moe-leg
gate_qwen35moe_e2e --common-placed-only: PASS
gpu-gate.sh: gate_qwen35moe_e2e ran 11 s (exit 0)

just gate-gpu-routed-legs over the GLM UD-Q4_K_XL file on a DGX Spark, alternating main and this branch (main, head, head, main). All four runs pass, and each places 39 of 42 routed layers on the card:

just gate-gpu-routed-legs
legs: glm5next unsloth/GLM-5.3-Flash-GGUF/UD-Q4_K_XL/GLM-5.3-Flash-UD-Q4_K_XL cli: room -: placed 39 of 42 routed layers carded PASS
gate_routed_legs: PASS

Host tests and checks on an earlier revision of this branch, on a DGX Spark:

CHECK rc=0
test result: ok. 175 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 78.21s
test result: ok. 446 passed; 0 failed; 3 ignored; 0 measured; 10 filtered out; finished in 3.11s
placement rc=0 model rc=0 meta rc=0

just contrib-check --tier t0 on an RTX 5090 machine:

DONE tier=t0 total=107 red=0

With one rule reverted at a time, its unit test goes red:

MUTANT glm-arms-common: RED (rc=101)
MUTANT qwen38-no-gemm: RED (rc=101)
MUTANT leg-bytes-no-b32: RED (rc=101)
MUTANT no-tier-refusal: RED (rc=101)
MUTANT coverage-glm-common: RED (rc=101)
MUTANT glm-rule-common-model: rc=101

On a DGX Spark, a leg that builds one form when two are requested turns 3 card-leg hardware tests red, for example "reads Q8Blocks32 columns, which the buffers do not hold".

GPU Evidence

nvidia-smi on the DGX Spark (GB10) the GLM gates ran on:

| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.2     |
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |

On the RTX 5090 machine:

| NVIDIA-SMI 595.99.02              Driver Version: 595.99.02      CUDA Version: 13.2     |
|   0  NVIDIA GeForce RTX 5090        Off |   00000000:01:00.0 Off |                  N/A |

What I ran into

This does not block the PR.

  • just gate-gpu-qwen35moe-leg ran on the default fixture only. The four fixture variants (q35iq4xs, q35q80, q35iq4q8, q35q6k) are not on any test machine, so they did not run. The card-leg hardware tests cover the Q8_0 and Q6_K gate-up and the 32-value down paths against the _sel launches.

  • The Qwen3-30B placed gate (gate_qwen3moe_e2e) did not run because its fixture is not on any test machine. The common leg it uses is covered by the card-leg tests and the Qwen3.6 placed run above.

  • No real NVFP4 GLM file is on a test machine. The NVFP4 layers are covered by the synthetic hostless trunk in the e2e gate, the card-leg tests and the plan tests.

  • One just gate-gpu-routed-legs run failed on the planner's unified pool check for the GLM UD-Q4_K_XL file, with the pool passed by 31 to 44 MB:

    gate_routed_legs: FAIL
    

    That run chose a seat context of 262144 where the passing runs used 4096. The routed stacks in that file are Q4_K, Q5_K and Q6_K, where the GLM rule equals the common rule, so main and this branch give the planner the same input. Four alternating runs on one machine all passed. The planner reads free card bytes at run time, which looks like the source of the difference.

  • cargo clippy was not run on this head.

Hardware

Two DGX Sparks (GB10, driver 595.84) for the GLM, card-leg and placement runs, and an RTX 5090 machine (driver 595.99.02) for the Qwen3.6 placed leg gate and the t0 check.

AI help

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

@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 tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 22, 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 must-fix defect found in the changed code.

Checked

Duplicates: 32 new or moved items checked; no new duplicate owner found. Dryer reported zero pairs. GPU and gate code were also searched manually.

Complexity: new hostless (36) and hostless_fixture (23) contain fixture construction and assertion conjunctions, with fixture/open/check stages separated. run (47→54) adds clause dispatch. load_placed, forced_row, structure, CardExperts::new, front, and PromptProgram::route add hostless or form-selection branches.

Silent failure: 8 optional/default/skip paths followed to consumers. Missing forms and unsupported stacks produce named errors. Hostless diagnostic zeros represent an absent host sum.

Tests, static mutation review: wrong act_h.of(form) selection fails both hardware oracles; dropping + b32 fails buffer-byte assertions; omitting the 32-value form from card_leg_forms fails reserve assertions; deleting refuse_off_tier(machine)? fails the TierLeg assertion. Removing || host.route_trace fails the host-view check; unconditional row_enqueued(l, 0) times out. Missing NVFP4/IQ3_S arms or widened Qwen arms fail type/coverage assertions. Restoring hostless go/wait operations fails graph counts. Carding Q6_K fails Solar's existing placement checks.

Gates: graph-count and GLM coverage changes have dated PIN reasons. No tolerance was relaxed or test removed. Hardware tests retain their ignored hw_ entries.

Adversarial checks: mixed down forms, noncontiguous host layers, trace retention, forced rows, and grouped prompt service traced through their guards and consumers. Decode/prefill changes introduce no per-token allocation or new synchronization. Hostless layers remove two graph memory-operation nodes; the base contract classifies this as launch count only.

Escape catalog: C1–C4 do not match the changed code.

Notes

Dryer did not scan crates/gpu or crates/gpu-gates; those paths were searched manually.
The pasted GPU runs omit the base commit hash required by CONTRIBUTING.md, so gpu.json records incomplete evidence. GPU tests were not rerun here.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_glm5next_e2e.rs, crates/gpu-gates/src/bin/gate_glm5next_residency.rs, crates/gpu-gates/src/bin/shared/routed_legs.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

Not approved: a release freeze is on (#648), and a merge of a needs-gpu change now would change the tree under the release batch.

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

Filed outside this PR: #653

@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 must-fix defect was established in the changed paths.

Checked

Duplicates: 32 added declarations checked; no new duplicate owner. Dryer reported zero pairs.
Complexity: New hostless (36) divides into NVFP4 execution and Q4_K trace checks; hostless_fixture (23) divides into metadata and tensor construction. run (47→54) adds dispatch arms. load_placed, forced_row, structure, CardExperts::new, front and PromptProgram::route add form or hostless branches.
Silent failure: 10 skip, fallback and zero-result sites followed. Unsupported forms and tier combinations return named errors; omitted host sums belong to fully resident layers.
Tests, static mutation audit: omitting the second form at crates/gpu/src/card_leg.rs:191 fails the NVFP4, multi-column and byte-count tests. Removing the prompt leg term at crates/model/src/arch/glm5next/place.rs:342 fails the reserve test; dropping the refusal at line 657 fails the tier test. Removing NVFP4 from crates/placement/src/accepts.rs:428 fails the GLM arm test; restoring the old coverage rule at crates/model/src/arch/coverage.rs:1575 fails the coverage test. Dropping the GEMM condition at crates/placement/src/accepts.rs:297 fails the Qwen arm test. Changing one family's arm at crates/placement/src/accepts.rs:432 fails the common-arm assertions; admitting Q6_K there fails Solar's placement assertions. Restoring host service or dropping the copy at crates/gpu-glm5next/src/ffn.rs:1052 fails the hostless clause; restoring the unconditional serve at crates/gpu-glm5next/src/forced.rs:139 fails its forced-row clause.
Gates: graph-count and NVFP4 coverage changes have dated PIN reasons. No tolerance moved.
Performance: decode and prefill checked. Fully resident decode layers remove two host memory operations; no new per-token allocation was found. PTX identity evidence is supplied for an earlier revision.
Adversarial cases: mixed down forms, absent host views, late trace/residency attachment, NextN drafts and invalid router values were checked against their guards.
Escape catalog: no C1–C4 pattern matched.

Notes

Dryer excluded gpu and gpu-gates; those paths were checked manually. GPU tests were not run in this review.
The GPU evidence omits the base commit hash and reports runs on earlier heads, so gpu.json records evidence=false.

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

Filed outside this PR: #654

github-actions[bot]
github-actions Bot previously approved these changes Oct 22, 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: carried from e9c70b3e, not re-reviewed.

The approval of e9c70b3e stands for c7fecd13. This pull request's 3 commits are the same patches in the same order: git patch-id --verbatim (the changed lines, the lines around them and whitespace) and the subject are equal for every commit. That review ran under the reviewer instructions, tools and slag ledger that review this head, and it approved.

The base moved, and changed none of the files this pull request changes.

A carry covers each patch's own lines and the lines around them. What the base changed elsewhere is covered by CI on this head and by the landing gates.

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

…uns its routed stacks by its arms, NVFP4 in its planes and the 32-value downs included; the leg's buffers hold the forms its layers' downs read

@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.

Since the last review: no earlier must-fix or non-blocking items were open.

Verdict: CLEAN: Both interdiff edits preserve behavior.

Checked

Duplicates: 0 new definitions in the interdiff; dryer reported 0 pairs.

Complexity: crapper's hostless, hostless_fixture, run, load_placed, forced_row, structure, CardExperts::new, front and route reports concern previously reviewed patches. The interdiff adds no branches.

Silent failure: 0 new sites. Hostless fronts, backs and enqueue notices still bypass the host exchange.

Tests: no test edits in the interdiff. Source inspection confirms that the step scheduler emits no Serve entries and GLM uses StepLeg. Removing the host_leg override therefore leaves decode, verify and slot walks unchanged. No build or hardware gate was run.

Gates: no pins, thresholds or cases changed in the interdiff. Both dense coverage rows retain the dense_by_name import.

Adversarial check: dense leading layers followed by hostless routed layers in a multi-row step still issue no scheduler serve; the routed back also skips row_enqueued for hostless layers.

Escape catalog: no matching patterns. No ledger lessons are in force.

Notes

The PR includes card output and gate results for earlier branch revisions but omits the tested base commit hash. The GPU evidence list is incomplete.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_glm5next_e2e.rs, crates/gpu-gates/src/bin/gate_glm5next_residency.rs, crates/gpu-gates/src/bin/shared/routed_legs.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 0778db1 into midagedev:main Oct 22, 2026
6 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 tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant