Repository navigation
gguf, placement, hf, model, model-hf, gpu, gpu-glm5next: a TP rank reads its parts from a GGUF file or a checkpoint folder - #618
Conversation
…ads its parts from a GGUF file or a checkpoint folder A rank's load took its parts from a GGUF file only. It now plans and reads each part from a model::part::Source: the caller's rule gives, for a tensor's name, card type and dims, whether it is read and which indices, and the source returns the part's bytes in its card type with the tensor scales its type reads. A source holds no model names and no rank count; one rank reads every tensor whole. model::part reads a GGUF file (gguf::Split), and model_hf::part::Checkpoint reads a Hugging Face checkpoint folder. The cut core moves to the CPU crates so both sources share it: placement::tp::part_of, Cut::span and check_bytes, gguf::tensor_runs, tensor_scales and scaled_weight. A folder's tensor is cut before it is normalized (hf::modelopt::normalize_part), so a part reads only its own stored values and block scales; check_part refuses a cut that splits a stored value or scale block from headers alone. A tensor the model moves after normalizing is made whole, moved, then cut. A plain BF16 or F32 expert stack now normalizes into one 3-D tensor. model_hf::arch::glm5next::open gives the GLM folder's checkpoint, and the family's rule is model::arch::glm5next::tp::rank_span. The folder's card plan and the rank's load hold the same tensors on the card (model::arch::glm5next::tp::card_holds): the trunk's layers, the head and the final norm, not the next-token layers or the token embedding, which the host reads. gpu-glm5next's tp::load plans every part of any source, checks its card format, then reads and uploads the parts a group at a time through Weights::add_parts, which now takes NVFP4 parts with their tensor scales. gpu-glm5next links the hf crates only through its `hf` feature, which the folder test on the card needs (`just gate-gpu-glm5next-tp`), so the gates that read a GGUF file do not key them. generate_glm5next --place tp without --plan loads rank 0's parts of the folder onto the card, then refuses by name: the ranks' step over the link between nodes is not built.
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix defect survived the source and boundary checks.
Non-blocking
⚠ Required staged-load evidence: crates/gpu/src/weights.rs:464.
The body reports that just stage-gpu-load-v41 was not run. Base AGENTS.md requires it for this file.
Attach that command's output from a two-card setup. It checks the shared uploader against real split files before landing; the fixture runs cover smaller loads.
Checked
Duplicates: 103 added declarations searched. Both dryer pairs read: short constructors for different error types; extracting them adds elements. No actionable duplicate found.
Complexity: all four flagged functions are new. plan_part (21) plans format-specific cuts; normalize_part (19) materializes them; Layout::apply (18) handles architecture layouts; Checkpoint::read (17) normalizes, transforms and checks the result. Existing stage helpers separate their work.
Silent failure: 9 conversion/default/filter sites followed. Failed conversions become named refusals; defaults rely on validated shapes or mapped names. Invalid scales, ranks and byte spans reach callers as errors.
Tests: 24 changed tests inspected. Mutation reasoning was static; no mutants were executed here. Production sites and mutants, with assertions that turn red by inspection:
- GPU
weights.rs:257,292,316,488: bypass size/scale/span checks or publish an upload early; the three part-validation tests and failed-group clause fail. - GPU
tp/source.rs:49: select rank zero for every rank; the rank-wrapper test fails.tp/mod.rs:632: retain NextN or embedding; the card test fails. - HF
modelopt.rs:1007,487: accept ragged experts or non-matrix quantized dims; the normalization and matrix-refusal tests fail.quant_config.rs:171: accept zero dims; the held-format test fails. - GLM
glm5next.rs:144,531,702,721: drop the key transpose, count BF16 at stored size, omit required-name checks, or retain NextN; layout, budget, required-folder and rank-equivalence tests fail. The real map gate also catches a changed-expsign atarch/mod.rs:11. arch/mod.rs:12: accept an underflowed zero; its numeric test fails. Qwenqwen35moe.rs:306: drop schema validation; its input-refusal test fails.- Checkpoint
part.rs:78,138,162: admit absent sources, allow row cuts, or normalize the whole instead of a part; the three source tests fail. - Model
glm5next/tp.rs:135,161: omit kernel units or shift rank spans; both new cut tests fail. - Placement
placement.rs:378: use the last node; the accessor test fails.tp.rs:111,151,183: shift a span, admit malformed sizes, or shift byte runs; the three moved cut tests fail.
Gates: changed budget expectations carry dated PIN reasons; no tolerance relaxed.
Escape catalog: C1–C4 have no matching added pattern.
Performance: load-time changes only; no changed decode, prefill or kernel work.
Notes
Source inspection only. Builds and gates were not run during this review. The body supplies GB10 gate output and identical PTX scans.
Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/generate_glm5next.rs, crates/gpu-glm5next/Cargo.toml, crates/gpu-glm5next/src/tp/mod.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. |
TP rank가 GGUF 파일이나 체크포인트 폴더에서 자기 몫의 조각만 읽게 합니다.
Part of #565.
What and why
This lets each tensor-parallel rank read only its own parts of a model, from a GGUF file or from a safetensors checkpoint folder, through one entry point. Before, a folder could only be read whole, so a rank that needs one slice of every split tensor had no way to start from the folder.
The entry point is the trait
model::part::Source, implemented for a GGUF file (gguf::Split, incrates/model/src/part.rs) and for a checkpoint folder (Checkpoint, incrates/model-hf/src/part.rs).plan(rule)checks every part against the tensor headers before any value is read, so a part that is out of range or mis-sized is refused at the input boundary.read(&Planned)then returns the card type's bytes and the tensor scale. The layer holds no model name and no rank count. With one rank, every tensor is read whole.crates/placement/src/placement/tp.rs):part_of,Cut::span,check_rankandcheck_bytesown where a rank's part starts and ends.crates/model/src/part.rs):Source,Planned,Partand the GGUF implementation.crates/gguf/src/lib.rs):tensor_runs,tensor_scalesandscaled_weight.crates/hf/src/modelopt.rs):normalize_partandcheck_part, plus the plain BF16 and F32 expert stacks.crates/model/src/arch/glm5next/tp.rs,crates/model-hf/src/arch/glm5next.rs):cut_ofandrank_spanname each tensor's cut, andPlacementError::Tpreports a refused part.glm5next::openopens the folder and returns the geometry, the tensor list and the checkpoint.crates/gpu-glm5next/src/tp/source.rs,crates/gpu/src/weights.rs):tp::loadtakes any&impl Source. It checks every part's plan and card format first, then reads and uploads in groups of a gibibyte throughWeights::add_parts, which replacesWeights::load_parts. The other caller of the old function, the Raon test helper incrates/gpu/src/arch/raon1/rda.rs, moved to the new API too (Weights::default(),add_parts, pieces withscale: None). A group joins the resident weights only after its uploads have synchronized, so a part refused late in a group leaves none of that group on the card. An NVFP4 part carries its own tensor scale.crates/gpu-glm5next/Cargo.toml): thehfcrates are optional behind a new featurehf. Only the folder test needs them, so the gates that read a GGUF file leave the feature off.crates/gpu-gates/src/bin/generate_glm5next.rs):--place tpuploads rank 0's parts to the card. It then stops with a named refusal, because the step between nodes is not built.Release notes: Added: a tensor-parallel rank reads only its own parts of a GGUF file or a safetensors checkpoint folder through one shared entry point.
Code shape
-expconversion has one function,neg_expincrates/model-hf/src/arch/mod.rs, which both GLM-5.3-Flash and Qwen call. It refuses a non-finite input before converting and a non-finite or zero result after, and each caller wraps the refusal with its tensor name. The temporary-folder helper that three test modules copied lives once inmodel_hf::test_support.Sourceand the cut rules carry no model name and no rank count.reads_scalefilter inpart_formatis removed.PINcomment with the reason.The per-rank memory budget counts the bytes a rank puts on the card, not the stored size and not tensors that stay on the host.
mapped_tpincrates/model-hf/src/arch/glm5next.rssets eachTpTensor::byteswithCardFormat::resident_bytes, the same owner the upload uses, and a BF16 tensor is counted asBf16AsF32, at its F32 size. Two kinds of tensor are never uploaded: the NextN layer after the trunk, and the token embedding, which stays in the host file.in_trunkincrates/model/src/arch/glm5next/tp.rsdecides whether a layer belongs to the trunk, andcard_holdsadds the embedding exclusion to it. The plan (mapped_tp), the checkpoint's part list andtp::loadall ask these two functions, so none of them keeps its own judgment. The embedding is still checked for presence and by the required-name check. A tensor name's layer number is parsed once, bylayer_ofin the same file. Before, every rank's budget counted the embedding, which asked each rank for an F32 size that the upload never used. A quantized expert stack with a single expert is read as well, whole or in parts: the plan finds the expert axis from the stored 2-D shape, so a stack of one expert no longer reads as a plain matrix.Duplication found or removed: the three test-module copies of the temporary-folder helper are replaced by one owner, the two
-expcopies are replaced byneg_exp, the layer-number parsing and the NextN judgment each have one owner (layer_of,in_trunk), and thepart_formatscale filter is removed because the NVFP4 rule already decides it.What I ran
The PR head is
9c98934013a385e58b05fe80e2c1e657fc2ce95b, on maind4429af1cf39f7a503ce728d6791fa20f97445fa. The other checks ran on the same commit before a rebase onto main with no conflicts. The checks that put the NextN judgment back (below, and in the GPU section) ran on an earlier commit of this branch.On that commit,
just contrib-check --tier t0passed, including these unit-test recipes:test-bloomery-gguftest-bloomery-hftest-bloomery-placementThe fixture budget test for the written fixtures,
hw_the_written_fixtures_hold_their_recorded_budget, also ran on that commit, on an RTX 5090 machine: 1 passed.To check that the NextN judgment has one owner,
a_glm_folder_gives_each_rank_its_gguf_s_partran with each caller put back to the old judgment, and with the owner's layer limit and its embedding exclusion removed. All five variants failed on an assertion ("the card plan holds no NextN tensor", "the checkpoint makes no NextN tensor" or!plan.contains_key("token_embd.weight")) with exit 101, and the restored source passed. The test checks, for one, two and four ranks, that the plan's card bytes equal the resident bytes of what each source reads, from a GGUF file and from a folder, with the embedding and the NextN layer left out of both.The oracle for the card test is the whole tensor read on the card. The parts of one, two and four ranks, joined on the card, must equal that tensor bit for bit. The test is
hw_a_folder_s_rank_parts_join_into_its_whole_on_the_card. It builds synthetic folders in NVFP4 expert stacks, MXFP8, FP8 with 128x128 blocks, BF16 and F32. It also checks the refusals that must happen before any read, and that a group with one refused part publishes none of its parts. For BF16 it checks that rank 0's head buffer equalsresident_bytes(65,536 divided by the rank count) at one, two and four ranks. The folder also holds the embedding and a NextN tensor, and the test checks that no rank's load puts either on the card.GPU evidence
The card is a DGX Spark (GB10) in the dev container image
bloomery-dev:cuda13.3.1. The rawnvidia-smitable lines come from an earlier run on the same card and image. The run of the final code printed the query lineNVIDIA GB10, 595.84before each GPU test.The folder test needs
--features hf. Without it the folder test is not built, and the run finds no test. The card test, run on that card:The fixture-tier gate for the same path, run on that card:
just gate-gpu-glm5next-tpends with exit 0. The recipe passes--features hfitself. The first result is thetpmodule's tests, and the second is the gate binary's test.To check that the card test can fail,
tp::loadwas changed to ask for the old judgment, which lets the NextN tensor onto the card. The test failed onassertion failed: off_card.iter().all(|n| whole.get(n).is_none())with exit 101. With the source restored it passed again.Each rank's parts, read from a checkpoint folder and joined in rank order on the card, equal the whole tensor bit for bit for every format the folder holds.
The change touches
crates/gpu/src/weights.rs, so the compiled PTX was compared with main. The scan set is the onejust canon-checkpicks: three binaries,bloomery-serve-ds41,gate_kquantandgate_swap. Each was built on main and on the head, scanned withptx-scan --no-jit, and compared withtools/ref/ptx-canon.py --scans:All 1026 entries (391, 319 and 316) are identical, and no entry exists on only one side.
The DeepSeek load goes through
Body::load_placed,Weights::load_placedandupload_segment, which now read the moved scale. Two fixture-tier gates cover that path.Both ran on main and on the head, on the same card, and both exited 0 with the same PASS lines:
For
gate-gpu-bf16the normalized output of main and head differs in 0 lines. Forgate-gpu-ds41-stepit differs in 3 lines of 268: the card's free bytes at load (two lines) and the load time with its free bytes. The resident bytes are the same,89101272.What I ran into
This does not block the PR. The checks above ran on one DGX Spark with loopback peers, so they cover the upload, the plan and the per-rank parts, not a decode across machines. The fixture in the gate refuses four ranks by name because four ranks would cut a 256-value Q6_K block. The folder's two and four rank parts are joined by the card test above. The full GLM-5.3-Flash FP4-Local checkpoint was not uploaded.
just stage-gpu-load-v41, whichAGENTS.mdasks for on a change tocrates/gpu/src/weights.rs, was not run. That recipe checks a DeepSeek-V4.1 plan split over two cards against the real files, and the machine used here has one card and only the fixture sets. The same load path was compared with main by the two fixture gates above.Hardware
A DGX Spark (GB10), driver 595.84, CUDA 13.3 in the dev container, for the card test and the gates. An RTX 5090 machine ran the fixture budget test, and a separate CPU host ran the unit tests.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.