Skip to content

Living Weights for GLM-5.3-Flash (glm family) - #574

Closed
chadhurley25075-png wants to merge 3 commits into
ashhart:mainfrom
chadhurley25075-png:glm-living-weights
Closed

chadhurley25075-png wants to merge 3 commits into
ashhart:mainfrom
chadhurley25075-png:glm-living-weights

Conversation

@chadhurley25075-png

Copy link
Copy Markdown
Contributor

Living Weights for GLM-5.3-Flash (glm family)

For your consideration: not a finished feature, but a working starting point. It brings Living Weights to GLM-5.3-Flash on a single Mac, it runs end to end, and with no learned shard the engine is token-exact with stock. We're excited to see what you and the community do with it.

Branch glm-living-weights (3 commits on main 297ec2c, which includes 1.0.4).

What it adds

  • tensorfold serve <glm-5.3-flash folder> --slide learns into GLM-5.3-Flash on one Mac, through the same
    /v1/slide/learn API, lesson, gate, guard and undo as Nemotron. The learner reuses nemotron/choice.zig and
    subspace.zig unchanged; the trainer caches one GPU capture per example and runs the step past the site on the CPU.
  • One site: y += 10 (x a^T) b after layer 44's shared-expert down projection, in decode and prompt chunks, with the
    train.metal kernels Nemotron uses. Rank 0 encodes nothing.
  • The model's files are never written. Learned rows go to append-only living-NNNN.safetensors shards beside the model,
    listed in living_weights.index.json and summed in order at load. Dropping the newest entry undoes that lesson
    exactly. Each shard carries the site weight's sha256; a mismatch is refused. A lone living_weights.safetensors
    loads as shard 1. LW_TOPIC labels a save, LW_TOPICS=a,b loads only those.
  • A chat template that closes no assistant turn (GLM-5.3) now ends each lesson's answer with the next turn's first
    token, so learned answers stop.
  • Opt-in GLM_LOAD_LIMIT_GB and GLM_MLOCK so Flash (180.6 GB) loads on one 256 GB Mac.
  • zig build test-lw (host math, gradient vs finite differences, the learner end to end on a toy model) and sidecar
    tests in core; a section in docs/living-weights.md.

How to use

GLM_LOAD_LIMIT_GB=200 GLM_MLOCK=1 tensorfold serve ~/models/flash-copy --slide
curl -N http://127.0.0.1:8080/v1/slide/learn -H 'Content-Type: application/json' -d '{"text": "I like blue."}'

Measured (one M3 Ultra, 256 GB)

  • No shard: 20/20 greedy replies equal the stock engine token for token at draft depth 0 and 3; last-row logits
    byte-identical 20/20.
  • A 32-rank shard saved, then reloaded in a new process: tokens and logits equal the change in RAM, 20/20 at depth 0
    and 3. Decode 49.0–49.4 tok/s with it, 48.7–49.2 without. Depth 3 equals depth 0 with the change and with a gated
    open block (20/20).
  • A learn of "I like blue." runs end to end in about 7.5 minutes (59 GPU captures 45 s, CPU tail about 180 s, the rest
    is the model writing and checking its lesson). The model answers "You like blue".

Known limits

  • The guard has not yet let a GLM fact stay. The first run looped (fixed by the turn-end change above); the second was
    taken out because a held-out "which colour do you like best?" also answered "You like blue best": one site at the last
    layer did not separate the two.
  • Not tested: thinking-on recall, several facts at once, a pair (--slide --speed-up is refused).
  • macOS build and zig build test pass; zig fmt --check is clean on the changed files.

The full GLM-5.3 version is a separate PR stacked on #557.

Thank you for Sliding Weights. It is your engine and your design; please reshape or decline this as you see fit.

🤖 Generated with Claude Code

indexer-bf16 and others added 3 commits October 9, 2026 21:01
…ed-expert down, loaded from append-only shards

y += 10 (x a^T) b after the last layer's shared-expert down projection, in decode and prompt chunks, with the
train.metal kernels Nemotron uses (rank 0 encodes nothing). Learned rows live beside the model as
living-NNNN.safetensors listed in living_weights.index.json, summed in index order; each shard carries the site
weight's sha256 and a mismatch is refused. A lone living_weights.safetensors loads as shard 1. Dropping the newest
index entry undoes a lesson exactly. LW_TOPICS=a,b loads only those topics.

GLM_LOAD_LIMIT_GB and GLM_MLOCK (both opt-in) let Flash load on one 256 GB Mac.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…achinery over the one GLM site

The lane host's learn hook (glm_slide.zig) attached in glm_host as Nemotron's is in metal.zig. The learner reuses
Sliding Weights' lesson, subspace choice, gate, gated rounds, commit, mining and guard (nemotron/choice.zig and
subspace.zig unchanged), generic over its trainer. The Metal trainer caches one GPU capture per example (everything
before layer 44's MLP is independent of the change) and runs the tail past the site and its backward to b on the CPU,
exact through the last hyper-connection. Saves spawn a new shard holding only the new ranks.

A chat template that closes no assistant turn (GLM-5.3) now ends each lesson's answer with the next turn's first token,
so learned answers stop. --slide with --speed-up is refused.

zig build test-lw: the CPU tail and its gradient against finite differences, the learner's state machine end to end on
a host toy model, save rounding and undo; no GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…measured numbers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ashhart

ashhart commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thank you, @chadhurley25075-png. Getting a lesson to run end to end on GLM-5.3-Flash on one Mac, with the engine token-exact when no shard is loaded, took real work. The turn-end fix for templates that never close an assistant turn is a good catch too.

We can't take this one as it stands:

  • Living Weights is moving to changes written into the model's own shards. This PR keeps each lesson in side files with an index, which is the design we're leaving.
  • About half of glm/lw_learner.zig is nemotron/slide.zig line for line. Living Weights learns on CUDA (GB10): the training step, its kernels checked against float64 #591 makes the learner generic over a backend, and a GLM learner should build on that one.
  • core/living_sidecar.zig puts GLM-5.3-Flash's site name and sizes in core, and each of the five new environment switches (GLM_LW, GLM_MLOCK, GLM_LOAD_LIMIT_GB, LW_TOPIC, LW_TOPICS) would need to become the default or go.
  • Three files pass our 600-line limit (glm/engine.zig at 620, lw_learner.zig at 610, lw_math.zig at 718), and the lean check finds about 70 new problems in all.
  • As your notes say, the guard hasn't let a GLM fact stay yet, so there's no result to gate on.

The turn-end change in server/slide_lesson.zig is useful on its own. Please send it as a small PR with a host test and we'll land it. If you want to take GLM learning further, an issue first would let us agree on its gate, as CONTRIBUTING asks.

@ashhart ashhart closed this Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants