Repository navigation
Living Weights for the full GLM-5.3 (glm53 family) - #575
chadhurley25075-png wants to merge 4 commits into
Conversation
A new family, tf-glm53, for the full GLM-5.3 (GlmMoeDsaForCausalLM: 78 layers, 256 routed experts top-8, DSA sparse attention with index_topk 2048, the layer-78 MTP head). Each rank holds a share of every layer's heads, expert rows and vocabulary; fp32 partials are exchanged over MCDMA inside the command buffer and summed in slot order, so N Macs give the bits one Mac gives with N canonical slices. - fp32 activations end to end (the checkpoint's F16 scales promote mlx-lm's matmuls to fp32, so that is the reference); MLX-arithmetic 6/8-bit row kernels, simdgroup tiles for prompt blocks, split-K short matvecs; fp16 KV option. - The DSA indexer at fp32 over BF16 weights, scores with the query staged once a span of keys (G53_IDX=3: two rows a threadgroup), radix top-k over many threadgroups for decode-sized blocks; sparse latent attention (G53_ATTN4H, G53_JOINB). - MTP self-speculative decode from the layer-78 head with verify blocks on the row path, and copy drafts (G53_COPY), both verified by the trunk: the same tokens. - N-rank exchange: per-peer send threads, a stall diagnostic (G53_STALL_S) and fenced pieces for large partials (G53_XCHUNK; MCDMA Endpoint.flushPeer), because the Thunderbolt link dropped an overflowing partial without an error. - Exact speed switches: concurrent encoder (G53_CONC), the wait inside the sum launch (G53_FWAIT), shared weight reads for bf16 row matvecs (G53_GROWS), key-split decode indexer (G53_KSPLIT), own-row prompt indexer (G53_OWN_FRONT), KV residency and touch after a snapshot load (G53_KV_RESIDENT, G53_TOUCH). - Layer-split latent cache (G53_LSPLIT, _OWNER, _FROM): past a chosen position each layer's latent cache and attention live on one rank, so a 512 GB owner beside three 256 GB Macs takes the cap from about 2.0M to 3.1M positions with the same replies. - Serve mode (JSON lines over TCP, cancel/stop_at, KV snapshots), oracle mode against an mlx-lm dump, tf-glm53-ixbench, and tools: the MLA absorb pack, the MTP head converters, a synthetic checkpoint. The copy index's unit tests join zig build test. Every switch is off by default and leaves replies character-identical when on. Measured on four M3 Ultra Mac Studios (256/512/256/256 GB) over Thunderbolt 5; not measured on M5. Built on Ash Hart's TensorFold and MCDMA (kernel conventions, the exchange, the copy rounds' acceptance rule). The own-row prompt indexer follows MiaAI-Lab's prompt sequence-parallel select and drowzeys' TF_GLM53_SP_SELECT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit c09e1be)
…ab-split learning step, CPU tests The change is y += 10 (x a^T) b after layers.77's shared-expert down projection (in 2048, out 6144). Learned rows live in append-only living-NNNN.safetensors shards listed in living_weights.index.json (a lone living_weights.safetensors loads as shard 1), each with the site weight's sha256. The step past the site is split by the head's vocabulary rows: each rank's part of the log-sum-exp and of W^T g, summed across ranks. The learner state machine, Sites and the shared CPU math are the GLM-5.3-Flash learner's files (families/glm/lw_*.zig), identical to that PR's. zig build test-glm53-lw: format round trip, shards and rollback, a simulated 4-rank split against one rank, the served apply's reference; no GPU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…acs through the exchange The committed change is applied at layer 77's shared expert per canonical slice (two kernels in kernels.metal); rank 0 of the change encodes nothing, so a run without "lw" is the stock forward. With "slide", learn lines give every rank the same lesson; each runs the same learner in lockstep on scratch-engine captures and sums its vocab parts through the exchange. Learning never touches the KV caches. Every rank must load the same change (its tag is in the start word), and an exchange number is never reused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thank you, @chadhurley25075-png. Learning in lockstep across four Macs, with every rank saving a byte-identical shard, is neat work, and catching the reused exchange sequence number was a good find. This PR starts from #557's code unchanged, so the reasons we gave there still apply: its own server ( The path from #557 stands: GLM-5.3's indexer and sparse latent attention as a family on the lane host, checked on one Mac with a layer subset. Learning for glm53 would then follow on the shared learner. |
Living Weights for the full GLM-5.3 (
glm53family)For your consideration: not a finished feature, but a working starting point that has learned real facts on the full GLM-5.3 across four Macs. We're excited to see what you and the community do with it.
Branch
glm53-living-weights, 3 commits stacked on #557 (f90dc25, #557 rebased onto 1.0.3).What it adds
"lw": pathserves a learned low-rank change after layer 77's shared-expert down projection on every rank;"slide": truealso takes{"learn": ...}/{"learn_step": k}lines. Without"lw"the engine is the stock one.and the parts are summed through the exchange. Captures come from a scratch engine; the KV caches are never touched.
living-NNNN.safetensors+living_weights.index.json, sha256 of thesite weight per shard, drop the newest to undo). Every rank must load the same change before serving.
families/glm/lw_learner.zig,lw_math.zig,lw_sites.zig, identical), sowhichever lands first, the other drops them.
zig build test-glm53-lw: format, shards and rollback, a simulated 4-rank split against one rank, the served apply'sreference. A section in
docs/recipes/glm-5.3.md.How to use
Add to every rank's settings:
"lw": "<folder>/living_weights.index.json"(or aliving_weights.safetensorspath),and
"slide": trueto learn. Then send every rank the same lesson line, for example{"learn": {"train": [...], "held": [...], "steps": 400, "commit": true, "save": true}}, followed by{"learn_step": k}lines.Measured (4 × M3 Ultra)
53.9 tok/s.
were unchanged on every step, and replies did not change before the commit.
bit-identical; the seventh (who wrote Romeo and Juliet) was reworded and still correct.
the strict
recalledcheck true, no repetition, neighbours' facts intact; it answers with the full date (measured on thebuild this branch was cleaned up from).
different shards. Fixed in this branch; a reused number is now refused.
Known limits
strict
recalledcheck (every answer token p > 0.5) is false. Recall with thinking on is not there yet: the lessonstrain the no-thinking form, and GLM-5.3 reasons its way past the fact. Thinking-mode lesson copies are the next step.
zig build testpass;zig fmt --checkis clean on the changed files.Thank you for the engine and the learner this is built on; please reshape or decline as you see fit.
🤖 Generated with Claude Code