Repository navigation
GLM-5.3-Flash on one Mac: the streams share one MLA cache pool, so --parallel 3 serves the full 1M window - #639
Merged
Conversation
…ion a request Every slot past the first allocated its own MLA caches for the whole window at load, so --parallel 3 at --context 1048576 needed ~65 GB of caches beside 180.6 GB of weights. The slots now share the engine's own MLA caches (pool.zig): a request takes a contiguous region for its prompt plus max_tokens when it begins and gives it back when it leaves. One request alone can use the whole window; several split it. The kernels see a region as a cache of its size (Ref offsets, no kernel change). Info.admit lets the lane host keep a request that does not fit beside the running streams in the queue, in order, until enough of them leave. A kept prompt state whose prefix sits in a region holds those blocks after its stream leaves, until a stream needs the room; the state then goes stale and its prompt is read again. Off on a pair (its ranks mirror slot commands) and with GLM_POOL=0.
BobClawblaw
force-pushed
the
glm-shared-pool
branch
from
October 11, 2026 01:26
9127267 to
91f1b5a
Compare
Owner
|
Thank you, @BobClawblaw. This is in 1.0.6 (
We didn't load the whole model on one Mac (past our 70% load rule there), so the full-window claim for three streams is from your run. |
jschmied
pushed a commit
to jschmied/TensorFold
that referenced
this pull request
Oct 11, 2026
…A cache pool, so --parallel 3 serves the full 1M window Thanks @BobClawblaw.
jschmied
pushed a commit
to jschmied/TensorFold
that referenced
this pull request
Oct 11, 2026
jschmied
pushed a commit
to jschmied/TensorFold
that referenced
this pull request
Oct 11, 2026
BobClawblaw
pushed a commit
to BobClawblaw/TensorFold
that referenced
this pull request
Oct 12, 2026
The change landed rebased over ashhart#639 as 3e02e29d4 with its author kept; this keeps the PR's head in the history with no change to the tree.
sethforprivacy
added a commit
to sethforprivacy/TensorFold
that referenced
this pull request
Oct 13, 2026
…XTS, and a stream that outgrows its session moves Every session held the whole window, so few fit beside the model (three 262K sessions in 15.4 GiB on a 256 GB Mac). - FLASHNEXT_SLOT_CONTEXTS lists the sessions past the engine's own (token counts, CONTEXTxN for N alike, e.g. "65536,32768x3,16384x11": 16 streams in 11.6 GiB); unset, nothing changes. - A new stream takes the smallest free session that holds its prompt and its reply's next FLASHNEXT_SLOT_GROW tokens (default 8192); LaneHost's admit hook (as on main since ashhart#639) holds a request until one is free. - Before a round, a stream left too little room moves to the smallest free larger session that holds its next FLASHNEXT_SLOT_GROW tokens (Session.moveTo: its cache rows, DeltaNet states, n-gram tail, head rows and pooled blocks copied on the GPU at a round's end, states settled first), or pauses (Stream.paused) until one frees. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
…A cache pool, so --parallel 3 serves the full 1M window Thanks @BobClawblaw.
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
The author rebased ashhart#639 onto main after our merge; this keeps the PR's current head in the history with no change to the tree.
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
The change landed rebased over ashhart#639 as 3e02e29d4 with its author kept; this keeps the PR's head in the history with no change to the tree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
Every slot past the first allocates its own MLA caches for the whole window at load. At
--context 1048576that is about 20 GB a stream, so three streams need ~65 GB of caches beside 180.6 GB of weights: more than a 256 GB Mac has under any load limit. The slots now share the engine's own MLA caches:families/glm/pool.zig: a request takes a contiguous region of the engine's caches, in 256-token blocks, for its prompt plusmax_tokens(plus a last window) when it begins, and gives it back when it leaves. One request alone can use the whole window; several split it. The kernels see a region as a cache of its size: itsRefs are offsets into the engine's buffers, no kernel changes.initState(..., 0, ...)), ~0.3 GB each;glm_host.fitcounts that.api.Info.admit: the lane host asks whether the queue's head fits beside the running streams, and when it does not, the request waits in the queue, in order, until enough streams leave. With no stream running it is always admitted (a request larger than the window is still refused at prefill, as now).Snap.held). A request that needs those blocks takes them: the oldest held state gives its blocks up and goes stale, and its next turn reads the prompt again. Admission does not wait for held blocks.e.eporfollowsPeer(): the ranks mirror slot commands) and withGLM_POOL=0, where each slot keeps its own window as before.prefill_step, so its prompt pass, and so its region, is taken inside admission: the next request'sfitsalready sees it (feat(lanes): a prompt pass a chunk a round, between the other streams' rounds #623's chunked pass doesn't apply here).pickis unchanged: in the pool a free slot holds no resident state of its own (its states moved to held blocks), so it picks the first free slot.Checks
zig build testpasses. New:pool.zig's block arithmetic, and a lane host test where a request that fits no pool waits with a lane free, then runs once the other stream leaves.zig fmt --check zig/srcclean. Every file stays under 600 lines (slots.zig 597, pool.zig 162).On this branch before its rebase onto 56150e6 (main 38de96b + this PR; the rebase changed no GLM file, and
zig build testpasses after it), one M5 Ultra,GLM_LAYERS=8,--context 1048576 --parallel 3, greedy. Eight layers write nonsense, so these are exactness checks, not quality:GLM_POOL=0(quality.suite --compare)concurrent), pooled andGLM_POOL=0"draft": false(drafts), pooled andGLM_POOL=0GLM_POOL=0GLM_POOL=0The full model, 1M window, three streams, measured downstream on 1.0.5 with the same pool (plus residency wiring, #581, which this PR does not include): 200-201 GiB wired, 31-40 GiB free, one user 92 / 105 / 99 / 96 tok/s (prose / code / structured / list, the ruler), 106-124 tok/s aggregate at three users, the Spark recipe's suite with replies of four streams together equal to each alone 12/12 and drafted equal to undrafted 12/12; a 6.4k-token system prompt's second question resumed at 6,362 of 6,376 tokens from another slot in 0.55 s (6.05 s read whole).