Repository navigation
Backlog
Description
Problem
Profiling Qwen4-35B-A3B-UD-IQ2_XS on Apple Silicon Metal (v0.2.20-poly.10 / df2c3ff, Apple M5 Ultra 256 GB, both full VRAM and simulated 16 GB partial-VRAM budgets) surfaced four independent bottlenecks:
- PLE 11.52 GB n-gram table on macOS / Metal:
per_layer_token_embd.weight(160M x 128IQ4_NL,72 B/row, 16 random rows/token) is whole-filemmap'd on Metal. With macOS 16 KiB VM pages, randommmaplookups pull at least 256 KiB/token into the unified buffer cache and thrash 16–24 GB Macs, whilestart_ple_warmer()has no macOS branch for 64–256 GB Macs. Related: [Engine] qwen4: read the PLE n-gram table row by row from disk through the Direct reader #440 and [Engine] qwen4: read PLE rows ahead: a decode window's while its guesses are drafted, a prompt's while its first layers run #465 (note [Engine] qwen4: read the PLE n-gram table row by row from disk through the Direct reader #440 currently falls back tommapon Metal). - Metal partial-VRAM host-GPU sync wall (
router wait~17–19 ms/tok):Engine::bell_on()returnsfalseon Metal, disablingwhole_rec_/gr_deferred_write_as soon as any expert is outside VRAM (!all_cached()) and forcing ~40 per-layer command buffer flushes + host waits per token. - Missing Metal Qwen4 decode fusions:
q4_gr_down_silu_quant(poly_mul_q8_0_k4+q4_gr_silu_1_1= 11.0% of full-VRAM decode GPU time) andq4_mul_sigmoid_q8_1are skipped on Metal (#if !defined(STRATA_GPU_METAL)), and routed-expertgate_upstill round-trips FP32g_beforeswiglu_rows_quantize_q8_1(poly_quantize= 4.0% GPU time). - 4K prefill QSA sparse attention hotspot:
q4_qsa_attend_batch_q8_8uses scalar per-element K/V reads and scalar FMAs, taking 515 ms (29.3% of total 4K prefill GPU time) at1.34 TFLOP/son M5 Ultra.
Split PRs (4 independent PRs, each against df2c3ff)
- [Engine] qwen4: add memory-aware PLE Direct reader (F_NOCACHE) and macOS warmer #473 (Draft) — PLE Direct reader (
F_NOCACHE) + async prefetch + macOS warmer (coordinates with [Engine] qwen4: read the PLE n-gram table row by row from disk through the Direct reader #440 / [Engine] qwen4: read PLE rows ahead: a decode window's while its guesses are drafted, a prompt's while its first layers run #465). - [Engine] metal: add MTLSharedEvent doorbell with defer-rank and watchdog-safe CB chunking #474 (Draft) — Metal
MTLSharedEventpartial-VRAM MoE doorbell + zero-bandwidthid < 0skip. - [Engine] qwen4/metal: fuse decode kernels, QSA score MMA, and overhaul Gated Residual #475 (Draft) — Metal Qwen4 decode fusions (
260-TGq4_gr_down_silu_quant,q4_mul_sigmoid_q8_1, routed-expert SRAMgate_up + SwiGLU + Q8_1). - [Engine] qwen4/metal: rewrite q4_qsa_attend_batch with simdgroup_matrix #476 (Ready) — Metal
q4_qsa_attend_batchsimdgroup_matrixrewrite (Metal-only 3 files; counterpart to CUDA [Engine] qwen4: QSA prompt attention for eight query heads a KV head from registers, the same bits #470).
Combined same-day A/B results (Apple M5 Ultra 256 GB, Qwen4-35B-A3B-UD-IQ2_XS, --kv q8_0 --lookup 0, df2c3ff vs combined 4-in-1)
| Scenario | Baseline (df2c3ff) |
Combined 4-in-1 | Gain |
|---|---|---|---|
Full VRAM --no-draft (192 tok) |
92.27 tok/s | 111.96 tok/s | +21.3% |
| Full VRAM Embedded MTP (192 tok) | 153.22 tok/s | 154.52 tok/s | +0.8% |
Full VRAM 4K prefill (4096 tok) |
2,488.2 tok/s | 3,425.1 tok/s | +37.7% |
Sim 16 GB dynamic LRU --no-draft (5.3 GiB VRAM, 6 threads, --ple-direct) |
23.08 tok/s | 32.67 tok/s | +41.6% |
Sim 16 GB dynamic LRU MTP (5.2 GiB VRAM, 6 threads, --ple-direct) |
25.39 tok/s | 30.79 tok/s | +21.3% |
Sim 16 GB frozen 65% + --ram-experts-mib 0 --no-draft (6 threads, --ple-direct) |
29.70 tok/s | 46.97 tok/s | +58.1% |
Sim 16 GB frozen 62.4% + --ram-experts-mib 0 MTP (6 threads, --ple-direct) |
40.63 tok/s | 57.60 tok/s | +41.8% |
Sim 16 GB frozen 65% + --ram-experts-mib 0 4K prefill (4096 tok, --ple-direct) |
2,039.5 tok/s | 2,570.3 tok/s | +26.0% |
Limits / unverified
- Hardware measurements above are on Apple M5 Ultra 256 GB (macOS, Release build); CUDA, HIP, SYCL, Windows, and Linux builds are not yet run. Physical 16 GB Apple M4 measurements will be added here once run.
Metadata
Metadata
Assignees
Labels
No labels
Activity