Repository navigation
gate_glm5next_tp: the rank body on the fixture at one, two and four ranks over a loopback - #589
Conversation
There was a problem hiding this comment.
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)
| 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), |
There was a problem hiding this comment.
Reuse GgmlType::reads_scale so scale-bearing formats have one owner.
| 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), |
177aab4 to
39ce711
Compare
There was a problem hiding this comment.
Since the last review:
- Scale-format owner: fixed at crates/gpu/src/weights.rs:268.
- PTX comparison: still open; see Non-blocking.
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
… the file; the source stays inside tp
…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.
…tions, or the gate refuses by name
39ce711 to
010e59f
Compare
There was a problem hiding this comment.
Since the last review:
- Duplicate NVFP4 rejection: fixed at crates/gpu/src/weights.rs:1805. The table-driven rejection test remains.
- PTX comparison: still open at crates/gpu/src/card_leg.rs:473; see below.
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)
|
The review is done and the contribution check passed, so I'm merging this. |
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 tpplan. 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::Rankopens 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::stepenqueues the N ranks sub-layer by sub-layer in turn, and the rank sum reusesGathers::enqueue_sum. The mixers and blocks are the existing KDA, MLA and FFN functions, withffn::rank_moeandCardExperts::rankfor the routed experts.tp::stepchecks 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,tapsandroutesrefuse to read before a completed step or on another GPU.set_tapsarms only before the first step, so a traced step's taps are never cleared.Rank::openchecks the context length, the vocabulary split and the embedding rows before any GPU work, and builds the gather's batch memory operations once.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_formatschecks the whole part list once, spans included, before any upload.tp::head::mergetakes 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.placement::kernels::rank_down_runsiscard_down_runsplus Q6_K, andLegStacks::of_rankis the only way to reach the new Q6_K arm ofCardLeg, which calls the existingenqueue_gemv_q6k_sel(no new kernel).card_down_runsand the planner's plans are unchanged, and a test pins both lists.host::link::gatherasGatherLoop, 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::releasereturnsGpuError, andGatherLoop::checkis the entry thattp::stepcalls.Cut::partinplacement::tpis 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_unitis 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), andcard_blocksjoins it with the format block.body::check_ctxandbody::check_poscheck the position count and the store capacity for the one-card body and the rank alike.bloomery-model-hftomodel::arch::glm5next::tp::cut, so the GGUF source and the checkpoint map read one table. It returns the existingPlacementError::Tensor, andmodel-hfcalls it and keeps its refusals. The GLM role table inmodel::arch::glm5next::rolesserves tensors by name (tensor_role) for the plan and the source alike.gate_glm5next_tpandjust gate-gpu-glm5next-tp(fixture tier only). The recipe also runs the gate binary's hardware test, andtools/gate-class.tsvclasses the recipe with the other GLM family gates.FxBands,ik_bands,IkRouteandfx_route_capmove from the e2e gate toshared/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.
split_f32, and both card constructors (CardExperts::newandCardExperts::rank) take the SwiGLU limit frombody::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 callse2e::on_path. The rank sum, the Q6_K launch and the mixers and blocks reuse existing functions.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.tp::cutandGatherLoop::releasereturn the existingPlacementErrorandGpuError. 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.gpu-glm5nextgoes from 4 to 7 withPINlines: the gather window,mem_batchandenqueue_sum, one call each.cargo fmtandcargo clippyare 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 themodel-hfcut 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) callsbloomery_gpu_gates::split_f32, andcrates/gpu-glm5next/src/ffn.rs:218and:264callbody::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 thatpart_formats(:279) and the GGUF cut (crates/gpu-glm5next/src/tp/source.rs:74) call.What I ran
The PR head is
8501095c8170a3d171ff1a0413fe7e5e86919be6on upstream main3da32e779a76dd2f1c9c4f3a0746865fb7521586. Each result names the head it ran on.just gate-gpu-glm5next-tpran again onaec9d61f, the PR head before its last commit (which only routes the host's scale format check throughGgmlType::reads_scale), and exited 0 in 115 s. Onb3504e78, with one routed layer's reference cut from five positions to four, or grown to six, the gate stops withlayer 3: ik routes 4 tokens, the run 5andlayer 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, andcargo check --workspace --all-targetswith the GPU features compiled on a DGX Spark with rc 0.just gate-gpu-glm5next-tpran on a DGX Spark onfe165643. The PR head differs from it in three ways. It is rebased onto the current main (git range-diffpairs eleven of the thirteen commits as equal; the other two differ in thenextnexport line ofcrates/gpu-glm5next/src/lib.rsand incrates/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 thetools/gate-class.tsvrow. 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-testandpython3 tools/recipes.py orphan-testsreturned rc 0,cargo test -p bloomery-hf --lib quant_config::gave 5 passed, andcargo 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 datasetmidagedev/bloomery-refsetsrevision375856d5632b1674710ee6db2858d0d6eb47346b) 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.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.1container on a DGX Spark, with asm_121build. The card lines fromnvidia-smi:just gate-gpu-glm5next-tponfe165643passes every clause, andgpu-gate.sh: gate_glm5next_tp ran 126 s (exit 0).gate_glm5next_tp clauses, DGX Spark
Guard checks, fail first
On
fe165643(18 guards) and its test-only successorcf5e33e1(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 theGatherLoop::checkcall, removed alone, let the step reach an invalid token instead of the link error, and the test failed with rc 101. Onfe165643the gather host tests gavetest result: ok. 5 passed; 0 failed; 1 ignoredand thetp::host tests gavetest result: ok. 9 passed; 0 failed.What I ran into
None of this blocks the PR.
Hardware
sm_121:gate_glm5next_tpand the guard checks onfe165643andcf5e33e1, and the GPU compile check on the PR head.6d727cde.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.