Skip to content

gate_glm5next_tp: the rank body on the fixture at one, two and four ranks over a loopback - #589

Merged
juliankang4 merged 16 commits into
midagedev:mainfrom
juliankang4:dgx-spark-glm-tp-body
Oct 21, 2026
Merged

juliankang4 merged 16 commits into
midagedev:mainfrom
juliankang4:dgx-spark-glm-tp-body

Conversation

@juliankang4

@juliankang4 juliankang4 commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

GLM-5.3-Flash의 텐서 병렬(tensor-parallel) rank 본체를 더하고, fixture 위에서 rank 1개, 2개, 4개를 loopback으로 확인하는 gate_glm5next_tp를 추가합니다.

What and why

Part of #494, the first item of the GLM-5.3-Flash TP=2 lane.

Under tensor parallel, each of N ranks holds its part of every split tensor and all of every whole one, and the ranks sum their partial outputs. #501 added the N-rank all-gather link and #519 the --place tp plan. This PR adds the rank body that runs on them: each rank loads only its own parts from the GGUF, steps the existing mixers and blocks at the rank's widths, and merges the head's argmax across ranks. The reference is the existing one-card body (Body, the whole fixture on one GPU). With one rank, the rank body matches the one-card body bit for bit on layers 0 to 4. With two ranks, both ranks match each other bit for bit and stay within the one-rank bands. Nothing outside the new gate calls the rank body yet; loading the real model across two nodes is a later item of #494.

What the PR adds:

  • gpu_glm5next::tp::Rank opens one rank (open(gpu, file, at, ctx)), derives its GGUF source from the file, and arms and reads its taps, routes and logits. Dropping a rank waits for its stream before it releases its pages. tp::step enqueues the N ranks sub-layer by sub-layer in turn, and the rank sum reuses Gathers::enqueue_sum. The mixers and blocks are the existing KDA, MLA and FFN functions, with ffn::rank_moe and CardExperts::rank for the routed experts.
  • tp::step checks every input before its first upload or launch and refuses by name: no ranks, ranks out of order or of another count, ranks whose layer count, width or head rows differ, a GPU other than the one that opened the rank, two ranks on one stream, a missing link at N > 1, a link whose pages are not the ranks' own, a released or broken link, a token past the vocabulary, and a position other than the one the stores stand at. logits, taps and routes refuse to read before a completed step or on another GPU. set_taps arms only before the first step, so a traced step's taps are never cleared.
  • Rank::open checks the context length, the vocabulary split and the embedding rows before any GPU work, and builds the gather's batch memory operations once.
  • Both tensor input edges share one size check, weights::check_part_bytes: every dim is nonzero, the first dim is whole blocks of the tensor's format, and the byte count those dims give, computed without overflow, equals the file's. The GGUF cut refuses a part that is not whole units of its role, whole format blocks, or whole K units of the kernel that reads it, by tensor name. part_formats checks the whole part list once, spans included, before any upload.
  • tp::head::merge takes each rank's (largest logit, id plus the rank's offset). The larger value wins, and a tie goes to the lower id. A non-finite value is refused.
  • A rank has no host tier, so the fixture's Q6_K routed down (layer 5) must run on the card. placement::kernels::rank_down_runs is card_down_runs plus Q6_K, and LegStacks::of_rank is the only way to reach the new Q6_K arm of CardLeg, which calls the existing enqueue_gemv_q6k_sel (no new kernel). card_down_runs and the planner's plans are unchanged, and a test pins both lists.
  • The gather test's N-rank ring moves from the tests into host::link::gather as GatherLoop, with named errors in place of panics, so the gate can run N ranks on one card. The loopback refuses pages shorter than its layout, one page given to two ranks, a page another live loopback uses, nonzero starting counters, no slots, and a post row count that differs from the launch's. GatherLoop::release returns GpuError, and GatherLoop::check is the entry that tp::step calls.
  • Cut::part in placement::tp is the one rule that checks a part's rank, dim, unit and format block, and it refuses a part of zero extent. The checkpoint plan and the GGUF source both call it. kernels::card_k_unit is the one table of the card layout's K units (MXFP4 256, MXFP8 128, and NVFP4 256 on dense sites and 32 on routed down, by role), and card_blocks joins it with the format block. body::check_ctx and body::check_pos check the position count and the store capacity for the one-card body and the rank alike.
  • The GLM cut rule moves from bloomery-model-hf to model::arch::glm5next::tp::cut, so the GGUF source and the checkpoint map read one table. It returns the existing PlacementError::Tensor, and model-hf calls it and keeps its refusals. The GLM role table in model::arch::glm5next::roles serves tensors by name (tensor_role) for the plan and the source alike.
  • gate_glm5next_tp and just gate-gpu-glm5next-tp (fixture tier only). The recipe also runs the gate binary's hardware test, and tools/gate-class.tsv classes the recipe with the other GLM family gates. FxBands, ik_bands, IkRoute and fx_route_cap move from the e2e gate to shared/glm5next_tier.rs, so both gates read one owner. The gate refuses a routing reference whose token count differs from the run's.

