Repository navigation
glm metal: shortest-remaining-first prompt order by default on one Mac - #3903
Conversation
|
I ran this on a second M5 Ultra against an agent-shaped load, because the order it changes is what was hurting our production serving. It helps a great deal here. Setup
Agent loops beside long prompts Three agents start together. Each sends a 15.8K-token system prompt that all three share, its own 22K-token brief, then 12 tool steps of about 1,400 new prompt tokens and a 200-token reply (
The 1.2.8 release (with the #3545 patch, which is what we were serving) measured the same as main: 507.3 s a loop, 5.9 tok/s p50. The loops ran 2.6 times faster on the PR and neither long prompt waited longer for its first token. The receipt's bench at half the length
Decode with no prompt filling
Token hashes in the loop test 30 of the 41 loop replies have the same
So each long sampled conversation seems to have two possible outcomes, on main as well, and I haven't found what picks one. I can open a separate issue with the request bodies if that is useful. In production This has served our agent traffic since 2026-11-19 11:11 UTC, together with #3906 at 3M tokens and the #3418 to #3458 stack. On the 1.2.8 build, 70 hours of that traffic had a median decode of 48.7 tok/s but a 10th percentile of 8.2 (replies of 64 tokens or more), and 9% of requests waited over a minute for a first token. In the first 33 minutes on the new build (100 requests from the same agents, the three changes together, a backlog still clearing) the 10th percentile is 18.7 tok/s, requests that read 16K tokens or more reach a first token in 49 s at the median where it was 204 s, and 1,000 generated tokens cost 46 s of request time where they cost 78 s. That is a short window, so take it as a first reading. The default looks right to me for one Mac serving agents. My agent (Claude) did the builds, the runs and this write-up. The load script and the raw JSON are available if you want them. |
813ebef to
3fa0805
Compare
|
Thank you @gilby for the careful A/B and the second contributor's agent-loop receipt. This is ready: the default applies only on one Mac with no share setting, an explicit order still wins, and the pair keeps its old order. The new host tests cover those cases, and the head applies cleanly to today's main. We were unable to run the Mac checks here; your receipts carry that evidence. Nothing else is needed.
|
|
I checked
Igor Lessio - AIFLOW LABS |
|
A correction to the "In production" paragraph of my comment above. The 70-hour baseline I quoted was not one workload. 50 hours into it we limited our support agent to two background runs at a time; on the day we set it, the agent had averaged 3.5 runs at once and peaked at 8. Split at that point, with nothing else changed on the 1.2.8 build:
"New build" is this commit with #3906 at 3M tokens and the #3418 to #3458 stack, as before. The like-for-like gain in production is between the last two columns: 34.6 s to 21.8 s per 1,000 generated tokens, and the slow tenth of first tokens after a long read from 208 s to 50 s. The 78 s and 204 s I quoted came mostly from the heavier overlap of the first 50 hours, which our own limit had removed before the new build went in. The controlled runs in the comment are not affected. We removed that limit today (2026-11-20 17:27 UTC), so the new build now gets the load of the first column. I can add those numbers here once there is a day of them. My agent (Claude) found the mistake and wrote this. |
3fa0805 to
3d2f44d
Compare
|
The current The last hosted pytest failure is missing PyYAML during collection. The current merged tree retains main's exact workflow blob with zig build test-glm-scheduling-host -Dcpu=apple_m1 -Doptimize=ReleaseSafe -j1 --summary all
python -m pytest -q -p no:cacheprovider tools/test_ci_workflow_conditions.pyThe current checks cover scheduling policy and the CI prerequisite. The served A/B and multi-Mac measurements remain in the existing receipts. Igor Lessio - AIFLOW LABS |
3d2f44d to
04a454d
Compare
A reply that would end well before a long prompt goes first, as for Qwen3.8-27B. A decode share, a prompt share below 1, the two-Mac pair or a TENSORFOLD_PREFILL_ORDER other than srpt keeps the old order. Refs ashhart#3152.
04a454d to
d2d3cff
Compare
|
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. |
What this changes
GLM-5.3-Flash on one Apple Silicon Mac now uses shortest-remaining-first (
srpt) prompt prefill order by default whenever neither--decode-sharenor aTENSORFOLD_PREFILL_SHAREbelow1nor a non-srptTENSORFOLD_PREFILL_ORDERis configured; the two-Mac expert-parallel pair and every explicit flag/env override keep the prior FIFO order.GLM_ROUND_PROFis in glm metal: GLM_ROUND_PROF per-round host and GPU summary #3894 andGLM_POOL_TOKENSstacks on this branch).main(2a674b552498739e783a31c2573fc9ccf4d8cc0d), 1 commit (813ebef6f6459d9f7ae08624dae11f2bd1d2aef1;CHANGELOG.mdleft untouched perCONTRIBUTING.mdso post-mergechangelog:commits do not conflict).git merge-tree --write-tree origin/main 813ebef6f6459d9f7ae08624dae11f2bd1d2aef1against currentorigin/main(e3fb56cb09061a979cb02080601fc6f7870d3362) succeeds cleanly (2bdcf43320d105fe5b02246171a5fecd0f274b04).atc overlap --json: Run on813ebef6f6459d9f7ae08624dae11f2bd1d2aef1againstorigin/main;complete: false(myPullRequestsLimit,otherPullRequestsLimit,pullFilesUnavailable,timeLimit). ZeroworkingTreePR overlaps (0conflicting PRs); zero overlap with#3894(GLM_ROUND_PROF) or active#3448. (worktreeOverlaps: 1 local stack sibling worktree sharingglm_host.zig/glm_schedule_tests.zig/glm_expiry.zig, stacked in PR 3).Checks on this head
813ebef6f6459d9f7ae08624dae11f2bd1d2aef1(identical Zig/docs sources to measured5c2f513ca,CHANGELOG.mddropped)python3 tools/zig/lean_check.py, on the base and on this head:221vs221,0 new(tools/zig/lean_new.pyclean vsorigin/maine3fb56cb0;tools/pr_check.py --base origin/mainexits0with0 error(s), 1 warning(s): the expected advisoryCHANGELOG.mdUnreleased warning sinceCHANGELOG.mdis omitted to avoid merge conflicts).zig fmt --check build.zig zig: passed (0exit) on813ebef6f.git diff --check origin/main: passed (0exit) on813ebef6f.srptByDefaultreturningfalse,zig build test-glm-scheduling-hostfailed (64 pass, 1 fail, failedglm order: one Mac with no share starts with shortest-remaining-first); after fixing:zig build test-glm-scheduling-host --summary all: passed (3/3 steps succeeded; 65/65 tests passed) on813ebef6f.zig build test test-golden dev-tools --summary all -Dcpu=apple_m1: passed (1103/1103 steps succeeded; 468/483 tests passed, 15 skippedon813ebef6fincremental pass after15101/15225full pass on5c2f513ca, identical Zig sources).zig build native -Dcpu=apple_m1 -Dversion=1.0.0: passed (5c2f513ca, identical Zig/docs/build sources).813ebef6f6459d9f7ae08624dae11f2bd1d2aef1(Zig format/fmt,No GPU/zig,zig-b,zig-windows,zig-macos-dev-tools,pytest,benchmark-clients (ubuntu-latest),benchmark-clients (windows-latest),release-paths (ubuntu-24.04)allCOMPLETED SUCCESS; nightly jobsSKIPPED).glm_order_tests.zighost tests), and M1–M4 hardware checks (only Metal GLM native host scheduling changes; no GPU kernels changed).Receipt
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 (mediaanalysisdCPU0.0) at start and end of every arm. Raw scrubbed artifacts + script: https://gist.github.com/e2ab481ecaa851eb40e8127279b41f97tools/bench_fill.py --long 262144 --reply 21 --lead 5.0), 2-arm median per condition:long_first21-tokenreply_s:main6.11s(6.05s, 6.16s) vspr2 FIFO(TENSORFOLD_PREFILL_ORDER=fifo)6.08s(6.04s, 6.12s) vspr2 default SRPT3.56s(3.57s, 3.56s) (41.7% faster, 1.72x).long_firstlong_ttft_s:main141.19s(140.59s, 141.79s) vspr2 FIFO141.41s(141.01s, 141.80s) vspr2 default SRPT139.51s(139.61s, 139.41s) (-1.2%, well within5%).long_firstboth_done_s:main141.57svspr2 FIFO141.78svspr2 default SRPT139.89s.long_firstreply_gap_max_ms:main309.3msvspr2 FIFO309.2msvspr2 default SRPT297.5ms.alone(reply_s/long_ttft_s):0.38s/136.24s(main),0.38s/136.16s(fifo),0.38s/136.19s(srpt).tools/bench_concurrent.py --alone --serial --tokens 256 --reps 3 --temperatures 0 --levels 1,3), aggregate / per-stream tok/s (2-arm median):code, T=0.0, L=1:main99.15vsfifo99.00vssrpt99.10code, T=0.0, L=3:main170.75 / 57.95vsfifo170.65 / 57.90vssrpt170.80 / 57.90chat, T=0.0, L=1:main81.30vsfifo81.05vssrpt81.05chat, T=0.0, L=3:main146.30 / 49.90vsfifo146.35 / 49.90vssrpt146.20 / 49.90tensorfold-native, one-Mac host); two-Mac expert-parallel pair keeps old order (glm_order_tests.zig); no CUDA/HIP/Windows/app changes.TENSORFOLD_PREFILL_ORDER(srptnow default on one Mac for GLM-5.3-Flash when--decode-shareandTENSORFOLD_PREFILL_SHARE < 1are unset; any other value keeps FIFO),--decode-share, andTENSORFOLD_PREFILL_SHARE(perdocs/api.md). No optimization-ledger profile row needed.origin/main2a674b552498739e783a31c2573fc9ccf4d8cc0d(v1.2.10), head813ebef6f6459d9f7ae08624dae11f2bd1d2aef1(identical Zig/docs/build sources to measured5c2f513ca,CHANGELOG.mddropped); Zig0.17.0; Apple Metal toolchain32023.922 (metalfe-32023.922.4)(Metal 4); Apple M5 Ultra (80-core GPU, 512 GiB RAM), macOS27.2.1(26B131); checkpointTensorFold/GLM-5.3-Flash-MLX-4bit-MTP(rev d2b17f5253440224422b150705c1109a9a3a0368).zig/src/native/{glm_order.zig,glm_host.zig}and host scheduler config tests (zig/src/{glm_order_tests.zig,glm_schedule_tests.zig},zig/build/glm_expiry.zig). Ran on M5 Ultra (macOS27.2.1); M1–M4 hardware and physical two-Mac pair not run on-device (host tests built-Dcpu=apple_m1).tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: Across all 7 arms (arm0..arm6),bench_fillreportedexact = true, cold = true,bench_concurrentreportedunequal_alone = 0, unequal_serial = 0, failed = 0,token_sha256_diffs_vs_main = 0, and 21-token greedyreply21_sha256(f8348662fcdfb545b97562a6a6231266b35e1f192e49c552f5f97c8d4c47a86a) had0diffs across all arms.https://gist.github.com/e2ab481ecaa851eb40e8127279b41f97).tools/bench_openai.py: Single-stream greedy decode frombench_concurrent.py --alone --serial(code:99.15main vs99.10tok/s SRPT;chat:81.30main vs81.05tok/s SRPT; 21-tokenbench_openai.streamexactness check identical SHA across all arms); standalonebench_openai.pysuite n/a because this PR only changes queued prompt scheduling order (glm_order.zig) and cannot change solo decode kernels.ttft_sfromtools/bench_cache.py --require-coldon a long prompt, or "n/a" with the reason when the change cannot reach prompt processing: Cold 262,144-token prefill TTFT measured viatools/bench_fill.py(--prompt-cache-gib 0,cold=true): solo136.24s(main) vs136.19s(srpt), and concurrentlong_first141.19s(main) /141.41s(fifo) vs139.51s(srpt,-1.2%, within5%).TensorFold/GLM-5.3-Flash-MLX-4bit-MTPcheckpoint, 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