Skip to content

glm metal: GLM_ROUND_PROF per-round host and GPU summary - #3894

Merged
ashhart merged 2 commits into
ashhart:mainfrom
gilby:glm-metal-round-prof
Nov 24, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
gilby:glm-metal-round-prof

Conversation

@gilby

@gilby gilby commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

GLM_ROUND_PROF=1 has GLM-5.3-Flash's Metal verify server accumulate and log a per-round GPU timing, idle gap, ahead span, and host phase summary broken down by batch row tier, stream count, drafted vs plain round, and partial accepts when streams end; when unset, empty, whitespace-only, or 0, round profiling stays off with unchanged behavior, and invalid values stop startup naming GLM_ROUND_PROF.

  • Issue: Refs GLM-5.3-Flash on Metal: decode and prompt speed on M5 Ultra, token-exact (baseline, items and gate) #3152 (PR 1 of 3 M5 Ultra scheduling/pool/profiling pull requests; SRPT default order and GLM_POOL_TOKENS follow in separate PRs).
  • Stacked on: main (a1781885e921e9a772c641fef26010557e1349da), fast-forward merged origin/main at f4701d07d30b31a3761c1c75b51bd7f89230c2cd (c6e7a05a4 + f794af849 + f4701d07d dropping CHANGELOG.md diff per CONTRIBUTING.md so post-merge changelog: commits do not conflict; #3152 measurements taken on 1c584f43aa4cd9e874aff6362ee1423200d46001 with identical Zig/docs sources). git merge-tree --write-tree origin/main f4701d07d30b31a3761c1c75b51bd7f89230c2cd succeeds cleanly (361a8e8520ba6adbfe7b95b2b59430bb636f192f).
  • atc overlap --json: Run on f4701d07d30b31a3761c1c75b51bd7f89230c2cd against origin/main; complete: false (myPullRequestsLimit, otherPullRequestsLimit, pullFilesUnavailable, timeLimit). Clean (0 conflicts) on #1434, #1508, #1924; 1 stale overlap #1634 (conflictFiles: 2); zero overlap with #3448; GitHub mergeable: MERGEABLE.

Checks on this head

  • Head commit: f4701d07d30b31a3761c1c75b51bd7f89230c2cd (measured on 1c584f43aa4cd9e874aff6362ee1423200d46001, full host CI verified on f794af849; identical Zig/docs sources)
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 221 vs 221, 0 new (tools/zig/lean_new.py clean against origin/main a1781885e9; tools/pr_check.py --base origin/main --pr 3894 exits 0 with 0 error(s), 1 warning(s): the expected advisory CHANGELOG.md Unreleased warning since CHANGELOG.md is omitted to avoid merge conflicts).
  • Tests run, with the command and pass, fail and skip counts:
    • zig fmt --check build.zig zig: passed (0 exit) on f4701d07d.
    • git diff --check origin/main: passed (0 exit) on f4701d07d.
    • Fail-before / pass-after: before adding GLM_ROUND_PROF rule to zig/src/platform/environment.zig, zig build test-environment-host failed (24/26, 2 crashes on unregistered strict parser) and zig build test failed (1165/1181, 3 crashes); after adding it:
      • zig build test-environment-host --summary all: passed (3/3 steps succeeded; 26/26 tests passed) on f4701d07d.
      • zig build test test-golden dev-tools --summary all -Dcpu=apple_m1: passed (1103/1103 steps succeeded; 1912/1958 tests passed, 46 skipped) on f794af849 (identical Zig/docs sources).
      • zig build native -Dcpu=apple_m1 -Dversion=1.0.0: passed (1c584f43a, identical Zig sources).
  • CI: on f4701d07d (merge dropping CHANGELOG.md), 5/9 active checks COMPLETED SUCCESS (Zig format / fmt, No GPU: benchmark-clients (windows-latest), pytest, release-paths (ubuntu-24.04), zig-macos-dev-tools), 4/9 CANCELLED as infrastructure when the repo-wide queued PR Actions backlog was cleared (benchmark-clients (ubuntu-latest), zig, zig-b, zig-windows), and host-nightly-linux / host-nightly-macos SKIPPED. Identical Zig/docs commit f794af849 passed 9/9 active checks COMPLETED SUCCESS (Zig format, No GPU).
  • Not run, and why: CUDA, HIP, Windows, desktop app, and M1–M4 hardware checks (host changes only affect the Metal GLM native runtime and environment.zig rules; no GPU kernels changed).

Receipt

  • Main against branch: 7-arm symmetric A-B-C-C-B-A (+ discard) on M5 Ultra with TensorFold/GLM-5.3-Flash-MLX-4bit-MTP, --parallel 3 --context 1048576 --prompt-cache-gib 0, Nominal thermal (notifyutil -g com.apple.system.thermalpressurelevel == 0) and idle background (mediaanalysisd CPU 0.0) at start and end of every arm. Raw scrubbed artifacts + script: https://gist.github.com/20a8e462fd1ffff017e6be8dd8ff0b6e
    • Concurrent (tools/bench_concurrent.py --alone --serial --tokens 256 --reps 3 --temperatures 0,1.0 --levels 1,3), aggregate / per-stream tok/s (2-arm median per condition):
      • code, T=0.0, L=1: main 98.95 vs unset 99.00 vs GLM_ROUND_PROF=1 98.95
      • code, T=0.0, L=3: main 170.85 / 58.0 vs unset 170.50 / 57.45 vs GLM_ROUND_PROF=1 170.75 / 57.9
      • code, T=1.0, L=1: main 111.00 vs unset 111.20 vs GLM_ROUND_PROF=1 110.75
      • code, T=1.0, L=3: main 114.85 / 46.15 vs unset 113.70 / 41.8 vs GLM_ROUND_PROF=1 113.45 / 46.55
      • chat, T=0.0, L=1: main 81.20 vs unset 81.15 vs GLM_ROUND_PROF=1 81.75
      • chat, T=0.0, L=3: main 146.25 / 49.9 vs unset 146.25 / 49.85 vs GLM_ROUND_PROF=1 146.25 / 49.85
      • chat, T=1.0, L=1: main 73.65 vs unset 72.65 vs GLM_ROUND_PROF=1 74.65
      • chat, T=1.0, L=3: main 104.80 / 41.45 vs unset 102.65 / 40.5 vs GLM_ROUND_PROF=1 105.20 / 40.4
    • OpenAI single-stream (tools/bench_openai.py --tokens 256 --reps 3 --temperatures 0,1.0), median decode tok/s / TTFT s (2-arm per condition):
      • fibonacci-raw, T=0.0: main 98.95 / 98.91 (0.08s) vs unset 99.29 / 93.99 (0.08s, one arm saw transient host jitter) vs GLM_ROUND_PROF=1 98.97 / 99.02 (0.08s)
      • fibonacci-raw, T=1.0: main 97.80 / 97.90 (0.08s) vs unset 98.12 / 97.65 (0.08s) vs GLM_ROUND_PROF=1 97.84 / 97.57 (0.08s)
      • gpu-chat-no-think, T=0.0: main 81.91 / 80.74 (0.12s) vs unset 81.86 / 79.63 (0.12s) vs GLM_ROUND_PROF=1 81.00 / 81.97 (0.12s)
      • gpu-chat-no-think, T=1.0: main 77.04 / 77.75 (0.12s) vs unset 77.04 / 77.12 (0.12s) vs GLM_ROUND_PROF=1 77.44 / 77.94 (0.12s)
    • Log & refusal behavior: GLM_ROUND_PROF=1 arms logged glm round prof: summary tables (789 windows across run); main and unset arms logged none; invalid values GLM_ROUND_PROF=yes and 2 both stopped startup (exit 1) naming GLM_ROUND_PROF.
  • Boxes it reaches: Apple Silicon Macs running native Metal GLM-5.3-Flash (tensorfold-native); no CUDA/HIP/Windows/app runtime reach.
  • New switch? Default, accepted values, profile row: GLM_ROUND_PROF (registered in zig/src/platform/environment.zig, scope .metal, kind .bool). Unset, empty, or whitespace-only = 0 (off). Accepted values: 0, 1. Any other text stops startup naming GLM_ROUND_PROF and accepted forms (expected 0 or 1). No optimization-ledger profile row added (diagnostic toggle only, unchanged throughput).
  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision: Base origin/main a1781885e921e9a772c641fef26010557e1349da (originally 2a674b552498739e783a31c2573fc9ccf4d8cc0d v1.2.10), measured head 1c584f43aa4cd9e874aff6362ee1423200d46001 (current head f4701d07d30b31a3761c1c75b51bd7f89230c2cd, CHANGELOG.md merge/drop only); Zig 0.17.0; Apple Metal toolchain 32023.922 (metalfe-32023.922.4) (Metal 4); Apple M5 Ultra (80-core GPU, 512 GiB RAM), macOS 27.2.1 (26B131); checkpoint TensorFold/GLM-5.3-Flash-MLX-4bit-MTP (rev d2b17f5253440224422b150705c1109a9a3a0368).
  • Paths and platforms the change reaches, which I ran and which I could not: Reaches Metal GLM slot/verify loop (zig/src/families/glm/{backend.zig,slots.zig,round_prof.zig}) and zig/src/platform/environment.zig. Ran on M5 Ultra (macOS 27.2.1); M1–M4 hardware not run on-device (host unit tests built -Dcpu=apple_m1).
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: Across all 6 measured arms (arm1..arm6), unequal_alone = 0, unequal_serial = 0, failed = 0, and token_sha256_diffs_vs_main = 0 (arm1_main_a vs all measured main, unset, and GLM_ROUND_PROF=1 cells).
  • Main against this branch, same machine and checkpoint, posted before asking for a run on our machines (or why you can't): Posted above and in the public receipt gist (https://gist.github.com/20a8e462fd1ffff017e6be8dd8ff0b6e).
  • Decode speed before and after, from tools/bench_openai.py: See Main against branch above (98.95 / 98.91 vs 98.97 / 99.02 tok/s greedy raw; 81.91 / 80.74 vs 81.00 / 81.97 tok/s greedy chat; no slowdown with profiling off or on).
  • Prompt speed before and after: the cold first request's ttft_s from tools/bench_cache.py --require-cold on a long prompt, or "n/a" with the reason when the change cannot reach prompt processing: n/a for prompt prefill kernels — GLM_ROUND_PROF only observes verify-window host/GPU timestamps after prefill (first-request TTFT in bench_openai.py stays identical at 0.08s raw / 0.12s chat across all arms).
  • Licence of any new weights or drafter, or "n/a": n/a (uses existing TensorFold/GLM-5.3-Flash-MLX-4bit-MTP checkpoint, no new weights or drafter).

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.

  • 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

@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thank you @gilby. The strict opt-in, one-branch-off hooks and per-round summary look right, and the environment, full host and CI checks are green. Leaving the changelog line out of the branch is fine; we place it at landing. Nothing further is needed from you here.

  • Synthena

@AIFlowML

Copy link
Copy Markdown
Contributor

I checked f4701d07d against main 210e3b0c5. The only merge conflict is the strict-switch test list in environment_test.zig. Keeping both GLM_ROUND_PROF and main's TF_QWEN27_SHARED_PREFIX resolves it.

On the resulting trial tree, Zig 0.17.0 on an M5 Max passed 94/94 with zig build test-environment-host test-glm-scheduling-host test-glm-gathers -Dcpu=apple_m1 -j5 --summary all. The five focused profiler tests also passed with zig test -lc --dep sys -Mroot=zig/src/families/glm/round_prof.zig -Msys=zig/src/platform/sys.zig, including the disabled hooks and histogram cases. Removing only the new env registration in scratch reproduced the two expected strict-parser crashes. I used host fixtures, so the served timing measurements remain covered by the author's receipt.

Igor Lessio - AIFLOW LABS

@gilby
gilby marked this pull request as ready for review November 21, 2026 20:44
@ashhart
ashhart force-pushed the glm-metal-round-prof branch from f4701d0 to 2c84357 Compare November 22, 2026 00:36
@AIFlowML

Copy link
Copy Markdown
Contributor

The latest 2c843579 head trial-merges cleanly into main d21617008. I checked the failing Linux and Windows jobs from the older hosted run. Both stopped on the Flash Next fixture expecting 36 settings. The current trial retains main’s corrected 37-setting fixture byte for byte. Linux job · Windows job

The current trial passed all 112 tests on M5 Max with Zig 0.17.0. That covers the round-profile option, clock-free disabled hooks, histogram buckets, the environment suite and the adjacent prompt-profile suite.

zig build test-environment-host test-glm-prompt-profile-host \
  -Dcpu=apple_m1 -Doptimize=ReleaseSafe -j2 --summary all

For the feature-specific tests I also registered a scratch target with the existing Metal engine test root filtered on round profile:. The published feature code was unchanged. Hosted reruns and device performance remain separate.

Igor Lessio - AIFLOW LABS

@ashhart
ashhart force-pushed the glm-metal-round-prof branch 2 times, most recently from d9883f9 to 9731ace Compare November 24, 2026 06:00
gilby and others added 2 commits November 24, 2026 15:55
GLM_ROUND_PROF=1 logs verify window GPU time, idle gap, ahead span, host phases, and partial accepts when streams end. Unset, blank, or 0 stays off; invalid values fail startup by name via environment.read. Refs ashhart#3152.
@ashhart
ashhart force-pushed the glm-metal-round-prof branch from 9731ace to ba31eb0 Compare November 24, 2026 15:55
@ashhart
ashhart merged commit 00e0e98 into ashhart:main Nov 24, 2026
11 of 12 checks passed
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you @gilby. 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.

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