The code takes N as data. The unit tests run N = 1, 2 and 4 (every_rank_holds_its_indices_of_the_cut_dim, the_merge_is_the_whole_rows_argmax) and 2, 3 and 4 ranks for the gather loopback.

Release notes: Under the hood: GLM-5.3-Flash has a tensor-parallel rank body, checked on the fixture by just gate-gpu-glm5next-tp; no binary loads it yet.

Code shape

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

  • No second copy. The fixture bands and the cut rule each have one owner (above). The gate reads each layer's selection bias with split_f32, and both card constructors (CardExperts::new and CardExperts::rank) take the SwiGLU limit from body::limit_of. Both input edges share one size check, the plan and the GGUF source share one cut rule (Cut::part) and one table of K units (kernels::card_k_unit), and the gate's first-flip rule calls e2e::on_path. The rank sum, the Q6_K launch and the mixers and blocks reuse existing functions.
  • Model code holds only architecture facts. The rank body lives in gpu-glm5next; the common crates gained a rank list of down formats, a part upload with its size check and the loopback, with no GLM branch.
  • Dead code is gone.
  • No silent failure. Before any cut or upload, a tensor part is refused by name when a dim is zero or missing, its first dim is off its format's block, its byte count overflows or differs from the file's, its spans hold another count, or its K part is off the kernel's K unit. A step and every read refuse the inputs listed above by name before a launch. The public tp::cut and GatherLoop::release return the existing PlacementError and GpuError. The gate expects a refused open at four ranks only; an open that fails at any other rank count ends the gate with that error.
  • Comments state what is true now. The unsafe ratchet for gpu-glm5next goes from 4 to 7 with PIN lines: the gather window, mem_batch and enqueue_sum, one call each.
  • No relaxed gate. No band changed; the e2e gate reads the moved bands from their new owner.
  • 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": the e2e gate's fixture bands (crates/gpu-gates/src/bin/gate_glm5next_e2e.rs) and the model-hf cut table (crates/model-hf/src/arch/glm5next.rs) move to one owner each; the gather test ring moves into the module. The gate's bias read (crates/gpu-gates/src/bin/gate_glm5next_tp.rs:775) calls bloomery_gpu_gates::split_f32, and crates/gpu-glm5next/src/ffn.rs:218 and :264 call body::limit_of (crates/gpu-glm5next/src/body.rs:1143) in place of their own activation match. check_part_bytes (crates/gpu/src/weights.rs:233) is the one size check that part_formats (:279) and the GGUF cut (crates/gpu-glm5next/src/tp/source.rs:74) call.

What I ran

