mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2645] [Engine] Metal: opt-in fp16-slab expert path (mpp) for streaming prompt chunks #4189
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#4189
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2645
Author: @catalinb13
Created: 10/15/2026
Status: 🔄 Open
Base:
main← Head:metal-prompt-moe-mpp📝 Commits (10+)
b158818metal: the request's sampling (the CUDA sampler's chain, on the CPU over the window's head logits)0d6e5batests: tools/metal_sampling_test.py (the request's sampling through --serve: reproducible seeds, picks draw for draw against a reference sampler on the dumped logits, penalties, logit_bias) and metal/tests/engine/host_sampler_parity.cpp3a49b02docs: Mac sampling (MAC.md Sampling: the keys, the order, seeds, the host pick's cost, greedy vs sampled decode)093ed30metal: release prompt scratch buffers before workspace growth02e9f27fix(serve): stop reporting stale cache occupancy after refused parkingb9252edMerge current main and exercise prompt growth without caller autorelease pools9844762conversation cache: --conversation-cache-min-tokens WRITE[,READ] gates parked reads1be9c7dmetal: opt-in fp16-slab expert path (mpp) for streaming prompt chunks1d7f1b5gap harness + attribution rounds 1-4; kprof gate reverted to baselinea9b951bmetal: M1 Max A/B hooks (STRATA_METAL_GEMV_TILE/MOE_TILE/GDN_SCAN); decode copy-overlap on by default on Metal📊 Changes
341 files changed (+53789 additions, -1723 deletions)
View changed files
📝
.gitignore(+3 -0)📝
docs/BATCHING.md(+77 -2)➕
docs/DECODE_2X_PLAN.md(+179 -0)📝
docs/DETAILS.md(+2414 -1196)📝
docs/MAC.md(+257 -238)➕
gap/arms-base.txt(+13 -0)➕
gap/arms-final.txt(+7 -0)➕
gap/arms-kprof.txt(+2 -0)➕
gap/arms-needle.txt(+5 -0)➕
gap/arms-needle2.txt(+7 -0)➕
gap/arms-needle3.txt(+2 -0)➕
gap/arms-profile.txt(+9 -0)➕
gap/arms-round10.txt(+9 -0)➕
gap/arms-round11.txt(+9 -0)➕
gap/arms-round12.txt(+7 -0)➕
gap/arms-round13.txt(+15 -0)➕
gap/arms-round14.txt(+13 -0)➕
gap/arms-round15.txt(+13 -0)➕
gap/arms-round16.txt(+17 -0)➕
gap/arms-round17.txt(+15 -0)...and 80 more files
📄 Description
Adds the measured M1 Max streaming-decode work on top of the mpp prompt path and the v0.1.45 merge (see commits; the earlier description covered mpp only):
Device-flag cut handshake, now the default (
STRATA_METAL_CUT=eventopts back)The decode window's 48 per-layer cuts used an MTLSharedEvent signal+wait pair inside the window's command buffer. On the M1 Max that costs 230-400 us per cut because the queue stops and re-arms at every wait (worst around indirect dispatch chains: +170 us, measured with
metal/tests/dispatch_lat, rowsseg ...vsflag ...).Context::run_graph_flagreplaces it with two tiny kernels shipped inmetal/kernels/units.metal(cut_seqbumps a shared-buffer counter after each cut, behind the window's own barriers;cut_spinat each segment start waits for a plain host store) - the queue never stops and propagation measures ~90 us/cut.Measured on Apple M1 Max 64 GB, IQ3_XXS 47 GB pack, 40K ctx, t357,
--spec 2MTP, 33 GB pinned arena (gap/gap.sh, armsgap/arms-round25.txt/26.txt, results ingap/results/1018-1534and1018-1545): 3x3 interleaved flag/event + a default-vs-opt-out sandwich. Decode 19.5-20.3 -> 29.97-30.49 tok/s; T=2 window 87.8 -> 56.0 ms, at the busy+miss floor (~55.5 ms: kernel busy 48.6 + 8.6 misses x 0.8 ms). All eleven arms produce byte-identical outputs (128-token output line md5956dbac3e10818130ee6a82d3327f688).Read-ahead depth 12 for big-expert packs (default;
STRATA_METAL_PREFETCHopts out)stream.cppdefaultbig ? 6 : 10->big ? 12 : 10(big = experts >1.5 MB). 7 candidate vs 7 anchor arms (rounds 21+22,gap/results/1018-1318/1329): decode misses 15.9 -> 8.6/window, window GPU 88.8 -> 83.0 ms, 19.0 -> 20.3 tok/s, +63 MB read/window overlapped behind the GPU, same md5. Depth 24 measured worse (aheads collide with urgent reads).Also in this push
docs/DETAILS.md: the two measured changes with their numbers, per the repo rules.vm.vm_page_filecache_minfloor moved the arena between arms and faked drift), per-arm filecache/free-page logging, progress output; dispatch_lat grows seg/flag/indirect handshake rows.What it leaves alone: the prefill path's timing (one big streamed chunk, handshake-free; warm prefill 49.5-49.99 event vs 50.9-51.1 flag tok/s, within drift), all CUDA/HIP code, and every non-stream default. Not tested on Apple hardware other than the M1 Max: the event-pair cost is a driver/queue property, so the win's magnitude may differ elsewhere;
STRATA_METAL_CUT=eventis the instant revert.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.