Repository navigation
fix(qwen3_5_moe): cap a verify stall at twice the fit, with no floor (Splash int8 align S28) - #355
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
556f86c to
0b664fb
Compare
0b664fb to
eb36d46
Compare
3717455 to
fb9a592
Compare
VerifyBudget::observe now counts a cycle as min(ms, 2*max(fit, mean)), with no lower bound, as Splash 9124ff2c does: a cap at the fitted price alone let one stall tilt the line so later cycles verified only their anchors. Cycles counted at under half their time raise one warning a minute, like Splash's cut notice. Co-Authored-By: Claude Opus 5.5 <[email protected]>
eb36d46 to
0f3c603
Compare
…ash2 budget (Splash int8 align S4) (#356) ## What Stage S4 of the Splash int8 KV alignment. It stacks on #355 (S28). The reference is Splash `9124ff2c` (1.6.0), `evaluateEngineMemoryPlan`. One memory plan now sizes the paged pool, both lane windows and the DFlash2 KV budget for qwen3_5 dense and MoE. It replaces three separate budgets (the 0.85 pool probe, DFlash2's 0.95 − 2 GiB then ×0.9, and `live_prefill_headroom`). ``` hard = WS − (15% + 1 GiB), lowered by --max-memory (S11: Splash max(1 GiB, 2%)) fixed = MLX active after load + other pools + 64 MiB staging + 256 MiB pipeline + 512 MiB runtime dynamic = hard − fixed lane = lane state + transient(W) + growth copy + KV(W + scratch), in whole extents ≤ dynamic window = min(trained, largest W that fits) ``` ##⚠️ Window change on a 36 GB M3 Pro (needs your review) The plan now charges what the old budgets left to the margin: Splash's 768 MiB reserves, the pool-growth copy, and the turn transients (verify partials and paged prefill attention). The margin stays 15% + 1 GiB until the governor (S11), as decided. Together this lowers the windows until S11: | M3 Pro inputs (27 GiB WS, 17,357 MiB active) | before S4 | S4 | with S11's 2% margin | |---|---|---|---| | AR / pool window | 78,464 | 48,601 | ~120K | | DFlash2 window | 139,257 | 61,433 | ~176K | | pool ceiling (1 MiB blocks) | 5,051 | 3,186 | ~7.7K | ## Prefill chunk ceiling Every qwen3_5 / MoE paged prefill (text, scheduler, serial, VLM) now runs in chunks of at most 2,048 rows, as Splash `ExecutionLimits::prefillTokenBudget` does, so the plan prices the chunk the engine runs. `MLX_PAGED_PREFILL_CHUNK_SIZE` above 2,048 is capped, and 0 (one shot) is gone for these families. CLI launchers already set 2,048. The pool budget subtracts the lane state first (Splash `availableForOneRequestKv = dynamic − laneStateBytes`). The scheduler still charges the GDN cell inside the pool too, so the AR window pays it twice versus Splash (50,585 if paid once); that is shared scheduler code and stays a labelled gap. ## Deleted (no compatibility path) `MLX_KV_MEMORY_UTILIZATION`, `MLX_KV_SAFETY_MARGIN_BYTES`, `DFLASH2_KV_HEADROOM_RESERVE_BYTES`, `MLX_PAGED_CACHE_INITIAL_MB` / `paged_cache_initial_memory_mb`, the qwen3_5 one-sequence pool cap, qwen3_5/MoE reads of `MLX_PAGED_PER_SEQ_CTX`, the TS overlay's 16,384 / 2,048 MiB defaults and `MLX_PAGED_CACHE_MEMORY_MB`. `MLX_PAGED_PER_SEQ_CTX` stays for the families outside this work. ## New - `--max-memory SIZE` (lower only) on `mlx serve` and `mlx agent`, through the host to `Qwen35LoadOptions.max_memory_bytes`. A value above the automatic budget is ignored with Splash's log line. - Load errors that name the limit: the plan cannot hold one lane and the runway; an explicit pool above the plan (16,384 MiB on the M3 Pro inputs → "at most 3,186 MiB"); the startup audit finds memory over the plan. - `/v1/models` before load: `estimateQwen35ContextWindow` plans from file sizes without loading. ## Splash gaps (labelled) - 27B lane: 355,217,408 B vs Splash 356,122,624 B (−905,216): no 4-bit draft window, a 2,311-row ring, no 16 KiB conv alignment. - Flash Next is FN1 (index plane, E1 64K allowance, E9 PLE share). - `--max-memory` reaches qwen3_5/MoE loads only. ## Tests Plan module: 18 tests, 25 named mutations. Wiring: 17 mutations. TS: new flag and overlay tests with mutations. Golden: WS 25,769,803,776 → hard 20,830,591,385 with mlx-node's margin (Splash's 24,696,061,952 recorded for S11; mutation "Splash margin" → red). - `cargo fmt --check`, `cargo clippy --all-targets -D warnings`: clean. - mlx-core `--lib` scoped: 784 + 379 passed; mlx-paged-attn profile 5 + 6 passed. - `yarn typecheck`, `vp lint` (21 files), `vp test` on 75 touched and importing files: 1,426 passed. `bge-native` fails at 2.7e-5 vs 5e-6: that is the NAX TF32 reranker drift fixed by #348 (not in this stack's base). - No live model run yet. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
What
Stage S28 of the Splash int8 KV alignment. It stacks on #354 (S27). The reference is Splash
9124ff2c(1.6.0).One stalled cycle could push the MoE DFlash2 lane into anchor-only verify cycles. The verify budget now counts a cycle as Splash
VerifyBudget::observedoes:meaniscost.time / cost.weightfor that width. A fast cycle counts at its own time. A cycle cut to under half its time prints onetracing::warn!line at most once a minute (Splashcuts_/nextNotice_).Only
qwen3_5_moe/verify_budget.rschanges. Dense qwen3_5 has no time cap.Tests
stalled_cycle_counts_twice_the_larger_of_fit_and_mean(both fit < mean and fit > mean)fast_cycle_counts_at_its_own_timeone_doubled_cycle_does_not_lock_verification_to_the_anchor: from the second cycle after a 2x stall, the width stays at its pre-stall value. Under Splash's own rule the first cycle after the stall drops to 2 rows; this was checked against SplashVerifyBudget.cppbuilt with clang++.Mutations: the 0.5x floor back, a cap at the line alone, and the old clamp: each turns its gate red.
cargo test -p mlx-core --lib qwen3_5_moe::verify_budget11 passed;qwen3_5_moe::dflash231 andqwen3_5::dflash2171 passed. fmt and clippy are clean.🤖 Generated with Claude Code