mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #5176] Gyro-M on a 64 GB Mac: the whole expert set fits in the expert cache, but setup writes 64 slots and drops the MTP #3081
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3081
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Flo5k5 on GitHub (Nov 4, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5176
Following up on #5169 (MTP pays under the 96 GB streaming threshold) with a stronger finding from the same machine.
Setup: Mac mini M5 Pro 64 GB, branch v0.2.6 + #3876 + #4126 + our TYPE_SIZE patch (#5167), Gyro-M TQ2_0 (
7aa36d15), same pack as the community reports in #5168.Finding: Gyro-M's experts (all of them — 24576 slots, 29.88 GiB of VRAM) fit in a 64 GB Mac's unified memory once oMLX/other servers are stopped.
--expert-cache 24576pre-fills the whole set from the profile in 45 s (705 MB/s) at boot, and after that the expert-tier counters never move again (since the start RAM 0 blobs, files 0 blobs) — the SSD streaming disappears entirely. The setup's own config for this machine writes--expert-cache 64and removes the MTP layer, which leaves the model streaming and slow.Measured (strata bench run, thinking-v1-draft.1 protocol, median short/4K/16K decode tok/s, 3 runs each, engine 0.1.50-metal):
Also measured and rejected on this machine:
--spec 6(loses everywhere),--lookup-chain 2(kills the 16K case: 37.4),--spec-min-p 0.7(wins short at 47.1, loses 4K/16K), re-benching hot vs cold (no difference once the cache is full at boot — the warm-up argument disappears with the full cache).tools/calibrate.pyon this Mac: pool-workers 4 (+12.6% on a miss-heavy engine, +0.4 once the cache is full), pcie-frac 0.55 default confirmed, spec-min-p 0.5 default confirmed, default adaptive tier kept.Suggestion: when
mac_fitcomputes the plan for a Gyro model, check whether all experts fit the available VRAM budget and, if so, write the full--expert-cachecount (plus keep the MTP on). On this 64 GB machine that single change is the difference between streaming and resident.The remaining gap to the Q2_0 resident speed (66 tok/s) is the TQ2_T Metal decode path itself — the trellis dequant costs more per expert than Q2_0's — which is kernel work, not configuration.
@github-actions[bot] commented on GitHub (Nov 4, 2026):
Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:
Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment
/reopen.Details: CONTRIBUTING.md
@Flo5k5 commented on GitHub (Nov 4, 2026):
Follow-up: where the remaining time actually goes on this machine.
With
STRATA_VERIFY_PROFILE=1 STRATA_DECODE_TIMING=1on the same config (expert cache full, so no streaming):Everything outside the verify kernels is zero — the ceiling is pure GPU compute in the expert path, and the decode-side profile confirms what the Q2_0 comparison suggested:
quant.metal,deq_tq<8>) lives on threadgroup gathers: per 16 weights, 4 IMAD hashes and 8 lookups into the 2048-point codebook. The repo's ownalu_benchon this M5 Pro measuresa_tgloadat 420 Gops/s vs ~3,700 for the integer ALU around it — the one operation the trellis path needs most is 6-9x slower than everything else.STRATA_METAL_F16=1(the LPR 16 / NR 2 trellis variant ofwindow.cpp:1192) measures 40.6 tok/s against 41.6 for the float path — neutral here.Ideas that would move the 44 → 50+ on this class of machine, in rough order of impact: expose or auto-tune NR 2/4 on the float path (
window.cpp:2468hardcodesgr = 1, so each unit is dequantized per row while the f16 variant already has an NR 2 form); a hot-expert fp16 pre-dequantized cache in the ~8.8 GB of VRAM that stays free with the full expert cache (the routing is concentrated enough for the profile fill to matter); a per-phase--spec-min-p(thinking accepts far better than the sampling-temperature-1 answer phase).None of this is a bug — the trellis tax is structural to the format, and the same machine keeps a bigger Q2_0 at 66 tok/s resident. Happy to test any of these on this Mac if a branch exists.
@Flo5k5 commented on GitHub (Nov 4, 2026):
Update: the DFlash2 drafter does run on Metal — we had it compiled out.
Our first engine build came from a branch without commit
1d36e65a("metal: DFlash2 drafter on the Metal window"), so the engine silently ignored--draft dflash2, the host remembered the failure and stripped the flags, and yesterday's "DFlash2 wins nothing" measurement was actually the suffix drafter alone. After rebuilding (0.1.56-metal) and placing the pack where the host looks for it (<data-dir>/dflash2/qwen3.8-flash-next-dflash2.q8.pack+draft_vocab.bin; our hand-packed 725 MB file is the accepted legacy Q8), the engine logs "DFlash2 drafter on".Re-run duel, same machine, same engine build, same standard bench (full expert cache,
--spec 4,--suffix-draft 8,--pool-workers 4):DFlash2 wins all three cases (+4% mean) with a measured acceptance of 96/143 = 67% against the MTP's 43-52%. Wider windows (
--spec 6 --draft-cap 8) lose everywhere (38.1 mean): the verifications past 4 tokens cost more than they return even at 67% acceptance. First answer 2.3 s and zero capped requests on this build — the 0.1.51-56 fixes to the thinking cap apply to both drafters.Two notes that might save others an hour: the engine gives no error when
--draft dflash2is compiled out (it just runs without a drafter and the host falls back), and the host's pack lookup only sees<data-dir>/dflash2/, not the cwd the engine reads--draft-modelfrom.@Flo5k5 commented on GitHub (Nov 4, 2026):
Follow-up with numbers: the resident plan arbitrates experts against the context on its own, and the cost is measurable.
Setup: same M5 Pro 64 GB, Gyro-M TQ2_0,
--expert-cache 24576 --mmap-experts --draft dflash2, only--max-contextchanges.A real 43,232-token request was read at 605 tok/s and answered (no refusal, KV grows on demand; the full
--kv-growpath is CUDA/HIP-only - no vmm on macOS - but the non-elastic path already serves 64K).So
recommend_context()'s 32K under 96 GB is not a memory wall: it is the choice of keeping every expert. The trade measured here: 64K costs ~21% of median decode speed (44.0 -> 34.7 on the standard bench, short windows hit hardest at -28%, 16K nearly flat) while the sanity suite stays 12/12. For our use (agent sessions that outgrow 32K), that trade is worth it; for pure speed, 32K integral remains the right pick. Trying 131072 next - the expected ceiling is the KV at peak (~30-70 KB/token from the parked-snapshot sizes).@Flo5k5 commented on GitHub (Nov 4, 2026):
The 131072 step, measured: it works end to end, and the marginal cost over 65536 is small.
So on a 64 GB Mac: 128K is a perfectly usable operating point for agent sessions, at roughly -25% decode vs the all-experts 32K. The next wall should be the KV at peak somewhere past this (a 256K window would ask 8-18 GB of KV on this model, more than the plan leaves beside the arena).
Our production profile moves to 131072. Thanks for a plan that arbitrates on its own - it made this a one-flag experiment.
@Flo5k5 commented on GitHub (Nov 4, 2026):
The 262144 verdict, for completeness: it works - with a twist worth knowing.
So the practical map on a 64 GB Mac is: 32K all-experts (44 tok/s) - 64K (88%, 34.7) - 128K (85%, 33.0) - 262K declared and serving (79%, LOW warning, stalls possible under mixed load). The recommended operating point stays 131072 (the LOW warning is the engine saying it has no slack left), but the window is not a wall anywhere.
@Flo5k5 commented on GitHub (Nov 4, 2026):
One more decode lever found in the tree, and a measurement caveat for everyone benching the standard suite on a laptop-class Apple Silicon.
@Flo5k5 commented on GitHub (Nov 4, 2026):
The remaining decode idea, as a design (the one lever the tree does not have yet): a second expert-cache tier holding the hottest experts PRE-DEQUANTIZED to fp16.
Measured grounds: the verify window is 100% GPU (47.1 ms/window, everything else at 0), and its cost is the TQ2_T trellis dequant - threadgroup gathers into the 2048-entry codebook (a_tgload ~420 Gops/s on this M5 Pro against ~4900 for the FMA path). The profile already ranks all 24,576 experts by routing frequency, and at 32K with every expert resident the boot leaves ~7.5 GB of VRAM free.
The tier: ~8 GB of fp16 holds ~800 experts (a Gyro-M expert is ~1.25 MB in TQ2_T, ~9.7 MB in fp16). The verify's gate/up/down read the hot expert as a plain fp16 GEMV - no codebook gathers - and fall back to the trellis path for the rest. If the top ~800 of a MoE's routing distribution carries a Pareto-sized share of the activations (the profile would say exactly how much), the dequant-bound verify gains that share almost free; boot pays a one-time GPU dequant of 8 GB.
The questions the design leaves to the code's owner: whether the tier lives beside the arena's slots or in its own allocation, how the ranking follows runtime heat (the profile is static; R4's hit counters already measure the real one), and whether the swap granularity is per-expert or by batch.
For the record, everything else in the decode path on this machine is already optimal-by-default: STRATA_METAL_GEMV_NR=2 (above), CTAB, FUSE, GDN_FUSE, GEMM_TILES and GYRO_TILES are all on unless turned off - the remaining headroom is this tier, or the trellis kernels themselves.