Skip to content

glm(metal): gate in-memory 4-bit/64 MTP draft head on GLM_DRAFT_HEAD_Q4 - #4253

Open
gilby wants to merge 1 commit into
ashhart:mainfrom
gilby:glm-metal-draft-head-q4
Open

gilby wants to merge 1 commit into
ashhart:mainfrom
gilby:glm-metal-draft-head-q4

Conversation

@gilby

@gilby gilby commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Gates in-memory 4-bit/64 MTP draft-head synthesis (zig/src/families/glm/draft_head_q4.zig, called from zig/src/families/glm/engine.zig) behind an opt-in environment switch, GLM_DRAFT_HEAD_Q4 (default 0 / unset / blank off; malformed values fail closed naming GLM_DRAFT_HEAD_Q4), and skips synthesis whenever --drafter (DFlash2) is set (zig/src/native/glm_host.zig).

  • Default (GLM_DRAFT_HEAD_Q4 unset, blank, or 0, or whenever --drafter is set): No draft head is synthesized (+0 bytes, zero extra load time, identical weights, drafts, and replies to main).

  • Opt-in (GLM_DRAFT_HEAD_Q4=1 without --drafter, tp == 1, w.mtp != null, w.draft_head == null, and used + need <= limit): Quantizes an 8-bit/64 lm_head once at load into an in-memory 4-bit/64 w.draft_head (356,843,520 B shared buffer at [154880, 4096]).

  • Precision & exactness: Target verification continues to read the unmodified 8-bit/64 lm_head, so verified replies keep main's exact tokens ("draft": false, greedy and seeded); however, under GLM_DRAFT_HEAD_Q4=1, the MTP draft_head itself is re-quantized from 8 to 4 bits, so draft logits and draft proposals change (moving MTP acceptance and drafted token counts).

  • Which workloads GLM_DRAFT_HEAD_Q4=1 helps (and where to leave it off):

    • Helps: Workloads on single-Mac checkpoints with an 8-bit/64 lm_head and no stored draft_head (such as GLM-5.3-Flash-oQ4e-mtp-oq071) where the 4-bit draft head shortens draft projection without increasing rejected drafts: on Apple M5 Ultra (512 GiB, --parallel 3 --context 131072), 7 of 8 bench_concurrent.py cells speed up (+0.35% to +3.02% aggregate, +0.67% to +2.60% steady, including code T=0 N=3 +2.32%, chat T=0 N=1 +1.40%, chat T=0 N=3 +2.49%, chat T=1.0 N=1 +3.02%), and earlier single-stream bench_openai.py runs speed up +1.94% to +3.52%.
    • Leave off (default 0): Prompts/workloads where 4-bit draft logits shift MTP/copy proposals toward lower acceptance or wider verify rounds (code T=0 N=1 on the 512 GiB M5 Ultra --context 131072 run shifted from 149/166 to 152/206 accepted/drafted tokens, -3.88%, and earlier M5 Ultra 256 GiB bench_concurrent.py T=1.0 sampled cells moved -1.25% to -2.95%), as well as --drafter (DFlash2) runs (automatically skipped) and uniform 4-bit/64 checkpoints (GLM-5.3-Flash-MLX-4bit-MTP, already a no-op).
  • Issue: Refs GLM-5.3-Flash on Metal: decode and prompt speed on M5 Ultra, token-exact (baseline, items and gate) #3152

  • Stacked on: main (0652b7907b847786c53bc44b04a43c16a8dcf547)

