Repository navigation
placement, model, gpu-gates: --place tp plans GLM-5.3-Flash's Hugging Face checkpoint over N ranks, each in its own node's pool - #519
Conversation
…ry dtype quantized checkpoints store held raw safetensors holds I8, U16, U32, I32, F8_E5M2 and F8_E8M0 beside U8 and F8_E4M3 as stored bytes, so the shards of the FP8, MXFP4, NVFP4 and compressed-scale checkpoints open; widening stays BF16, F16 and F32. Folder opens model.safetensors.index.json and every shard it names, each mapped with its header validated, so opening reads the index and the headers and no tensor's bytes. Every name of the index must be in the shard it names and every tensor of a shard in the index under that shard; a shard named by a path outside the folder (a shard may sit in a folder of it, as FP4-Local's tensors/native-QB.safetensors), and a shard's own refusal, are named with the file. A tensor reads whole, by a range of its rows (one contiguous range) or by a range of the columns of a 2-D tensor (each row's piece, row after row). The tests open the real headers of two nvidia/GLM-5.3-Flash-NVFP4 shards with their index entries, and one deepseek-ai/DeepSeek-V4.1-Flash shard, written as files whose data sections are holes. refuses_unknown_dtypes_and_bad_ranges used I8 as its unknown dtype; it now uses C64.
quant_config reads the supported configs quantized checkpoints carry: ModelOpt's hf_quant_config.json (quant_algo, quantized_layers, exclude_modules), transformers' fp8 (weight_block_size, modules_to_not_convert), compressed-tensors (config_groups, ignore). Quark checkpoints are refused by name. Each module is declared a format: NVFP4-ModelOpt, FP8 by block, channel or tensor, MXFP4-OCP or INT4-pack; an unknown quant_method, algorithm or scheme is refused by name when the config is read. ModelOpt's file takes a module first and config.json's own config the modules it leaves, as DeepSeek-V4.1-Flash-NVFP4 needs. plan gives every tensor of a table one format: a weight's stored dtype, shape and companion scales are matched against its module's formats, a tensor scale may be shared from the module ModelOpt names (Qwen3.8's PLE shards), and BF16 and F32 are placed as stored. A quantized weight the config leaves unquantized, one that fits none of its formats, a companion no placed weight reads and any other dtype are refused by name. input_scale and kv_cache_quant_algo are reported, not used. The fixtures are the configs of twelve checkpoints and every tensor of GLM-5.3-Flash-NVFP4's layers 0 and 3.
…s unit-axis block scales, NVFP4 with csf and csf_32x2_v1 scales ModelOpt's FP4-Local exports declare MXFP8 (group 32 or weight_block_size [1, 32]), FP8_PB_WO with its block grid stored [r, 1, c, 1], W4A16_NVFP4, and NVFP4 whose weight_scale is stored compressed (weight_scale_encoding csf or csf_32x2_v1). The reader refused MXFP8 by name and so read neither config. Each format now places its weight with its own companions: MXFP8 its E8M0 scale a 32 values, FP8 blocks a 2-D or unit-axis 4-D grid, csf its fixed slab and exceptions, csf32 its five parts. An unknown encoding, or an encoding on another algorithm, is refused by name. Decoding the compressed scales is not part of this reader.
…and layouts glm5next::hf maps a GLM-5.3-Flash checkpoint's tensors to the glm5next names the program reads, with the layouts llama.cpp's converter (Glm5NextModel) writes: the routed experts of a projection stacked by id, kv_b_proj split per head into the key half (transposed) and the value half, the KDA conv taps as [kernel, 1, channels], A_log as -exp of its heads, dt_bias as the ssm_dt bias, under a model.language_model. or model. prefix. The next-token layers and the vision tower are left out; any other name, a stack missing an expert and a kv_b_proj of the wrong rows are refused by name. Layout::apply moves a tensor's elements; the names come from glm5next::names. The test maps layers 0 and 3 and the unlayered tensors of nvidia/GLM-5.3-Flash-NVFP4 (placed by hf::quant_config) to exactly the names and ggml dims of unsloth's UD-Q4_K_XL for those layers. An ignored test checks every layer and the small F32 tensors byte for byte against that GGUF.
…r N ranks, each rank in its own node's pool Tensor parallel is a new placement beside the expert tier: each of N ranks holds a 1/N part of every split tensor and all of every whole one, resident in its own node's pool, with no host or NVMe tier. placement::tp::plan_tp takes the tensors and one pool a rank and gives each rank's split and whole bytes; a cut whose parts are not whole units of the tensor's role (a head's rows) or cut off its format's block, and a rank past its pool, are refused by name. A rank's pool is its node's census reading: the unified pool on a device that allocates from host memory, else the card's usable bytes capped by its free reading. A format's bytes and cut units are written once, on the format (hf::quant_config::Format::held): a format held in a GGUF card type reads its row (QRow::cut: one block along a row, any row), so NVFP4 in every scale encoding is GGUF's 64-value block; MXFP8 and FP8 block formats, which have no card type row, keep their own block and one scale a block. The family gives only the axis: model::arch::glm5next::hf::tp_cut names the dim and unit each glm5next tensor is cut on (heads for KDA and latent attention, inner width for dense, shared and routed experts, vocabulary for the head) or keeps it whole (norms, shared low-rank inputs, indexer, router, hyper-connections, embedding). generate_glm5next --place tp --plan reads the Hugging Face folder BLOOMERY_REF_MODEL names, plans rank 0 on this process's one card and the other ranks on the nodes BLOOMERY_TP_NODES lists (each node's tier_server answers its census), and prints one `tp rank=` line a rank. The load is not built and is refused by name, as are BLOOMERY_DRAFT=mtp, an empty node list, and BLOOMERY_TP_NODES beside BLOOMERY_TIER_NODES; an off-host node needs BLOOMERY_TIER_LINK=rdma as a tier node does. Every other --place word parses as before, and Place::on refuses tp for every other binary. On GLM-5.3-Flash-FP4-Local's layers 0, 3 and 4 the per-rank sums, scaled by the layer kinds the config lists, equal an independent count of all 42 headers: 91,600,737,016 B a rank at N = 2 and 46,684,372,088 B at N = 4. 64 heads into 3 ranks and a routed down's 2,048 inputs into 64 ranks are refused.
There was a problem hiding this comment.
Verdict: CLEAN: No merge-blocking defect survived the failure-path checks.
Non-blocking
⚠ Assert routed-expert stacking order: crates/model/src/arch/glm5next/hf.rs:213. Replacing by_id.values() with by_id.values().rev() escapes the assertions: the mapping test discards layout at line 657, and the oracle's VALUES list excludes expert weights. Assert numeric expert-ID order in each Layout::Stack in the existing mapping test to catch an ordering regression.
Checked
Duplicates: 146 new declarations checked; no proven duplication. All three dryer pairs read: distinct error variants or conversion domains, with no common owner to reuse.
Complexity: new GLM layer/tp_cut and quant modelopt_format/held dispatch architecture or format rules. New map combines name dispatch, expert stacking and group validation; layout combines format-specific companion checks; required combines config validation and role selection; HfMapSet::read combines headers, file rows and completion checks; Folder::open combines index validation and shard checks. Existing Dtype::of/name, levers::read, Family::check_set and cli::run grow through cases and guards.
Silent failure: 13 added production fallback/conversion sites followed. Required malformed values reach named errors; remaining fallbacks represent optional metadata or implicit dimensions.
Tests: mutation review of 23 new tests and two changed tests. Wrong types/layouts/byte totals and dropped presence, cut, pool, overflow, identity and RDMA guards meet assertions. Reversed expert stacking remains uncovered, as above.
Gates: no existing band or pin relaxed. The new writer PIN matches its source md5. The PR reports FAIL-first for missing oracle values, stale identity, unfinished sets and the A_log transform.
Adversarial checks: missing configured layers, partial experts, head/block boundary cuts, duplicate device UUIDs and overflowing packed widths are refused. Unavailable peers propagate connection errors.
Escape catalog: no C1–C4 match. Changed paths perform planning, metadata reads or tooling; no decode/prefill hot path changed.
Notes
Tests were inspected, not executed in this review. GPU evidence is incomplete: the PR provides no nvidia-smi card-and-driver line.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/generate_glm5next.rs, crates/gpu-gates/src/generate.rs, crates/gpu-gates/src/record.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)
|
The review is done and the contribution check passed, so I'm merging this. |
TP=2를 위해 GLM-5.3-Flash-FP4-Local의 텍스트 본체를 N개 rank에 나누는 배치 계획(
--place tp --plan)을 더하고, 설정에 있는 모든 텍스트 층과 필수 텐서가 폴더에 있는지 검사합니다.What and why
Part of #494, the "TP=2 placement" and "GLM-5.3-Flash names and layouts from the Hugging Face checkpoint to the names the body reads" items, and of #493, the "quantization config" and "safetensors folder source" items.
Under tensor parallel, each of N ranks holds a 1/N part of every split tensor and all of every whole one, resident in its own node's memory, with no host or NVMe tier. This PR adds the plan of that placement for GLM-5.3-Flash's Hugging Face checkpoint and prints it; the tensor-parallel load and decode are later items of #494, and a run without
--planis refused by name.What the PR adds:
hf::safetensors::Folderreads a Hugging Face model folder (itsmodel.safetensors.index.jsonand every shard's header, shards in subfolders included) as one tensor source, every dtype quantized checkpoints store held raw. A shard path that leaves the folder (.., a leading/, a drive prefix or a\), and an index whoseweight_mapholds no tensors, are refused by name.hf::quant_configreads a checkpoint's quantization config (ModelOpt'shf_quant_config.jsonand thequantization_configinconfig.json) into one format a tensor, with each format's companion tensors checked. It knows NVFP4 (with plain,csfandcsf_32x2_v1scales), MXFP4, MXFP8, FP8 per tensor, per channel and per block (block scales[r, c]or[r, 1, c, 1]), packed INT4, BF16 and F32. A zero or malformed group size, an FP8 field of the wrong type, and a[class in a ModelOpt module pattern (the reader matches*and?only) are refused when the config is read. Quark checkpoints are refused by name; their config is not read. A packed weight whose unpacked width exceeds the platform's word is refused when it is placed. A tensor scale ModelOpt shares across a module's parts (Qwen3.8's PLE table) is found on the declared module. Published checkpoint configs are fixtures.Format::heldgives a format's bytes on the card and the block a cut must keep, with one owner per format: a format held in a GGUF card type reads itsQRowand usesgguf::tensor_bytes, so NVFP4 in every scale encoding is GGUF's 64-value block with one F32 tensor scale a matrix. MXFP8 and FP8 block weights have no card type row yet and keep their own block and one scale a block.model::arch::glm5next::hfmaps the checkpoint's names and layouts to the glm5next names and ggml dims the body reads, andtp_cutnames the dim and unit each tensor splits on: heads for KDA and latent attention, inner width for the dense blocks and the shared and routed experts, vocabulary rows for the head. Norms, the low-rank inputs every head shares, the indexer, the router, the hyper-connection mixes and the embedding stay whole on every rank. A stem with no rule, a split tensor with other dims than its stem has, two checkpoint tensors for one routed expert, a routed expert that is not a matrix, a layer holding part of a set of tensors that come together (a dense block's gate without its up, say), akv_b_projwhose head count overflows, a tensor with a zero dimension or a byte count past 64 bits, and a checkpoint with no text tensors are refused by name. At the folder entry, one required-name table reads the config's layer kinds and the existing role tables. Every trunk layer must have its configured attention and feed-forward groups and its hyper-connections; configured shared experts, the embedding, the head and the final norm are required too. Configured NextN layers must have their latent attention, routed block, shared expert, input projection and input norms. NextN is validated but is not part of this trunk-only plan. The tensor-table API still accepts layer subsets.refsetfamilyhf-map-glm5nextandjust dump-ref-glm5next-hf-mapwrite the mapping oracle: the checkpoint's shard headers and small tensors beside the GGUF's tensor table and the same tensors. The family pins the checkpoint and GGUF revisions, the architecture and the writer's md5, and refuses by name a set of another revision, a changed file or an unfinished dump.just gate-glm5next-hf-maptakes no argument and opens the set through the family.placement::tp::plan_tptakes the tensors and one pool a rank and gives each rank's split and whole bytes. A part that is not whole units of the tensor's role (a head's rows), a part off the format's block, a rank past its pool, and two ranks on one device (a node that answers for this process's own card) are refused by name. The code takes any N; the tests run N = 1, 2, 3, 4 and 64.generate_glm5next --place tp --planreads the folderBLOOMERY_REF_MODELnames, plans rank 0 on this process's card and the other ranks on the nodesBLOOMERY_TP_NODESlists (each node'stier_serveranswers its census), and prints onetp rank=record a rank (record::TP_RANK, in the binary's--records-schema).BLOOMERY_TP_NODEStakes the tier node rules (an off-host node needsBLOOMERY_TIER_LINK=rdma) and is refused besideBLOOMERY_TIER_NODES, as areBLOOMERY_DRAFT=mtpand an empty node list.Existing paths: every other
--placeword parses as before, andPlace::onrefusestpfor every other binary. No GGUF load, plan or kernel changes.Release notes: Under the hood:
--place tp --planprints the tensor-parallel plan of GLM-5.3-Flash's Hugging Face checkpoint over N nodes; the load is not built yet.Code shape
The review reads these first. A box left unticked needs one line of why.
Format::held, and read the GGUF card type'sQRowwhere one exists. A rank's pool comes from the existing census throughunified_ofandnode_cards.glm5next::hfholds the checkpoint's names, layouts and the axis each tensor splits on; no common owner gained a per-model branch.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": none.What I ran
Head
09355ef647a9253f5d2a21890823059131e2a7b4on upstream main821d7b85abc11611a7a416be21407352e2ebba85. The first three commits are the shared baseda0786c473042a8e8197841b48bbd5bb680b48ff. The checks below ran on188006905955a1eb775b3e742a30ac1f84aabc9e.git range-diffbetween that head and this one shows every commit equal except the model commit, which moves one fixture,glm-5.3-flash-ud-q4_k_xl-layers-0-3.tsv, fromcrates/model/datatocrates/hf/tests/fixtures, and changes the one path inhf.rsthat reads it.The rank-byte reference is an independent count of the 42 shard headers of
nvidia/GLM-5.3-Flash-FP4-Localat revision76348ddb2be2e35e39ecfc00e75dc07703f4f3d5: the text trunk, block scales decoded to plain E4M3, BF16 as shipped andA_logas F32.--place tp --planon two DGX Sparks, the real folderweights=91600737016On a Linux x86_64 machine, the library tests,
cargo fmt --checkand clippy with-D warningson the touched crates ran on18800690:The library results were 256, 72, 42 and 4 passed, respectively, with no failures. Refset has three ignored tests. Format and clippy exited 0. Output:
r10-fixes.log, lines 715 to 918. On09355ef6, the lint and unit tier finished withDONE tier=t0 total=94 red=0(lint.log, line 101), and the GPU crates compiled in the DGX Spark container (gpu-check.log).The folder test writes a complete indexed safetensors folder with three trunk layers and one NextN layer. Its omission table covers an entire trunk layer, both attention kinds, dense and routed feed-forward groups, hyper-connections, shared experts, the embedding, head and final norm, and the NextN layer and its required groups and inputs. On
bb23c488, all 17 omissions returned successful rank plans on the original reader; the corrected entry refused each by tensor name, and seven malformed config rows were also refused. Output:r9-fixes.log, lines 168 to 206 and 463 to 493. The test can be run alone:cargo test -p bloomery-model --lib a_folder_requires_the_whole_configured_text_model -- --nocaptureThe pinned FP4-Local index also covered all required names in the production table on
bb23c488: 46 configured text layers including NextN, 1,368 required names and zero missing. This metadata-only check uses the real index's names and fixture shape templates, not model weights. Output:r9-fixes.log, lines 277 to 287. The two-node plan below is carried from47cb6318, because the index satisfies the same coverage check and the returned trunk tensors and byte rules are unchanged. NextN remains outside those byte totals.Mapping oracle gate
The oracle compares the Hugging Face NVFP4 export with the unsloth GLM-5.3-Flash UD-Q4_K_XL export. The gate computes the set of value tensors it must compare from the map and stops before comparing when the oracle lacks one of them, holds one the gate does not compare, or misses a layer from 0 to 44. Write the set and run the gate with:
The gate matched 1,383 names and dimensions, 212 F32 tensors and 180 BF16 tensors. The existing
ssm_aallowance covered 16 values one unit apart in the last place. Output:r10-fixes.log, lines 339 to 345. The writer'sgguf.safetensorshas the same md5,74c321a388fcf37a28520b29402cc055, as the earlier hand-made oracle, with 392 Hugging Face and 392 GGUF tensors. Output: the writer job's log, lines 110 to 121.The gate failed first on these changes. With the previous gate and a set without the 34
ssm_adecay tensors, the gate passed and compared nossm_avalue (lines 324 to 330). The fixed gate refused that set by tensor name, with exit 101 (lines 356 and 370). It also refused a set of another checkpoint revision (lines 372 to 394) and a set without its# completetrailer (lines 396 to 418), each with exit 101. ReplacingA_log'sNegExplayout withSamefailed the value comparison atblk.0.ssm_a, exit 101 (lines 431 and 447). All lines are inr10-fixes.log.Two DGX Sparks
On two DGX Sparks joined by their direct link, rank 1 ran
tier_server --listen <addr>:<port>and rank 0 ran:This ran on
47cb6318; the later commits do not change the folder reader's tensor accounting or the plan, and the--place tprecord is pinned by its test. The retained output is:The command exited 0. Without
--planit prints the named unbuilt-load error and exits 1. An unsetBLOOMERY_TP_NODESis refused by name.Comparison with the reference
The oracle is the Hugging Face export
nvidia/GLM-5.3-Flash-NVFP4at revisionda920bb0b9f4a06727223a349e55468e38352348, read against unsloth'sGLM-5.3-Flash-GGUFUD-Q4_K_XL at revisiona38483c8cd5df544f53d70fb281afe97369d5ab6. The refset familyhf-map-glm5nextpins both, and the writer'sgguf.safetensorshas md574c321a388fcf37a28520b29402cc055. Measured on18800690;09355ef6only moves a fixture (see above).ssm_avalues one unit apart in the last place, inside the existing allowance)Direct effect: with N = 2 each rank holds 91,600,737,016 B of weights, 50.5 % [derived] of the 181,433,466,872 B one rank holds alone, and both ranks on two DGX Sparks print the same figure. The end-to-end number this opens is GLM-5.3-Flash decode over two nodes, which this PR does not measure: the plan expects 23 to 31 tok/s at one request [derived], against 4.68 tok/s on main's expert tier.
What I ran into
--place tpwithout--planreturns the named unbuilt-load error. This does not block the capacity-only change.Hardware (if the change is for a machine)
Two DGX Sparks (GB10, 128 GB unified memory each) on a direct 200 Gb/s link, in the CUDA 13.3.1 container with
BLOOMERY_ARCH=sm_121. The unit tests and the mapping gate ran on a Linux x86_64 machine.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.