Repository navigation
glm metal: GLM_POOL_TOKENS sizes the shared latent pool apart from the per-stream window (stacked on #3903) - #3906
Conversation
|
This is the setting our production serving needed most. Measurements from a second M5 Ultra (512 GB) below, then some feedback. Setup is the same as in my comment on #3903: Why we needed it 70 hours of agent traffic on the 1.2.8 release with the #3545 patch (
So the byte budget was never the limit. The 1,048,572-token pool was, although the live conversations would have fitted in it. The same effect at a quarter of the size PR build,
All 18 replies have the same token hashes in both arms. In the small-pool arm every return visit resumed at 15,812, the end of the shared system prompt: that prefix survived and each conversation's own rows did not. 3,000,000 tokens on 512 GB
Feedback
In production Serving our agent traffic at 3M tokens since 2026-11-19 11:11 UTC, with #3903 and the #3418 to #3458 stack. In the first 33 minutes (100 requests from the same agents, 4 to 5 conversations and about 0.5M tokens alive) no next turn of a live conversation was re-read, where 6.4% of requests and 69% of the tokens read were such re-reads before. Reuse is 93.7% against 91.5%. That is a short window, so take it as a first reading. 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. |
62b362a to
4f17156
Compare
|
Thank you @gilby. This is our first review of The setting is opt-in: unset or blank keeps the pool and the output tokens exactly as on main, and your receipt shows zero token differences across main, unset, blank and a 2M-token pool. The refusals for malformed or out-of-range values, the load limit, the two-Mac pair and Main has since added cases to
|
4f17156 to
bcce0e8
Compare
|
I checked
Igor Lessio - AIFLOW LABS |
|
A correction to the "Why we needed it" and "In production" sections of my comment above. The 70 hours I analysed were two workloads. 50 hours in, 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. The same matching, split at that point:
So "69% of the tokens read were re-reads" described mostly the heavier first 50 hours. The like-for-like figure for the default pool is the middle column, where a quarter of the tokens read were re-reads of live conversations. At 3M that is 1.1%. The quarter-scale revisit test and the 3M checks in the comment are not affected. The middle column also bears on the second feedback point (eviction order): by this estimate the live conversations alone stayed under the 1,048,572-token pool the whole time, 0.93M at most, and a quarter of the reading was still re-reads. The estimate counts conversations at their final size and leaves out what each running stream reserves, so read it as a hint. We removed the limit today (2026-11-20 17:27 UTC), so the 3M pool now gets the load of the first column, where up to 1.31M tokens were alive at once. I can add those numbers here once there is a day of them. My agent (Claude) found the mistake and wrote this. |
bcce0e8 to
0464275
Compare
|
I checked the current GLM stack against main I replayed only the pool delta (
This validates the host integration for taking the three changes in order. Full-checkpoint serving and GPU timings were outside these runs. Igor Lessio - AIFLOW LABS |
0464275 to
93552d7
Compare
|
Thanks @gilby for the pool-sizing work. Two startup cases still need small fixes. With MTP enabled, an explicit pool that fits only after dropping the MTP head currently logs that fallback and starts. Could you preserve the documented named refusal for this case, keeping the existing fallback when the pool setting is unset? Also, when fixed streams do not fit beside an explicit pool, the error recommends lowering
|
|
Fixed both startup cases in commit
Verified on this commit: |
|
Thank you, @gilby. Both startup fixes are present. An explicit pool now keeps MTP enabled and gives the named refusal when it cannot fit; the unset setting keeps the existing fallback. Fixed-stream errors now point to the pool setting or parallel count, and the host cases cover both messages. No further code correction is requested for these fixes. What's left is device evidence for the complete stack, because it changes the default scheduling: generated token IDs equal to main with
|
|
Device evidence for the complete stack ( Checkpoint & Serving Configuration
1. Token Equality (
|
| Run | Pool log | Wired | Max RSS / Peak footprint |
|---|---|---|---|
main (GLM_POOL_TOKENS unset) |
3 streams share one 1048572-token MLA pool |
190.9 GiB |
205.26 GB / 205.61 GB |
main + #3906 (GLM_POOL_TOKENS unset) |
3 streams share one 1048572-token MLA pool |
190.9 GiB |
205.26 GB / 205.62 GB |
main + #3906 (GLM_POOL_TOKENS=2000000) |
3 streams share one 1999868-token MLA pool; context 1048576 tokens a stream in a shared pool of 1999868 tokens (GLM_POOL_TOKENS=2000000), 3 streams |
208.2 GiB |
223.79 GB / 224.16 GB |
Cell (N, T) |
main unset agg (per-stream) |
#3906 unset agg (per-stream) |
#3906 GLM_POOL_TOKENS=2000000 agg (per-stream) |
|---|---|---|---|
code N=1, T=0 |
108.1 (108.1) |
108.2 (108.2) |
108.6 (108.6) |
code N=3, T=0 |
181.9 (61.0) |
181.7 (61.0) |
182.0 (60.7) |
chat N=1, T=0 |
87.8 (87.8) |
88.2 (88.2) |
87.0 (87.0) |
chat N=3, T=0 |
155.0 (53.1) |
154.8 (53.1) |
153.8 (52.7) |
code N=1, T=1 |
121.7 (121.7) |
121.7 (121.7) |
122.0 (122.0) |
code N=3, T=1 |
121.8 (47.4) |
124.0 (47.6) |
122.0 (47.1) |
chat N=1, T=1 |
81.7 (81.7) |
81.8 (81.8) |
82.0 (82.0) |
chat N=3, T=1 |
111.2 (43.7) |
110.9 (42.7) |
111.5 (43.3) |
3. Oversized Pool Refusal Check (GLM_POOL_TOKENS=999999999)
Startup stopped cleanly before cache allocation (exit status 1, naming GLM_POOL_TOKENS):
error: glm: GLM_POOL_TOKENS=999999999 needs 19477.3 GB of caches beside 180.6 GB of weights and images, past this Mac's 358.4 GB load limit (70% of RAM); lower GLM_POOL_TOKENS or raise the limit
|
Thanks @gilby. The new release-model receipt answers the remaining device request: both the unset and 2M-pool runs report 48 of 48 replies matching main, with no solo or serial differences. Both startup fixes and their focused cases remain present. Main now contains the scheduling default already. The remaining conflicts with main are additive settings and test entries, which we will merge on our side keeping both. No further source correction or duplicate device run is requested. Exact-tree CI remains before landing.
|
a828619 to
c71b062
Compare
…e per-stream window Unset keeps the pool equal to --context. A set pool is planned with its caches and window scratch, refused by name before cache allocation when the load limit cannot hold it, and refused with the two-Mac pair or GLM_POOL=0. Refs ashhart#3152.
…tream refusal to pool setting
c71b062 to
42a9343
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_POOL_TOKENSsizes GLM-5.3-Flash's shared Metal MLA latent pool on one Mac independently from the per-stream--contextwindow (so--parallel 3 --context 1048576withGLM_POOL_TOKENS=2000000shares a1,999,868-token pool across up to three streams, capping each stream at--context, and cutting a stream's window cleanly when the pool is smaller). Unset, empty, or whitespace-only keeps the pool equal to--contextas before; malformed values, pools below1024or above4294967231, pools exceeding the Mac load limit, and combinations with--speed-uporGLM_POOL=0stop startup before cache allocation namingGLM_POOL_TOKENS.GLM_ROUND_PROFis in glm metal: GLM_ROUND_PROF per-round host and GPU summary #3894 and SRPT default order is in glm metal: shortest-remaining-first prompt order by default on one Mac #3903).813ebef6f6459d9f7ae08624dae11f2bd1d2aef1, base2a674b552498739e783a31c2573fc9ccf4d8cc0d); PR 3 adds 2 commits (813ebef6f6459d9f7ae08624dae11f2bd1d2aef1..62b362a575d352be7031dbacb7ef62010b835bfe, 12 files:533031810GLM_POOL_TOKENSfeature +62b362a57non-macOSArenacompile guard inzig/src/families/glm/state.zigso Linuxtest-host-alinks without Objective-C symbols).CHANGELOG.mdis omitted perCONTRIBUTING.mdso post-mergechangelog:commits do not conflict;git merge-tree --write-tree origin/main 62b362a575d352be7031dbacb7ef62010b835bfeagainstorigin/main(a1781885e921e9a772c641fef26010557e1349da) succeeds cleanly (bda0e357e8f17ec2c42ee22c34a48df9f14e384c).atc overlap --json: Run on62b362a575d352be7031dbacb7ef62010b835bfeagainstorigin/main; zero conflictingworkingTreePRs (#2008isclean,conflictFiles: 0); zero overlap with#3894(GLM_ROUND_PROF) or active#3448(worktreeOverlapsonly reflects local stack base glm metal: shortest-remaining-first prompt order by default on one Mac #3903).Checks on this head
62b362a575d352be7031dbacb7ef62010b835bfe(stacked on glm metal: shortest-remaining-first prompt order by default on one Mac #3903813ebef6f6459d9f7ae08624dae11f2bd1d2aef1;12files added/changed beyond glm metal: shortest-remaining-first prompt order by default on one Mac #3903,15total vsorigin/main;#3152served receipt measured one95aa3853/533031810, macOS runtime behavior identical)python3 tools/zig/lean_check.py, on the base and on this head:221vs221,0 new(tools/zig/lean_new.pyclean vsorigin/maina1781885e9;tools/pr_check.py --base origin/main --pr 3906exits0with0 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) on62b362a57.git diff --check origin/main: passed (0exit) on62b362a57.x86_64-linux-gnu(-Odebug) cross-link check onzig/src/glm_schedule_tests.zig(--test-filtermatchingglm_expiry.zig): compiled & linked ELF binary with0errors and0objcsymbols (nm -uclean), fixing the533031810test-host-aobjc_msgSend/objc_release/sel_registerNamelink failure.GLM_POOL_TOKENSrule inzig/src/platform/environment.zig,zig build test-glm-scheduling-hostcrashed1/71andzig build test-environment-hostcrashed2/26; after registering it and thestate.zigcomptime guard:zig build test-glm-scheduling-host test-environment-host test-glm-prefill-widths-host --summary all: passed (7/7 steps succeeded; 71/71 tests passed:26/26environment +71/71glm scheduling/prefill) on62b362a57.zig build test test-golden dev-tools native --summary all -Dcpu=apple_m1: passed (1105/1105 steps succeeded; 1748/1791 tests passed, 43 skippedincremental on62b362a57after15080/15204full pass one95aa3853).GLM_DRY=1 GLM_POOL_TOKENS=2000000under default 70% RAM load limit (GLM_LOAD_LIMIT_GBunset) passes plan/limit checks keeping all 45 + MTP layers (180.58 GBbuffers).62b362a575d352be7031dbacb7ef62010b835bfe, all 9 active checks wereCANCELLEDbefore start asinfrastructurewhen the repo-wide queued PR Actions backlog was cleared (Zig format/fmt;No GPU:benchmark-clients (ubuntu-latest),benchmark-clients (windows-latest),pytest,zig,zig-b,zig-windows,release-paths (ubuntu-24.04),zig-macos-dev-tools), andhost-nightly-linux/host-nightly-macosSKIPPED. Prior533031810passedZig formatand 7/8 activeNo GPUchecks (failing onlyzigLinux link due to Objective-C symbols fromglm_schedule_tests.zig), fixed in62b362a57(verified withx86_64-linux-gnu -OdebugNO_OBJC_SYMBOLS,71/71host tests, and1105/1105macOS steps above).900Kneedle pass withGLM_LOAD_LIMIT_GBunset (verifiedGLM_DRY=1 GLM_POOL_TOKENS=2000000acceptance under default 70% limit358.4 GBand observed208.2 GiBkept wired onpr3_pool2m; default limit refusal verified atGLM_POOL_TOKENS=20000000), and M1–M4 hardware checks (only Metal GLM pool sizing andenvironment.zigrules change; no GPU kernels changed).Receipt
512 GiBRAM) withTensorFold/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/bb001310eb3cf2eb87c015d576c2cc05exit 1, namingGLM_POOL_TOKENS, before cache allocation):GLM_POOL_TOKENS="abc"->tensorfold: GLM_POOL_TOKENS="abc": expected a whole number of tokens from 1024 to 4294967231 (unset or blank: the --context window)GLM_POOL_TOKENS="0"->tensorfold: GLM_POOL_TOKENS="0": expected a whole number of tokens from 1024 to 4294967231 (unset or blank: the --context window)GLM_POOL_TOKENS=20000000(default 70% limit) ->error: glm: GLM_POOL_TOKENS=20000000 needs 390.3 GB of caches beside 180.6 GB of weights and images, past this Mac's 358.4 GB load limit (70% of RAM); lower GLM_POOL_TOKENS or raise the limit(OverMemoryLimit)GLM_POOL_TOKENS=20000000(GLM_LOAD_LIMIT_GB=400) ->error: glm: GLM_POOL_TOKENS=20000000 needs 390.3 GB of caches beside 180.6 GB of weights and images, past this Mac's 400.0 GB load limit (GLM_LOAD_LIMIT_GB); lower GLM_POOL_TOKENS or raise the limit(OverMemoryLimit)GLM_POOL_TOKENS=2000000 GLM_POOL=0->error: glm: GLM_POOL_TOKENS sizes the shared pool of one Mac: it cannot be used with the two-Mac pair or GLM_POOL=0(PoolTokensNeedPool)GLM_POOL_TOKENS=2000000 --speed-up->error: glm: GLM_POOL_TOKENS sizes the shared pool of one Mac: it cannot be used with the two-Mac pair or GLM_POOL=0(PoolTokensNeedPool)mainvs unset vs blank vsGLM_POOL_TOKENS=2000000+GLM_LOAD_LIMIT_GB=400):main,pr3_unset,pr3_blank: all loaded1048572-tokenMLA pool,context 1048576 tokens, 3 streams;bench_concurrent.py --alone --serial --tokens 256 --reps 2 --temperatures 0 --levels 1,3had0unequal,0failed, and0token_sha256diffs vsmain(code98.8/168.7vs99.1/169.2vs99.0/169.1;chat80.8/145.7vs81.0/146.2vs81.1/145.8tok/s).pr3_pool2m(GLM_POOL_TOKENS=2000000 GLM_LOAD_LIMIT_GB=400):info: glm: 3 streams share one 1999868-token MLA pool,208.2 GiB kept wired between requests,context 1048576 tokens a stream in a shared pool of 1999868 tokens (GLM_POOL_TOKENS=2000000), 3 streams;bench_concurrent0unequal,0failed,0diffs vsmain(code99.0/169.5,chat81.5/146.0tok/s).900,000-token needle test underGLM_POOL_TOKENS=2000000(2,700,000concurrent tokens sharing the1,999,868-token pool):NEEDLE-ALPHA-74921: solo587.03s, concurrent637.19s,found=true,complete=true,token_sha256719826071f5e715fe3e2296ee74f83b94baf0d7c2c4c12292c14243e897c7c3bexact match (solo == concurrent).NEEDLE-GAMMA-92047: solo577.99s, concurrent1205.72s,found=true,complete=true,token_sha25695fed1bf0550699f843e4124626e15144f45b7418a69df1d4c1b45ab8a4b2f24exact match (solo == concurrent).NEEDLE-BETA-38514: solo577.59s, concurrent1733.38s(queued cleanly until a900Kpool region freed),found=true,complete=true,token_sha256ac9ffd484beee96dfccb327ea46f484cd2867d1c901e294839fba08c78833273exact match (solo == concurrent).tensorfold-native, one-Mac shared pool); two-Mac pair andGLM_POOL=0refuseGLM_POOL_TOKENS; no CUDA/HIP/Windows/app changes.GLM_POOL_TOKENS(registered inzig/src/platform/environment.zig, scope.metal, kind.u32). Unset, empty, or whitespace-only =--contextwindow as before. Accepted values: whole integers1024..4294967231(trimmed spaces/tabs, first char digit; refuses signs, suffixes, out-of-range,GLM_POOL=0,--speed-up, and load-limit overflow namingGLM_POOL_TOKENS). Documented indocs/environment.md. No optimization-ledger profile row needed.origin/main2a674b552498739e783a31c2573fc9ccf4d8cc0d(v1.2.10), stacked on glm metal: shortest-remaining-first prompt order by default on one Mac #3903813ebef6f6459d9f7ae08624dae11f2bd1d2aef1, head62b362a575d352be7031dbacb7ef62010b835bfe(macOS runtime identical to measurede95aa3853/533031810; adds62b362a57non-macOSArenacompile guard); 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/families/glm/{pool_size.zig,pool.zig,engine.zig,glm.zig,state.zig},zig/src/native/glm_host.zig,zig/src/platform/environment.zig,zig/build/glm_expiry.zig, and unit tests. Ran on M5 Ultra (macOS27.2.1) and cross-linkedglm_schedule_tests.zigforx86_64-linux-gnu; M1–M4 hardware not run on-device (host tests built-Dcpu=apple_m1).tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: Acrossmain,pr3_unset,pr3_blank, andpr3_pool2m(GLM_POOL_TOKENS=2000000),bench_concurrentreportedunequal_alone = 0, unequal_serial = 0, failed = 0,0token_sha256diffs vsmain, and all 3900K-token needle prompts produced identicaltoken_sha256between solo and 3-stream concurrent runs.https://gist.github.com/bb001310eb3cf2eb87c015d576c2cc05).tools/bench_openai.py: Single-stream and 3-stream greedy decode fromtools/bench_concurrent.py --alone --serial:code98.8/168.7(main) vs99.1/169.2(unset) vs99.0/169.1(blank) vs99.0/169.5tok/s (GLM_POOL_TOKENS=2000000);chat80.8/145.7(main) vs81.0/146.2(unset) vs81.1/145.8(blank) vs81.5/146.0tok/s (GLM_POOL_TOKENS=2000000); standalonebench_openai.pysuite n/a becauseGLM_POOL_TOKENSonly sizes the MLA buffer allocation and pool capacity without changing decode kernels (covered in glm metal: GLM_ROUND_PROF per-round host and GPU summary #3894).ttft_sfromtools/bench_cache.py --require-coldon a long prompt, or "n/a" with the reason when the change cannot reach prompt processing: UnsetGLM_POOL_TOKENSallocates the identical1,048,572-token pool asmain(exact match inbench_concurrent.pyTTFT0.08s/0.12s); withGLM_POOL_TOKENS=2000000, solo900,000-token cold prompts completed in587.03s,577.59s, and577.99s(--prompt-cache-gib 0, exact needles found).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