Checks on this head

  • Head commit: adcc166af2a073385ecc83a04121dd3627387e3d (rebased onto main 0652b7907b847786c53bc44b04a43c16a8dcf547)
  • Lean checker (python3 tools/zig/lean_check.py / tools/zig/lean_new.py): 165 on base (0652b7907b), 165 on head (adcc166af2), 0 new findings (python3 tools/pr_check.py --pr 4253 --base origin/main exits 0 with 0 errors; every touched .zig file <= 600 lines: draft_head_q4.zig 239, engine.zig 586, glm.zig 99, glm_host.zig 289, environment.zig 596, environment_test.zig 585).
  • Overlap check: atc overlap --json (7 changed files).
  • Host, native, and golden suites run on adcc166af2 (Zig 0.17.0, -Dcpu=apple_m1):
    • zig fmt --check build.zig zig — passed (0 exit)
    • git diff --check origin/main..HEAD — passed (0 exit)
    • zig build test-glm-disk-charge-host test-drafter-skip-metal-host test-glm-metal-dflash-host test-environment-host test-env-defaults-host test-shared-head-cost-metal-host -Dcpu=apple_m1 --summary all — 69/69 steps succeeded; 396/399 tests passed (3 skipped) (test-glm-disk-charge-host 64/64, test-drafter-skip-metal-host 71/71, test-glm-metal-dflash-host 15/15, test-environment-host 32/32, test-env-defaults-host 43 pass / 3 skip + 102/102, test-shared-head-cost-metal-host 69/69)
    • zig build test-native -Dcpu=apple_m1 --summary all — 68/68 steps succeeded; 183/186 tests passed (3 skipped; includes draft_head_q4.zig unit tests)
    • zig build test-golden -Dcpu=apple_m1 --summary all — 5/5 steps succeeded (69/69 + 327/340 equal, 0 unexpected differences)
  • Earlier 97c77cd6e2 live --drafter smoke checks on GLM-5.3-Flash-oQ4e-mtp-oq071 + --drafter GLM-5.3-Flash-DFlash2 (--context 4096 --prompt-cache-gib 0): GLM_DRAFT_HEAD_Q4=0 vs GLM_DRAFT_HEAD_Q4=1 both loaded 184.7 GB target weights (192,776,757,016 B vs 192,775,233,424 B footprint; draft_head_q4 skipped), identical 64-token greedy reply sha256.
  • Not run, and why: live M1/M2/M3/M4 runs; CUDA/ROCm paths (Metal single-Mac draft_head_q4 load path).

Receipt

Rebased head (adcc166af2) on Apple M5 Ultra (512 GiB, macOS 27.2.1, Zig 0.17.0, ReleaseFast)

  • Command & server flags: GLM-5.3-Flash-oQ4e-mtp-oq071 (8-bit/64 lm_head + native MTP, without --drafter), --parallel 3 --context 131072 --prompt-cache-gib 0 --profile stable --no-update-check --port 18091; tools/bench_concurrent.py --alone --serial --tokens 256 --reps 3 --temperatures 0,1.0 --levels 1,3 --seed 1234, alternating A-B-B-A (r1_base -> r2_q4 -> r3_q4 -> r4_base), pmset -g therm clean (No thermal warning / No performance warning) before and after every run.
  • Startup refusal (GLM_DRAFT_HEAD_Q4=yes): exits 1 with tensorfold: GLM_DRAFT_HEAD_Q4="yes": expected 0 or 1 (1 quantizes an 8-bit/64 GLM lm_head into an in-memory 4-bit/64 MTP draft head at load).
  • Memory footprint (/usr/bin/time -l) & default parity:
    • r1_base / r4_base (origin/main 0652b7907b): 184.7 GB weights; MaxRSS 191,478,136,832 B / 191,473,451,008 B (mean 191,475,793,920 B), peak footprint 191,869,788,240 B / 191,865,053,096 B (mean 191,867,420,668 B).
    • r5_cand_unset (adcc166af2, GLM_DRAFT_HEAD_Q4 unset): 184.7 GB weights; MaxRSS 191,473,680,384 B, peak footprint 191,865,282,376 B (+0 weight bytes vs main).
    • r2_q4 / r3_q4 (adcc166af2, GLM_DRAFT_HEAD_Q4=1): 185.1 GB weights; MaxRSS 191,831,703,552 B / 191,831,539,712 B (mean 191,831,621,632 B, +355,827,712 B / +355.8 MB), peak footprint 192,223,502,392 B / 192,223,404,232 B (mean 192,223,453,312 B, +356,032,644 B / +356.0 MB).
  • Exactness (drafted == plain == main, greedy & seeded):
    • Across all 4 A-B-B-A runs: 0 failed, 0 unmeasured, timing_valid=True, 48/48 --alone equal (0 unequal, 0 failed, non-vacuous at N=3) and 16/16 --serial ("draft": false) equal (0 unequal, 0 failed, plain_drafted=0, non-vacuous MTP drafts accepted on every cell) per run.
    • r5_cand_unset (1 rep): 16/16 --alone equal, 16/16 --serial equal, 0 failed.
    • Cross-binary token_sha256 parity: 100% bit-identical across r1_base (origin/main), r4_base (origin/main), r5_cand_unset (adcc166af2 unset), r2_q4 (Q4=1), r3_q4 (Q4=1), --alone, and --serial ("draft": false) at both T=0 (code 7cd4ab7084c3..., chat 20acae32b5d8...) and T=1.0 seeds 1234..1236 (code 378ce72fdd3b..., 5f649fe4146c..., 9c2be42968b6...; chat 1fd198720049..., 346536bbcc9a..., 99673f09fb34...).
  • Speed (aggregate_tps / steady_tps, A-B-B-A means of 3-rep cell medians):
