Skip to content

glm metal: one arithmetic order for prompt windows, chunks and decode on M1-M4 (#743) - #2128

Draft
ashhart wants to merge 2 commits into
mainfrom
lead/s234-glm-order
Draft

ashhart wants to merge 2 commits into
mainfrom
lead/s234-glm-order

Conversation

@ashhart

@ashhart ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Draft until its gates have run on an M3 Ultra. Refs #743.

GLM's pre-M5 prompt windows and chunks choose different projection and KDA sums, so changing a prompt's cuts can change greedy tokens (#743). This selects one standalone dense projection and KDA encoder for single-Mac Metal before the M5, and keeps MLA and both expert paths on their existing window operators at every cut. It accounts for the extra recurrence scratch before admission and includes the arithmetic policy in saved-state identity.

Plain and drafted replies from either older prompt mode may change once, including image turns. M5, paired-Mac and CUDA GLM retain their existing arithmetic. The shared SIMD input pitch defaults to contiguous addressing for existing callers. The changelog and native arithmetic note describe that scope.

Validation: actual dispatch recording tests and independent FP64 recurrence controls; caught/restored stride and stale-state faults; GLM window/kernel-contract tests; actual engine and device-gate compilation without Metal execution; plain Linux build; zero new lean findings. Two additional GLM scheduling/restore host targets fail with a missing core import on both this tree and the supplied base.

Device qualification is pending. The new model-free gate checks FP64 dense classes, projection cuts 1..17/33/2048, KDA state/tail bytes and partial replay, plus FP64 scan/post references at captured points. M1/M2 compiled resource limits, nonlinear prep, reporter-prompt equality, independent model fidelity, draft/resume/concurrency, memory and speed remain unqualified. Decode must not be slower; bounded MLA/MoE prompt work is a specific speed risk to measure. A 40-layer run diagnoses the executed prefix, not the full model's replies, fidelity, MTP acceptance, memory fit or speed.

@ashhart

ashhart commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

The model-free gate ran on an M3 Ultra at this head (e8ea6a6d3), with no model loaded:

  • tf-glm-ordered-check: passed.
    • Every dense class is exact across prompt cuts 1–17, 33 and 2,048, and within its FP64 bound. That covers MLA o_proj q6/q8, dense and shared gate/up and down at their widths, routed q2/q4, lm_head q4/q8, and the narrow scalar boundary at q2–q8.
    • The worst error is 0.874 of its bound (shared down q8). The rest are 0.39–0.87.
    • KDA: cuts 1/2/3/4/8/16/17/33 give identical Y, FP32 state and convolution tail. Partial replay and the FP64 scan/post references pass.
  • Kernel contract and host tests (test-kernel-contract test-glm-window-contract-host test-glm-ordered-host): 25/25 steps, 193/193 tests.

Still to do before this leaves draft:

  • A rebase onto main. core/contract/registry.zig conflicts in code, and the build file is ours to settle.
  • The model cells: Proposal: restore single-Mac GLM-5.3-Flash on the M3 Ultra #743's reporter prompts with tokens equal across prompt cuts; drafted, resumed and concurrent equal; decode not slower; the memory fit. These need a GLM checkpoint on the M3 Ultra, which isn't there yet.

Use shared SIMD projection strides and the chunk KDA recurrence for
single-Mac pre-M5 runs. Keep MLA and expert operations on their window
paths at every prompt cut, account for recurrence scratch before
admission, and include the policy in saved-state identity.

Add recording and independent FP64 reference gates, a model-free device
check, resource declarations and the reply compatibility note.

Refs #743.

This branch has not been deployed

No deployments
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.

1 participant