The PR head is 8501095c8170a3d171ff1a0413fe7e5e86919be6 on upstream main 3da32e779a76dd2f1c9c4f3a0746865fb7521586. Each result names the head it ran on.

  • just gate-gpu-glm5next-tp ran again on aec9d61f, the PR head before its last commit (which only routes the host's scale format check through GgmlType::reads_scale), and exited 0 in 115 s. On b3504e78, with one routed layer's reference cut from five positions to four, or grown to six, the gate stops with layer 3: ik routes 4 tokens, the run 5 and layer 3: ik routes 6 tokens, the run 5.

  • On the PR head, the Linux t0 lint tier ended with DONE tier=t0 total=101 red=0, and cargo check --workspace --all-targets with the GPU features compiled on a DGX Spark with rc 0.

  • just gate-gpu-glm5next-tp ran on a DGX Spark on fe165643. The PR head differs from it in three ways. It is rebased onto the current main (git range-diff pairs eleven of the thirteen commits as equal; the other two differ in the nextn export line of crates/gpu-glm5next/src/lib.rs and in crates/hf/src/quant_config.rs, where main's own code moved). It adds the recipe line that runs the gate binary's hardware test and the tools/gate-class.tsv row. Its last commit adds the routing reference's token count check to the gate.

  • On 6d727cde, which the PR head follows by that last commit, python3 tools/gate_class.py --self-test and python3 tools/recipes.py orphan-tests returned rc 0, cargo test -p bloomery-hf --lib quant_config:: gave 5 passed, and cargo test -p bloomery-model-hf --lib arch::glm5next::tests:: gave 6 passed. Before the recipe line and class row, the same two tool checks returned rc 1.

The gate opens N ranks on one card, each rank with its own context, and joins them with the loopback. It steps the batch set's tokens from a reset and taps every layer's streams, every routed layer's picks and the logits at each position. It holds them against two references: the one-card body for one rank, and one rank for two ranks. At every position of every run, clause (hm) checks that the step's token is the argmax of the ranks' logits laid end to end in rank order (the largest value, a tie to the lower id), so the merge names the token's id in the whole vocabulary. The oracle clause compares every run with the fixture's reference batch set (fx_ref_glm5next, Hugging Face dataset midagedev/bloomery-refsets revision 375856d5632b1674710ee6db2858d0d6eb47346b) by the rule the e2e gate's (cfx) clause applies to the one-card body. Where a routed layer picks other experts than the reference (a flip), the first flip on a path must fall within the router band's pair rule, every layer output off a flip's path must stay within its stream band, and the last argmax must tie the reference at the head band.

Reference Result Difference
One-card body, 1 rank layers 0 to 4 bit for bit at 5 positions; layer 5 l_out_rel 4.997e-3 of its band 1.378e-1; logits 4.738e-3 of 1.384e-1 0 differing tap bits on layers 0 to 4
One rank, 2 ranks both ranks bit for bit alike; layers 6.473e-7 to 8.592e-3, logits 8.142e-3, each within its band 0 routed picks differ
fx_ref_glm5next, 1 and 2 ranks 12 flips each, every flip within the pair rule, last argmax 153205 a tie with the reference PASS

For one rank, the bit-equal range ends where the one-card body starts using the host. The gate opens that body without a card budget, so its plan puts all 288 experts of layers 2, 3 and 4 on the card and leaves layer 5's Q6_K experts on the host (card experts by layer [0, 0, 288, 288, 288, 0]). The rank runs layer 5 on the card, so from there on the gate holds the rank to the stream and head bands instead of bit equality. Clause (q6) checks layer 5 alone, from inputs that match bit for bit: the rank's Q6_K card leg lands at 4.997e-3 of the layer's block band 5.486e-2.

Four ranks do not run on this fixture. Its routed experts have an inner width of 512, so a quarter is 128 values, which cuts through a 256-value Q5_K block. The cause is the fixture's widths and the K-quant block size; the loopback takes four ranks in its unit tests. The open refuses the load and names the tensor, and clause (4) holds the refusal to name the tensor and the rank count. Four is the only count the gate expects to be refused. If the open fails at one or two ranks, the gate stops with that error and fails.

Clause (st) prints 29 PASS lines for the refusals of one rank's step and reads: opens of no positions and past the reference sets, reads before a step, a first step at position 1 and at the stores' end, a repeated position, taps armed after a step or once disarmed, a token past the vocabulary, five calls on a different GPU, two ranks on one GPU, ranks out of order or of another count, unjoined ranks, a short gather page, a foreign link and a released link. After the refusals, the step at the next position is accepted.

GPU Evidence

The gate ran in the bloomery-dev:cuda13.3.1 container on a DGX Spark, with a sm_121 build. The card lines from nvidia-smi:

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

just gate-gpu-glm5next-tp on fe165643 passes every clause, and gpu-gate.sh: gate_glm5next_tp ran 126 s (exit 0).

gate_glm5next_tp clauses, DGX Spark
one-card plan: card experts by layer [0, 0, 288, 288, 288, 0] of 288; the first layer with host experts 5
load host_tier r8=off (no sidecar at /models/fixtures/glm5next-r8/glm53-fixture-r8.gguf; optional: a source checkout writes it with just r8-sidecar)
load host_tier type=q4_K k=4096 path=fused
load host_tier type=q5_K k=512 path=fused
load host_tier type=q5_K k=4096 path=fused
load host_tier type=q6_K k=512 path=fused
(hm) 1 ranks: the step's token the argmax of the ranks' logits in rank order at every position, 0 of 5 otherwise PASS
(n1) bit-equal range: layers 0..5 (every expert on the card in both), 5 positions: taps bit for bit PASS
(n1) band range: layer 5 l_out_rel 4.997e-3 of the stream band 1.378e-1 (the rank computes on the card what the one-card body computes on the host) PASS
(n1) band range: logits rel 4.738e-3 of the head band 1.384e-1, every argmax a tie at it true; tokens the one-card body's or a tie true PASS
(q6) layer 5 (blk.5.ffn_down_exps.weight Some(Q6_K)): the rank's card leg against the host's rule, l_out_rel 4.997e-3 of the layer's block band 5.486e-2 PASS
(st) step on a different GPU: glm5next tp rank: rank 0: use the GPU that opened it PASS
(st) set_taps on a different GPU: glm5next tp rank: rank 0: use the GPU that opened it PASS
(st) taps on a different GPU: glm5next tp rank: rank 0: use the GPU that opened it PASS
(st) routes on a different GPU: glm5next tp rank: rank 0: use the GPU that opened it PASS
(st) logits on a different GPU: glm5next tp rank: rank 0: use the GPU that opened it PASS
(st) one rank: an open of no positions: glm5next Body: ctx 0: at least 1 and at most the 16384 positions a reference set checks the selector at PASS
(st) one rank: an open past the reference sets' positions: glm5next Body: ctx 16385: at least 1 and at most the 16384 positions a reference set checks the selector at PASS
(st) one rank: tap arming on a fresh open: accepted PASS
(st) one rank: logits before a step: glm5next tp rank: a completed step (tp::step) PASS
(st) one rank: a first step at position 1: glm5next tp rank: position 1, where the stores hold 0 positions PASS
(st) one rank: a first step at the stores' end: glm5next Body: a step at position 64 in stores of 64 PASS
(st) one rank: the step at 0: accepted PASS
(st) one rank: position 0 after its step: glm5next tp rank: position 0, where the stores hold 1 positions PASS
(st) one rank: logits after the step at 0: accepted PASS
(st) one rank: the step at 1: accepted PASS
(st) one rank: tap arming after a step: glm5next tp rank: taps armed before the first step (open the rank again) PASS
(st) one rank: the step's taps after the refused arming: 98304 values, bit for bit the read before it: true PASS
(st) one rank: disarming after a step: accepted PASS
(st) one rank: taps once disarmed: glm5next tp rank: armed taps (Rank::set_taps) PASS
(st) one rank: tap arming once disarmed: glm5next tp rank: taps armed before the first step (open the rank again) PASS
(st) one rank: a token past the vocabulary: token_embd.weight: token 4294967295 is past the 154880 rows PASS
(st) one rank: the step after refusals: accepted PASS
(st) one rank: two ranks on one GPU: glm5next tp rank: rank 1: each rank must use a distinct stream PASS
(st) one rank: ranks out of order: glm5next tp rank: rank 1 of 2 at place 0 of a step over 2 PASS
(st) one rank: a rank of another count: glm5next tp rank: rank 0 of 2 at place 0 of a step over 1 PASS
(st) one rank: unjoined ranks: glm5next tp rank: a step over 2 ranks needs its joined link only at N > 1 PASS
(st) one rank: a short gather page: the gather loopback: rank 0: page has 65852 bytes, needs 65856 PASS
(st) one rank: a foreign link: the gather loopback: rank 0: page is not joined by this link PASS
(st) one rank: a released link: the gather loopback: the link was released PASS
(hm) 2 ranks: the step's token the argmax of the ranks' logits in rank order at every position, 0 of 5 otherwise PASS
(2) 2 ranks: every rank's tokens, taps and picks bit for bit rank 0's PASS
(2) layer 0 l_out_rel 6.473e-7 against one rank, of the stream band 4.031e-2 PASS
(2) layer 1 l_out_rel 1.072e-6 against one rank, of the stream band 5.701e-2 PASS
(2) layer 2 l_out_rel 1.508e-3 against one rank, of the stream band 8.533e-2 PASS
(2) layer 3 l_out_rel 5.142e-3 against one rank, of the stream band 1.054e-1 PASS
(2) layer 4 l_out_rel 6.921e-3 against one rank, of the stream band 1.231e-1 PASS
(2) layer 5 l_out_rel 8.592e-3 against one rank, of the stream band 1.378e-1 PASS
(2) logits rel 8.142e-3 against one rank, of the head band 1.384e-1, every argmax a tie at it true; routed cells picked otherwise than one rank's 0 PASS
(rr) 2 ranks twice from fresh opens: every rank's tokens, logits, taps and picks bit for bit PASS
(4) 4 ranks: the open refused "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" (a part of other than whole units or format blocks; the loopback runs no step at this count) PASS
(fx) 1 ranks: 12 flips, the first on their paths within the pair rule true; every output off a flip's path within its stream band true (20 on a path); the last argmax 153205 a tie with ik's at the head band true PASS
(fx) 2 ranks: 12 flips, the first on their paths within the pair rule true; every output off a flip's path within its stream band true (20 on a path); the last argmax 153205 a tie with ik's at the head band true PASS
gpu-gate.sh: gate_glm5next_tp ran 126 s (exit 0)

Guard checks, fail first

On fe165643 (18 guards) and its test-only successor cf5e33e1 (2 guards), each guard was removed alone, and the test or gate clause that covers it failed. After each removal, the restored source passed. The two stream owner checks failed their CPU tests with rc 101. Each of the five calls on a different GPU, removed alone, turned only its own clause red. Eleven loopback constructor and launch guards failed their assertions. The step's link check and the GatherLoop::check call, removed alone, let the step reach an invalid token instead of the link error, and the test failed with rc 101. On fe165643 the gather host tests gave test result: ok. 5 passed; 0 failed; 1 ignored and the tp:: host tests gave test result: ok. 9 passed; 0 failed.

What I ran into

None of this blocks the PR.

  • The fixture cannot run four ranks, for the block reason in What I ran. With a routed inner width that is a multiple of 1,024, each of four ranks would hold whole 256-value blocks and the gate could step N = 4.

Hardware

  • A DGX Spark (GB10), driver 595.84, CUDA 13.3.1 container, sm_121: gate_glm5next_tp and the guard checks on fe165643 and cf5e33e1, and the GPU compile check on the PR head.
  • A Linux CPU machine: the lint tier on the PR head and the tool and CPU checks on 6d727cde.

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 21, 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: MUST_FIX: the new part uploader duplicates an existing format rule.

Must fix

1. Reuse the owner of scale-bearing formats

crates/gpu/src/weights.rs:268 repeats the scale-format rule owned by crates/gguf/src/quant.rs:260. This is a kind B duplicate under R14.
Replacing the guard now removes a second list to maintain. The replacement preserves the accepted formats: CardFormat::of already rejects NVFP4_ROWS, the additional type named by reads_scale().

            Some(f) if !t.ty.reads_scale() => formats.push(f),

Non-blocking

⚠ Attach the PTX comparison: crates/gpu/src/card_leg.rs:478 adds the Q6_K module to the shared card leg. The add class in AGENTS.md requires a base/head PTX comparison; the PR supplies gate output but no scan.
Run just ptx-compare ea128adff06f352c445e27ed05ef46df15235878 gate_glm5next_e2e --features glm5next and attach the output to check which entries changed.

Optimization headroom

  • G. Per-launch and per-sync fixed cost: crates/gpu-glm5next/src/tp/mod.rs:419, include the winning logit in the existing token readback. For vocabulary V over N ranks, replacing each full logits readback with one f32 in the token readback removes N copies and N logits allocations per token, saving 4(V−N) bytes/token [derived].

Checked

Duplicates: confirmed the format-rule copy and equivalent replacement. Diagnostics report 0 dryer pairs.
Complexity: diagnostics identify new orchestration functions and CardLeg::launch's added Q6_K arm; complexity alone is no finding.
Silent failure: part format, size and span checks return named errors.
Tests: statically inspected uploader, merge and rank-state assertions; no tests were run during validation.
Gates: the PR supplies fixture gate output; the unsafe ratchet has a dated PIN. No GPU tests were rerun here.
Escape catalog: C1–C4 have no matches in added shell code.

Card check: gpu-evidence. This pull request changes crates/gpu-gates/Cargo.toml, crates/gpu-gates/src/bin/gate_glm5next_e2e.rs, crates/gpu-gates/src/bin/gate_glm5next_tp.rs … and carries a gate run on the author's card, which counts as verified.

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

Comment thread crates/gpu/src/weights.rs Outdated
return Err(GpuError::shape(PARTS, format!("{} given twice", t.name)));
}
match CardFormat::of(t.ty) {
Some(f) if t.ty != GgmlType::NVFP4 && t.ty != GgmlType::F8E4M3_ROWS => formats.push(f),

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.

Reuse GgmlType::reads_scale so scale-bearing formats have one owner.

Suggested change
Some(f) if t.ty != GgmlType::NVFP4 && t.ty != GgmlType::F8E4M3_ROWS => formats.push(f),
Some(f) if !t.ty.reads_scale() => formats.push(f),

@github-actions github-actions Bot added gpu-evidence Verified on the author's card: the pull request carries the gate run and its output and removed needs-gpu Changes code a card must check, and carries no gate run on a card labels Oct 21, 2026
@juliankang4
juliankang4 force-pushed the dgx-spark-glm-tp-body branch from 177aab4 to 39ce711 Compare October 21, 2026 04:34

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

Verdict: MUST_FIX: two tests pin the same NVFP4 admission rejection.

Must fix

1. Keep NVFP4 admission rejection in one test

crates/gpu/src/weights.rs:1752 adds a table-driven admission test whose QROWS includes NVFP4. The existing case at crates/gpu/src/weights.rs:1811 already pins its rejection with no part upload takes. Removing the scale guard at line 268 makes both assertions fail for NVFP4. This is a kind B duplicate under R14 and the one-test-per-contract rule.
Removing the repeated NVFP4 case leaves one place to pin that format's admission. Keep the F8E4M3_ROWS and NVFP4_ROWS cases: they belong to OWN_ROWS, outside the new test's QROWS iteration.

Replace the rejection loop at line 1805 with:

        for (bad, says) in [
            (
                vec![part("a", GgmlType::Q8_0), part("a", GgmlType::F32)],
                "given twice",
            ),
            (vec![part("derived.x", GgmlType::F32)], "derived"),
            (
                vec![part("a", GgmlType::F8E4M3_ROWS)],
                "no part upload takes",
            ),
            (
                vec![part("a", GgmlType::NVFP4_ROWS)],
                "no part upload takes",
            ),
        ] {
            let e = part_formats(&bad).map(|_| ()).unwrap_err().to_string();
            assert!(e.contains(says), "{e}");
        }

Non-blocking

⚠ Attach the PTX comparison: crates/gpu/src/card_leg.rs:473 adds the Q6_K module to the shared card leg. The add class in AGENTS.md requires a base/head PTX comparison; the PR supplies no scan.
Attach just ptx-compare 3da32e779a76dd2f1c9c4f3a0746865fb7521586 gate_glm5next_e2e --features glm5next output to establish which entries changed.

Checked

Duplicates: the new admission test overlaps the existing NVFP4 case. Dryer reports 0 pairs and did not search crates/gpu or crates/gpu-gates.
Complexity: the 10 reported functions belong to unchanged patches; the interdiff adds no orchestration growth.
Silent failure: part_formats returns a named error before load_parts uploads anything.
Tests: static mutation analysis confirms both tests reject a dropped scale guard for NVFP4. F8E4M3_ROWS and NVFP4_ROWS have no card layout and remain rejected without that guard. No tests were run.
Gates: no pins or bands moved in the interdiff.
Escape catalog: C1–C4 do not match the interdiff.

Card check: gpu-evidence. This pull request changes crates/gpu-gates/Cargo.toml, crates/gpu-gates/src/bin/gate_glm5next_e2e.rs, crates/gpu-gates/src/bin/gate_glm5next_tp.rs … and carries a gate run on the author's card, which counts as verified.

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

…'s tensor parts upload, the gather loopback leaves the tests

The pieces the tensor-parallel GLM body loads and links through, each beside
the one-card path it leaves as it was:

- placement::kernels::rank_down_runs: the down types a tensor-parallel
  rank's leg runs, card_down_runs' and the Q6_K down over q8_1 rows. A rank
  has no host tier, so every expert runs on its card. card_down_runs, and
  with it every one-card plan, is unchanged; the test pins both lists.
- card_leg: LegStacks::of_rank admits that list; LegStacks::of keeps
  card_down_runs (both through one checker). CardLeg loads the Q6_K _sel
  entries and runs a Q6_K down stack through enqueue_gemv_q6k_sel, which
  only of_rank's stacks reach.
- weights: Weights::load_parts uploads tensors or parts of them a caller
  cut (TensorPart: the part's header entry and its rows' bytes), in the
  card format load_where uses; block_index is public for the caller's pick
  of names.
- host::link::gather: the tests' N-rank loopback (Ring) moves into the
  module and refuses by name instead of panicking; GatherLoop is it over
  mapped pages, for a gate that runs every rank in one process.
- model::arch::glm5next::tp::cut: the per-tensor cut rule moves out of
  model-hf, so the GGUF rank source reads the same rule as the checkpoint
  map. model-hf calls it and refuses as before.

Existing functions changed, each keeping its callers: LegStacks::of (same
admission, through LegStacks::with_downs), CardLeg::load (one more kernel
set), CardLeg::enqueue (one more down arm), block_index (now pub),
gather's test Ring (now the module's, Result instead of panics), and
model-hf's tp_cut (replaced by model's tp::cut, same table).
…head's merge

tp::Rank is one rank of N: its part of every tensor, cut by the family's
rule and read through GgufSource, which cuts the file's mapped bytes, and
the one-card step's buffers and stores at the rank's widths, with one row's
card-expert buffers. A step calls the mixers' and blocks' own functions at
those widths (kda, mla, ffn::dense, and ffn::rank_moe, the routed block
with every expert on the card at its own id), gathers each sub-layer's
part from every rank, adds them in rank order and runs hc_post on the sum:
two gathers a layer, each on post and wait operations the rank builds at
its open. Each rank's head projects its part of the vocabulary and takes
its argmax; tp::head::merge picks the larger value, the lower id on a tie,
the one-card argmax's rule. tp::step runs every rank a sub-layer at a
time. N is the ranks' count; at N = 1 there is no gather.

The body's load helpers (dims_of, trunk_plans, layer_cfg, store, host_run,
Body::derive, Kernels::load, Scratch::new, Embedding, pair::write_row)
become crate-visible for the rank's open; none changes.
…anks over a loopback

Every rank is a context of its own on the one visible card, their parts
carried by host::GatherLoop. (n1) one rank against the one-card body: the
layers whose experts both run on the card bit for bit, the layers the
one-card body serves on the host (the fixture's Q6_K downs) within their
stream bands, the logits within the head band; (q6) that first host layer
held to its own block band; (hm) every run's step token the argmax of the
ranks' logits in rank order; (nN) every rank alike and within the bands
of one rank. Two ranks must load and run; four, whose part of the expert
width cuts off the down stacks' Q5_K block, are refused at the open by
name, and a refusal at any other count fails the gate; (rr) a rerun bit
for bit; (fx) each run against ik's batch set as the e2e gate's (cfx)
holds the one-card body. A tap's stream count is hc::HC_STREAMS.

FxBands, ik_bands, IkRoute and fx_route_cap move from gate_glm5next_e2e to
shared/glm5next_tier.rs, which both gates read; the e2e gate is unchanged.
Recipe: just gate-gpu-glm5next-tp (fixture tier only).
… a rank's stores take each position once

Cut::part is the one rule for a rank's extent along a cut: no rank, a dim
the tensor lacks, a part of no units or of other than whole units, and a
part off the format's block are refused by name. plan_tp, the GGUF rank
source's part_of and RankOf::part call it. The one-card body and the rank
share check_ctx and check_pos.

A rank tracks the position its stores stand at. tp::step refuses, on every
rank and before any launch, a position other than that one or past the
stores. A step that fails once its launches go out leaves every rank
refusing the next, and a rank's logits, taps and routes are refused until
a step completes. gate_glm5next_tp's (st) clause holds these refusals.
…ayout's K unit

The plan checked a part along K against the format's block alone, 32
values for MXFP8 and MXFP4, while the card layouts need more: MXFP8
planes hold a scale word of four blocks (128 values, mxfp8_planes) and an
MXFP4 stack the q8_1 activation's 256 (MxStack::upload). A plan could give
a rank a part its card then refused.

kernels::card_k_unit is the one table of those units. tp::card_blocks
widens a format block to it; the checkpoint plan (model-hf tp_tensors,
through Format::card_type, which now names MXFP8's card type) and the
GGUF rank source both pass their blocks through it to Cut::part. A gpu
test holds the two layouts to the table's values.
…::on_path; step reads the trunk's layer count directly
…d out alike

GatherLoop::new checked each rank's crossings against its own page, so two layouts of one byte prefix and one-row slots of widths 1 and 2 joined and the wider rank summed an unwritten zero. The loopback now refuses layouts that are not ranks 0..N of N with rank 0's slots and tail. tp::step took the longest trunk of its ranks; it now refuses ranks whose layer count, width or head part differ from rank 0's before any launch. Ring::release always released to RELEASE and loses its parameter.
@juliankang4
juliankang4 force-pushed the dgx-spark-glm-tp-body branch from 39ce711 to 010e59f Compare October 21, 2026 05:06

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

Verdict: CLEAN: The duplicate case is removed, and the remaining test preserves NVFP4 rejection coverage.

Non-blocking

⚠ Attach the PTX comparison: crates/gpu/src/card_leg.rs:473 adds the Q6_K module to the shared card leg. The add class in AGENTS.md requires a base/head PTX comparison; the PR still supplies no scan.
Attach just ptx-compare c69b5d37d34c1cb87a3e06babe67a53d0dfa0db0 gate_glm5next_e2e --features glm5next output to establish which entries changed.

Checked

Duplicates: 0 new items in the interdiff. The repeated NVFP4 case is gone. Dryer reports 0 candidate pairs.
Complexity: crapper flags Rank::{open, enqueue_sub}, tp::step, gate::{run, state_clause, fx_clause, ranks_run}, Ring::new and tp::cut as new-function growth, and CardLeg::launch as 47→50. These patches are unchanged; the interdiff only removes a test case.
Silent failure: 1 admission path followed. Scale-dependent formats return a named error before load_parts uploads anything.
Tests: removing the scale guard at weights.rs:268 makes part_formats_follows_the_scale_rule fail on NVFP4. F8E4M3_ROWS and NVFP4_ROWS remain covered separately because QROWS excludes them. Static mutation analysis only; no tests were run.
Gates: no bands or pins moved. The removed case duplicated coverage retained in the table-driven test.
Escape catalog: C1–C4 do not match this interdiff.

Notes

Dryer did not search crates/gpu or crates/gpu-gates; the interdiff introduces no items there.

Card check: gpu-evidence. This pull request changes crates/gpu-gates/Cargo.toml, crates/gpu-gates/src/bin/gate_glm5next_e2e.rs, crates/gpu-gates/src/bin/gate_glm5next_tp.rs … and carries a gate run on the author's card, which counts as verified.

🔨 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 603d6da into midagedev:main Oct 21, 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 gpu-evidence Verified on the author's card: the pull request carries the gate run and its output model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja 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