Repository navigation
GLM on CUDA: under TF_GLM_LAYERS the start-up memory check counts the tensors the load reads (#2745) - #2788
Merged
Conversation
wojo
added a commit
to wojo/TensorFold
that referenced
this pull request
Nov 10, 2026
wojo
force-pushed
the
up-thin-weights
branch
from
November 10, 2026 18:37
9febbcf to
d39d23f
Compare
Owner
|
Thanks @wojo, this follows the outline closely and reads well. What I checked at
The only conflict with main is the CHANGELOG line, which we'll sort out when it lands, so there's nothing for you to do there. Thanks for picking this up so quickly after #2745.
|
… tensors the load reads, not the files weightShare took the checkpoint's file bytes and scaled them by the rank's share, so a thin load (TF_GLM_LAYERS=20) was sized as the whole 163.6 GiB checkpoint. With TF_GLM_LAYERS=N it now counts, from the shard headers, the tensors under model.language_model. and lm_head. that the loader reads: layers below N, the MTP layers when drafts are on, and every tensor outside a layer. Unset, malformed, 0 or past the config's layers keep the files' count. weightShare gains the open's drafts flag; MiniMax M3 and Nemotron ignore it. Fixes ashhart#2745.
ashhart
force-pushed
the
up-thin-weights
branch
from
November 11, 2026 10:34
d39d23f to
54c98e5
Compare
ashhart
pushed a commit
that referenced
this pull request
Nov 11, 2026
Owner
|
Thank you @wojo. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
This was referenced Nov 11, 2026
Owner
|
Thanks @wojo! This is in TensorFold 1.2.7, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.7
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2745, as you outlined there: with
TF_GLM_LAYERS=N, GLM's start-up memory check counts by tensor from the shard headers, only what the loader reads. On main14dea6c6a, two commits, authored and committed with my noreply address, no trailers.What changes
zig/src/families/glm/cuda_thin_bytes.zig(new):countreturns the files'totalunless TF_GLM_LAYERS names a thin load; thenbytesopens the checkpoint undermodel.language_model.andlm_head.(the loader's two prefixes,cuda_weights.zigload) and sums the stored bytes of layers below N, the MTP layers (indexnum_hidden_layerson) when the load takes them, and every tensor outside a layer (embedding, norm, head). The tower, whichcuda_vision_offercounts on its own, is outside both prefixes.weightShare(zig/src/families/glm/cuda_native.zig:143) divides that count by the rank's share, as it divided the files before..mtp = o.drafts), soweightSharetakes the open'sdrafts: one argument added at its only caller,cuda_family_memory.weights. MiniMax M3 and Nemotron ignore it (each says why in a line).0or more than the config's layers: the count istotal, the files, exactly as before. The open still refuses a malformed value by name.Tests
test-glm-thin-weights-host(new step, in the GLM host set): a synthetic index over two shards (three layers, one MTP layer at index 3, a layer 10, the embedding, norm and head, and a tower tensor in the first shard):TF_GLM_LAYERS=2counts exactly the embedding, norm, head and layers 0-1; with drafts, the MTP layers as well;3adds layer 2; the tower never counts.countwith the variable unset,x,0or4(past the config's 3) returns the files' total unchanged.true).On the real checkpoint (GLM-5.3-Flash, 45 layers + 1 MTP, read from the headers): the files are 163.6 GiB;
TF_GLM_LAYERS=20counts 66.6 GiB without drafts and 70.4 GiB with them. The 20-layer thin copy we serve from (layers 0-19 and 45 linked from the full checkpoint, 71.7 GiB of files) gives the same two numbers.TP=2: the count is unchanged when TF_GLM_LAYERS is unset (the same
totalreaches the same share). With it set, the thin count is divided by the same share as the files were.Host
test-glm-thin-weights-host,test-glm-startup-host,test-glm-pages-host,test-glm-tp3-host,test-goldenandtest-cuda-host(5,941 of 5,977, 36 skipped; main's image-route fixture fix makes it complete on macOS now) all pass.fmtclean,cuda_fragment_checkclean, lean 386 vs 386 on the base (0 new),tools/pr_check.py: 0 errors.aarch64-linux-gnunative build at both commits.No device run: the change is in the admission arithmetic before any GPU work, and the header counts above are from the real checkpoint.
🤖 Generated with Claude Code