Cell main (r1, r4) main mean Q4=1 (r2, r3) Q4=1 mean Diff main steady Q4=1 steady Steady diff
code T=0.0 N=1 86.7, 86.2 86.45 83.0, 83.2 83.10 -3.88% — — —
code T=0.0 N=3 148.8, 148.8 148.80 151.3, 153.2 152.25 +2.32% 151.70 155.30 +2.37%
chat T=0.0 N=1 71.3, 71.2 71.25 72.2, 72.3 72.25 +1.40% — — —
chat T=0.0 N=3 132.2, 133.0 132.60 135.8, 136.0 135.90 +2.49% 138.50 142.10 +2.60%
code T=1.0 N=1 81.0, 80.5 80.75 81.2, 81.4 81.30 +0.68% — — —
code T=1.0 N=3 102.6, 103.9 103.25 104.5, 105.8 105.15 +1.84% 107.10 109.35 +2.10%
chat T=1.0 N=1 68.0, 67.9 67.95 69.9, 70.1 70.00 +3.02% — — —
chat T=1.0 N=3 100.4, 99.7 100.05 101.0, 99.8 100.40 +0.35% 104.45 105.15 +0.67%
  • Uniform 4-bit/64 checkpoint no-op (GLM-5.3-Flash-MLX-4bit-MTP, --tokens 64 --reps 1 --levels 1): GLM_DRAFT_HEAD_Q4 unset vs GLM_DRAFT_HEAD_Q4=1 both loaded 180.6 GB weights (MaxRSS 187,392,032,768 B vs 187,390,459,904 B, peak footprint 187,734,791,248 B vs 187,733,218,432 B), 4/4 --alone and 4/4 --serial equal, 0 failed, bit-identical token_sha256 across unset, Q4=1, and "draft": false.

(Earlier d6fb847706 / 97c77cd6e2 Apple M5 Ultra 256 GiB receipts: https://gist.github.com/gilby/eb56bbd461a97cd6f4293cd56062004f)

  • Boxes it reaches: glm5_next on Metal when GLM_DRAFT_HEAD_Q4=1 is set, --drafter is not set, an 8/64 lm_head and MTP layer are present, tp == 1, no stored draft_head exists, and memory budget fits (~0.36 GB shared buffer); complete no-op by default (GLM_DRAFT_HEAD_Q4 unset/blank/0), with --drafter, on 4/64 checkpoints (GLM-5.3-Flash-MLX-4bit-MTP), or when tight against limit.
  • New switch? Default, accepted values, profile row: GLM_DRAFT_HEAD_Q4 (.scope = .metal, .kind = .flag in zig/src/platform/environment.zig, documented in docs/environment.md); accepted values 0 or 1 (unset or blank is 0, malformed values refused by name); no profile row change (stays 0 across profiles).
  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision:
    • TensorFold commit: adcc166af2a073385ecc83a04121dd3627387e3d atop main 0652b7907b847786c53bc44b04a43c16a8dcf547
    • Toolchain: Zig 0.17.0 (-Dcpu=apple_m1 -Doptimize=ReleaseFast), macOS Metal (macOS 27.2.1)
    • Machine / GPU: Apple M5 Ultra (512 GiB, applegpu_g17, unified memory, tensor units true)
    • Checkpoints: GLM-5.3-Flash-oQ4e-mtp-oq071 (8/64 lm_head + MTP), TensorFold/GLM-5.3-Flash-MLX-4bit-MTP (uniform 4/64)
  • Paths and platforms the change reaches, which I ran and which I could not:
    • Ran: macOS Apple M5 Ultra (512 GiB) single-Mac oq071 (origin/main, GLM_DRAFT_HEAD_Q4 unset, GLM_DRAFT_HEAD_Q4=1, GLM_DRAFT_HEAD_Q4=yes refusal), GLM-5.3-Flash-MLX-4bit-MTP (4/64 no-op), host/native/golden tests; earlier 97c77cd6e2 --drafter skip check on GLM-5.3-Flash-DFlash2.
    • Could not run: live M1/M2/M3/M4 silicon, CUDA/ROCm (CUDA uses its own cuda_mtp_load.zig).
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false:
    • Default GLM_DRAFT_HEAD_Q4=0/unset changes no weights or sums (r5_cand_unset matches origin/main in weights and token_sha256).
    • Under opt-in GLM_DRAFT_HEAD_Q4=1, the MTP draft_head is re-quantized from 8-bit/64 to 4-bit/64 (so draft logits and draft proposals change), while target verification still reads the 8-bit/64 lm_head: bench_concurrent.py --alone --serial recorded 0 unequal and 0 failed across all alone (48/48 per run) and serial (16/16 per run) checks, with 100% cross-binary token_sha256 match against origin/main and "draft": false at both T=0 and T=1.0.
  • Main against this branch, same machine and checkpoint, posted before asking for a run on our machines (or why you can't): Yes — alternating A-B-B-A device receipt above.
  • Decode speed before and after: default 0/unset is identical to main; opt-in GLM_DRAFT_HEAD_Q4=1 on GLM-5.3-Flash-oQ4e-mtp-oq071 (--parallel 3 --context 131072) speeds up 7 of 8 cells (+0.35% to +3.02%, steady +0.67% to +2.60%) while shifting code T=0.0 N=1 by -3.88% (152/206 vs 149/166 accepted/drafted tokens).
  • Prompt speed before and after: unchanged (prompt_ttft_tps ~164.4–165.4 on code, 258.8–260.4 on chat; draft LM head runs only during MTP drafting).
  • Licence of any new weights or drafter, or "n/a": n/a.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed. If the bits change, the description says which sums change and why. (Default GLM_DRAFT_HEAD_Q4=0 changes no bits. When opted into GLM_DRAFT_HEAD_Q4=1, the MTP draft_head itself is re-quantized in memory from 8-bit/64 to 4-bit/64, so MTP draft logits and draft proposals change while target verification keeps the 8-bit/64 lm_head and verified replies stay exact.)
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled (Default GLM_DRAFT_HEAD_Q4=0 and --drafter runs match main; opt-in GLM_DRAFT_HEAD_Q4=1 shifts draft proposals and can slow specific cells such as code T=0.0 N=1 -3.88% or earlier T=1.0 sampled cells, which is why the switch stays off by default.)

@AIFlowML

Copy link
Copy Markdown
Contributor

At d6fb8477 on M5 Max with Zig 0.17.0, I ran the existing draft_head_q4.zig test by adding a scratch build step on the Metal engine module with filter quantizeGroups packs 4-bit codes. zig build test-glm-draft-head-review -Dcpu=apple_m1 -Doptimize=ReleaseSafe -j3 --summary all passed 60/60.

I repeated the call to maybeMake in that fixture after the exact-budget allocation, and checked that draft_head.w.addr(), Weights.bytes and the backing buffer count all stayed the same. The scratch rerun also passed 60/60. This covers reuse of an existing synthesized head on the Metal device.

A trial merge with 46c6ee22 was clean. Pairing this head with #4254 conflicts in glm.zig. If they ride together, the useful served cell is an 8-bit/64 checkpoint that creates the synthetic head and then exercises #4254's greedy path, with token hashes against drafts off. I ran the allocation fixture without loading a full checkpoint.

Igor Lessio - AIFLOW LABS

@ashhart

ashhart commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Thanks @gilby. Building the draft head once at load is a neat idea, and target verification still reads the 8-bit lm_head, so replies keep main's tokens. Three things before we run it:

  1. It runs on every GLM load that has an MTP head, with no switch. It costs about 357 MB and some load time even when the drafter isn't used: on current main, --drafter (DFlash2) bypasses MTP and would leave the synthesized head unused. Please put it behind an opt-in switch, off by default, and skip it when --drafter is set.
  2. Your own table shows it slower in three of the four sampled cells: code T=1.0 N=1 91.3 → 90.0 (-1.4%), code T=1.0 N=3 104.3 → 103.0 (-1.2%) and chat T=1.0 N=3 108.5 → 105.3 (-2.9%). The 4-bit head changes the drafts, so acceptance moves. We can't take a default that is slower anywhere. As an opt-in, please say in the description which workloads it helps.
  3. The checklist says "No precision traded for speed". The draft head itself is re-quantized from 8 to 4 bits, so please describe it that way: the replies stay exact, but the drafts don't.

We'll handle the rebase onto current main (a conflict in glm.zig with the DFlash2 test imports) when you push the switch.

  • Synthena

@gilby
gilby force-pushed the glm-metal-draft-head-q4 branch from d6fb847 to 97c77cd Compare November 21, 2026 21:00
@gilby gilby changed the title glm(metal): synthesize 4-bit/64 draft LM head from 8-bit lm_head for MTP glm(metal): gate in-memory 4-bit/64 MTP draft head on GLM_DRAFT_HEAD_Q4 Nov 21, 2026
@gilby

gilby commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @ashhart (and @AIFlowML for the allocation-reuse check). Addressed all three items and rebased onto current main (127230b4b0) at 97c77cd6e2:

  1. Opt-in switch + --drafter skip: Added GLM_DRAFT_HEAD_Q4 (0 or 1; unset, blank, or 0 is off by default; malformed values fail closed naming GLM_DRAFT_HEAD_Q4) in zig/src/platform/environment.zig, zig/src/platform/environment_test.zig, and docs/environment.md, and wired drafter != null from glm_host.open into Engine.loadWith so synthesis is skipped whenever --drafter (DFlash2) is set.
  2. Workloads documented: Updated the PR description to state where GLM_DRAFT_HEAD_Q4=1 helps — greedy (T=0) single-stream and multi-stream MTP decoding (+1.10% to +2.45%) and single-stream bench_openai.py runs (+1.94% to +3.52%) on checkpoints with an 8-bit/64 lm_head and no stored draft_head — versus concurrent sampled (T=1.0) bench_concurrent.py cells (-1.25% to -2.95%), where 4-bit draft logits shift MTP acceptance, which is why it stays off by default.
  3. Precision / checklist wording: Updated the description and checklist to state explicitly that under GLM_DRAFT_HEAD_Q4=1 the MTP draft_head itself is re-quantized from 8-bit/64 to 4-bit/64 (so drafts change, while target verification reads the 8-bit/64 lm_head and verified replies stay exact).

Verification on 97c77cd6e2:

  • zig fmt --check build.zig zig and python3 tools/pr_check.py --base origin/main --pr 4253 (0 errors, 165 vs 165 lean findings).
  • test-environment-host (31/31), test-env-defaults-host (42/45 + 96/96), test-glm-metal-dflash-host (15/15), test-native (161 pass / 3 skip), test-kernel-contract, test-golden (69/69), and draft_head_q4.zig unit tests (62/62).
  • Served checks on GLM-5.3-Flash-oQ4e-mtp-oq071 (--context 4096 --prompt-cache-gib 0):
    • GLM_DRAFT_HEAD_Q4=yes refuses at startup naming GLM_DRAFT_HEAD_Q4="yes".
    • Default (GLM_DRAFT_HEAD_Q4 unset): 184.7 GB weights (190,868,200,712 B footprint), greedy reply sha256 matches "draft": false.
    • GLM_DRAFT_HEAD_Q4=1: 185.1 GB weights (191,222,455,728 B footprint, +354.3 MB), identical greedy reply sha256.
    • GLM_DRAFT_HEAD_Q4=1 + --drafter (GLM-5.3-Flash-DFlash2): 184.7 GB target weights (192,775,233,424 B vs 192,776,757,016 B at GLM_DRAFT_HEAD_Q4=0), confirming draft_head_q4 synthesis is skipped with DFlash2.

@AIFlowML

Copy link
Copy Markdown
Contributor

I checked revised head 97c77cd6e in a clean trial merge into main 2ce240cf0 on M5 Max (macOS 27.2, Zig 0.17.0). git diff --cached --check passed.

zig build test-glm-disk-charge-host test-drafter-skip-metal-host test-glm-metal-dflash-host test-environment-host -Dcpu=apple_m1 -j4 --summary all passed 177 tests with one failure. The first three targets passed all 62, 69 and 15 tests respectively. This includes the revised check for default-off behavior, malformed-value refusal, and skipping synthesis with an external drafter. The only failure was the Flash Next inventory expecting 24 switches and finding 25, which I reproduced with the same environment target on main.

The full-checkpoint memory and timing figures remain the author’s measurements.

Igor Lessio - AIFLOW LABS

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks @gilby. The revised switch is off by default, skips synthesis with DFlash2, and documents both the sampled slowdowns and the changed draft precision. That addresses all three earlier requests, and the posted checks support the default and skip behavior.

The 4-bit head built from the loaded 8-bit head only proposes drafts: the target still verifies every drafted token, so replies stay equal to plain decoding and only acceptance and speed change. That fits our rule. What remains is the device comparison on a GLM checkpoint: drafted replies equal to plain ones with the switch on, greedy and seeded, and the speed effect at one and several streams.

  • Synthena

Quantizes an 8-bit/64 GLM lm_head into an in-memory 4-bit/64 MTP draft head
at load only when GLM_DRAFT_HEAD_Q4=1, --drafter is not set, tp == 1, and
memory budget allows; unset, blank or 0 stays off and malformed values fail
closed.

Refs ashhart#3152
@gilby
gilby force-pushed the glm-metal-draft-head-q4 branch from 97c77cd to adcc166 Compare November 24, 2026 22:12
@gilby

gilby commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto main (0652b7907b) at adcc166af2 and ran the requested Apple M5 Ultra (512 GiB, macOS 27.2.1, Zig 0.17.0 -Dcpu=apple_m1 -Doptimize=ReleaseFast) device comparison on GLM-5.3-Flash-oQ4e-mtp-oq071 (an 8-bit/64 lm_head + native MTP checkpoint without --drafter) alongside GLM-5.3-Flash-MLX-4bit-MTP (4-bit/64 no-op check) and host/native/golden checks.

1. Rebase & checks on adcc166af2

  • zig fmt --check build.zig zig — passed (0 exit)
  • git diff --check origin/main..HEAD — passed (0 exit)
  • python3 tools/zig/lean_check.py / tools/zig/lean_new.py — 165 on base (0652b7907b), 165 on head (adcc166af2), 0 new findings
  • python3 tools/pr_check.py --pr 4253 --base origin/main — 0 errors (1 advisory CHANGELOG.md warning); all touched .zig files <= 600 lines (draft_head_q4.zig 239, engine.zig 586, glm.zig 99, glm_host.zig 289, environment.zig 596, environment_test.zig 585)
  • atc overlap --json — 7 changed files
  • zig build test-glm-disk-charge-host test-drafter-skip-metal-host test-glm-metal-dflash-host test-environment-host test-env-defaults-host test-shared-head-cost-metal-host -Dcpu=apple_m1 --summary all — 69/69 steps succeeded; 396/399 passed (3 skipped)
  • zig build test-native -Dcpu=apple_m1 --summary all — 68/68 steps succeeded; 183/186 passed (3 skipped; includes draft_head_q4.zig unit tests)
  • zig build test-golden -Dcpu=apple_m1 --summary all — 5/5 steps succeeded (69/69 + 327/340 equal, 0 unexpected differences)

2. Device comparison on Apple M5 Ultra (512 GiB)

Server flags: --parallel 3 --context 131072 --prompt-cache-gib 0 --profile stable --no-update-check --port 18091 on GLM-5.3-Flash-oQ4e-mtp-oq071 (without --drafter).
Benchmark: tools/bench_concurrent.py --alone --serial --tokens 256 --reps 3 --temperatures 0,1.0 --levels 1,3 --seed 1234, alternating A-B-B-A (r1_base -> r2_q4 -> r3_q4 -> r4_base), plus r5_cand_unset (adcc166af2 with GLM_DRAFT_HEAD_Q4 unset, 1 rep) and GLM-5.3-Flash-MLX-4bit-MTP (1 rep, 64 tokens, N=1). pmset -g therm recorded no thermal or performance warning before/after every run.

Memory (/usr/bin/time -l), default parity & refusal

  • GLM_DRAFT_HEAD_Q4=yes: exits 1 with tensorfold: GLM_DRAFT_HEAD_Q4="yes": expected 0 or 1 (1 quantizes an 8-bit/64 GLM lm_head into an in-memory 4-bit/64 MTP draft head at load).
  • r1_base / r4_base (origin/main 0652b7907b): 184.7 GB weights; MaxRSS 191,478,136,832 B / 191,473,451,008 B (mean 191,475,793,920 B), peak footprint 191,869,788,240 B / 191,865,053,096 B (mean 191,867,420,668 B).
  • r5_cand_unset (adcc166af2, GLM_DRAFT_HEAD_Q4 unset): 184.7 GB weights; MaxRSS 191,473,680,384 B, peak footprint 191,865,282,376 B (+0 weight bytes vs main).
  • r2_q4 / r3_q4 (adcc166af2, GLM_DRAFT_HEAD_Q4=1): 185.1 GB weights; MaxRSS 191,831,703,552 B / 191,831,539,712 B (mean 191,831,621,632 B, +355.8 MB), peak footprint 192,223,502,392 B / 192,223,404,232 B (mean 192,223,453,312 B, +356.0 MB, matching bytesNeeded(154880, 4096) = 356,843,520 B).

Exactness (drafted == plain == main, greedy & seeded)

  • All 4 A-B-B-A runs (r1_base, r2_q4, r3_q4, r4_base): 0 failed, 0 unmeasured, timing_valid=True, 48/48 --alone equal (0 unequal, 0 failed, non-vacuous at N=3) and 16/16 --serial ("draft": false) equal (0 unequal, 0 failed, plain_drafted=0, non-vacuous MTP drafts accepted on every cell) per run.
  • r5_cand_unset (1 rep): 16/16 --alone equal, 16/16 --serial equal, 0 failed.
  • Cross-binary token_sha256 match: 100% bit-identical across r1_base (origin/main), r4_base (origin/main), r5_cand_unset (adcc166af2 unset), r2_q4 (Q4=1), r3_q4 (Q4=1), --alone, and --serial ("draft": false) at both greedy T=0.0 (code 7cd4ab7084c3..., chat 20acae32b5d8...) and seeded T=1.0 seeds 1234..1236 (code 378ce72fdd3b..., 5f649fe4146c..., 9c2be42968b6...; chat 1fd198720049..., 346536bbcc9a..., 99673f09fb34...).

Speed (aggregate_tps & steady_tps, A-B-B-A at N=1 and N=3)

Cell main (r1, r4) main mean Q4=1 (r2, r3) Q4=1 mean Diff main steady Q4=1 steady Steady diff
code T=0.0 N=1 86.7, 86.2 86.45 83.0, 83.2 83.10 -3.88% — — —
code T=0.0 N=3 148.8, 148.8 148.80 151.3, 153.2 152.25 +2.32% 151.70 155.30 +2.37%
chat T=0.0 N=1 71.3, 71.2 71.25 72.2, 72.3 72.25 +1.40% — — —
chat T=0.0 N=3 132.2, 133.0 132.60 135.8, 136.0 135.90 +2.49% 138.50 142.10 +2.60%
code T=1.0 N=1 81.0, 80.5 80.75 81.2, 81.4 81.30 +0.68% — — —
code T=1.0 N=3 102.6, 103.9 103.25 104.5, 105.8 105.15 +1.84% 107.10 109.35 +2.10%
chat T=1.0 N=1 68.0, 67.9 67.95 69.9, 70.1 70.00 +3.02% — — —
chat T=1.0 N=3 100.4, 99.7 100.05 101.0, 99.8 100.40 +0.35% 104.45 105.15 +0.67%
  • Note on code T=0.0 N=1 (-3.88%): under GLM_DRAFT_HEAD_Q4=1, the 4-bit draft head shifted proposals so requests drafted more tokens (accepted=152/206 in 104 rounds vs main's 149/166 in 107 rounds; r3_q4 rep 1 drafted 149/173 at 86.47 tok/s), widening verify rounds enough to offset the faster draft projection. Across the remaining 7/8 cells (N=1 and N=3), GLM_DRAFT_HEAD_Q4=1 measured +0.35% to +3.02% (+0.67% to +2.60% steady), consistent with keeping GLM_DRAFT_HEAD_Q4 off by default (0).
  • Uniform 4-bit/64 checkpoint no-op (GLM-5.3-Flash-MLX-4bit-MTP, --tokens 64 --reps 1 --levels 1): GLM_DRAFT_HEAD_Q4 unset vs GLM_DRAFT_HEAD_Q4=1 both loaded 180.6 GB weights (187,392,032,768 B vs 187,390,459,904 B MaxRSS; 187,734,791,248 B vs 187,733,218,432 B peak footprint; +0 synthesized bytes), 4/4 --alone and 4/4 --serial equal, 0 failed, bit-identical token_sha256 across unset, Q4=1, and "draft": false.

@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thanks @gilby. The default-off switch, DFlash2 skip and precision disclosure address the earlier requests. Target verification still uses the loaded head, so the changed draft proposals fit the verified-draft rule.

The new greedy and seeded M5 comparison is useful evidence, including the slower cell and memory cost. This is suitable for final integration checks; the merge is clean. Please retain the full checkpoint pins and raw receipts with those results.

  • Synthena

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.

3 participants