Repository navigation
fix(ci): main builds, e2e loads under the memory plan, and a GPU without MPP prefills through a portable path - #377
Conversation
- utils/functional.rs: the #348 sparse-MoE autograd fixture built Qwen3_5MoeConfig with paged_cache_initial_memory_mb and use_block_paged_cache, which #344 removed, and missed rope_scaling; mlx-core's lib and clippy did not compile. - The qwen3_5-dense e2e leg pinned paged_cache_memory_mb above what the memory plan allows on the 7 GB runner (181 MiB): p2_paged_thinking and qwen3_5_session forced 512, the cold-tier gate 1024. They now omit it and the plan sizes the pool. The cold-tier harness takes with_planned_pool(); every other family keeps its explicit size. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
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. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ds through a portable path
The hosted macOS VM ("no known Apple GPU family") cannot build the
tensor-op paged prefill pipelines, and since S10f they are the only
Qwen3.5 prefill / verify route, so the qwen3_5-dense e2e leg failed with
"paged_prefill_attention_q8_split_g4_d256 has no pipeline on no known
Apple GPU family".
The adapter now asks once per process (mlx_paged_prefill_mpp_builds,
cached in a OnceLock) whether every MPP pipeline builds. Where it does,
nothing changes. Where it does not, paged_prefill_attention attends the
same stored rows through the plain-Metal vLLM varlen kernel
(gather_kv_for_prefill_chunk_varlen). Splash has no such fallback.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 34d5b06228
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
On a GPU that cannot build the tensor-op prefill pipelines, a bf16 pool's varlen launch held partials for every row and every 512-token partition: about 1 GiB for 2,048 rows, 16 query heads, D256 at 32K tokens, against a priced workspace of 32.25 MiB. Above 87,041 (24 heads) or 130,561 (16 heads) tokens the preflight refused the chunk (INT_MAX). The fallback branch now runs a bf16 chunk's rows in pieces of floor(2048 / partitions) rows, the bound the varlen dispatcher already tiles an int8 pool to, each piece at committed + start, then concatenates the rows. Per piece, the partials plus the concatenate's output copy are at most the priced workspace for every history up to 1,048,576 tokens, and every piece passes the preflight. The shared varlen dispatcher and the int8 route do not change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The runner's stable toolchain moved to 1.100: clippy adds needless_range_loop and needless_bool hits, and cargo warns on the unused workspace mlx-core entry, which build.warnings denies. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cargo 1.100 moves build-script OUT_DIRs to build/<pkg>/<hash>/out and runs test binaries from there, with no deps/ folder. The metallib gate now parses both OUT_DIR forms (hand-written parser), and a prebuilt-MLX binary with no colocated mlx.metallib uses its own build's copy instead of the producer's baked METAL_PATH. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…old tier The #374 governor refuses Optional claims on a host short of spare memory (the 7 GB hosted runner). A refused dense GDN ladder rung was dropped, so nothing reached the cold tier and the restart restored nothing. Splash falls back to publishStateToDisk; the rung now stays for this turn's sidecar capture and is dropped at the turn's end. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ssified (#379) Base: `fix/main-ci-after-344` (#377, the main CI fix). Merge #377 first; this PR then holds one commit. ## What A native MLX/Metal error raised inside a lazy eval (kernel or pipeline failure, GPU OOM, command-buffer error) now reaches the Rust error that the turn returns, with MLX's own text. The scheduler's GPU-OOM check (`is_gpu_out_of_memory` → `note_gpu_oom`, Splash `NativeRuntime::executionFailed`) can then match it, fail the row `metal_out_of_memory:` and reset the ledger. This covers prefill, the first sample and every scheduler decode step. ## Why P0 (code-only probe, a throw inside `PagedPrefillAttention::eval_gpu`) showed the text survived only when the paged prefill layer barrier caught it. On the sample path and on every decode token read it was lost: - `ensure_readable` caught the throw and returned `false`. `item_at_int32` then reported `Failed to extract int32 scalar (array must have size=1)`, so the OOM check missed it and the ledger count stayed 0. - `mlx_synchronize` only printed to stderr. MLX throws a failed GPU command's error once (at the next encode, synchronize or event wait, `mlx/error.h`) and then clears it, so a dropped error is gone and the turn keeps running on what the failed command wrote. - `MxArray::eval` (`mlx_array_eval`) at the first sample, at the paged prefill chunk boundary and at the scheduler's decode sample (`batch_greedy_tokens`, the greedy MTP verify) swallows a wait-time error the same way. The decode epilogues then also fell back to per-row sampling on any error, which reads what the failed command wrote. ## Change ``` ensure_readable / mlx_synchronize ──catch──► per-thread native error slot ▲ (each item_at_* / synchronize entry clears it first) │ item_at_* ──false──► mlx_take_native_error (copy + clear) ──► "MLX eval failed in array_item_at_int32: <MLX text>" mlx_synchronize ──false──► synchronize_and_clear_cache_checked ──► "MLX synchronize failed in <context>: <MLX text>" eval_arrays_with_context ──Err──► "MLX eval failed in <context> while materializing N arrays: <MLX text>" │ hybrid scheduler: fail the row ──► settle_step ──► note_gpu_oom ──► metal_out_of_memory: … ; ledger count +1 ``` Scheduler decode step after this PR: ``` forward ──► greedy wave? ──yes──► argmax ──► eval "scheduled_greedy_sampling" │ │ shape/graph miss │ Err: every batched row fails (no fallback) │ └──► per-row sampling ◄───┘ Ok: tokens no └──► per-row samplers ──► eval "scheduled_sampling" │ GPU OOM: every row fails (no per-row retry) │ other Err: per-row retry (unchanged) speculative (MTP / DSpark / DFlash) verify ──► greedy: eval "scheduled_verify_greedy", Err fails every row ──► forced row: eval "scheduled_verify_forced" ──► per-row greedy accept: eval "speculative_greedy_accept" ``` - `crates/mlx-sys`: the slot in `mlx_common.h`; `mlx_synchronize` returns a status; `mlx_take_native_error`; the test hook `mlx_test_fail_next_native_call` (no production caller; the next eval, read or synchronize on this thread throws once). - `array/data.rs`: `item_at_{int32,uint32,float32}` attach the slot's text. `array/memory.rs`: `synchronize_and_clear_cache_checked(context)`. The public `MxArray::eval` signature is unchanged; the unchecked `synchronize*` helpers keep their old behaviour for every other caller. - `engine/hybrid_scheduler.rs`: the synchronize after a non-final prefill slice, after a replay slice and after the first sample is checked. The first sample is evaluated with `eval_arrays_with_context`. A failed batched greedy eval fails each batched row with the native text. - `engine/batch_sampling.rs`: `batch_greedy_tokens_or_fallback` returns `Result<Option<_>>`. A shape or graph miss still falls back to per-row sampling (`Ok(None)`); a failed eval or read is an error. In `evaluate_pending_samples`, a GPU OOM at the wave eval fails every row instead of the per-row retry; other errors keep the retry. - `engine/hybrid_scheduler/speculative.rs`: the greedy verify eval and the forced-row eval are checked; a failed greedy verify fails every row of the wave (tickets still commit with keep=0) instead of the per-row fallback. - `engine/dspark_turn.rs`: `accept_dspark_proposal`'s greedy argmax eval is checked (one line). It is reached on the scheduler decode path when the wave is mixed; the whole-turn DSpark caller shares it and already handles its `Err`. - `models/qwen3_5{,_moe}/paged_forward.rs`: the non-final chunk residual eval (text and VLM prefill) uses `eval_arrays_with_context`. This closes the #344 gap where the error was only logged. Per-step cost: the decode evals were already one sync eval each; the checked call adds the error test and a one-element handle `Vec`. ## Error text, before → after | failure | before (reaches the turn) | after | OOM matched / ledger | |---|---|---|---| | throw while encoding, first eval at the sample (P0 run B) | `Failed to extract int32 scalar (array must have size=1)` | `metal_out_of_memory: a GPU command exhausted Metal memory (MLX eval failed in scheduled_prefill_sample while materializing 1 arrays: [malloc] Unable to allocate 1073741824 bytes.); …` | no / 0 → yes / 1 | | error thrown at the batched greedy decode sample | swallowed; decode went on (or fell back to per-row sampling) | `metal_out_of_memory: … (MLX eval failed in scheduled_greedy_sampling while materializing 1 arrays: [malloc] …); …` | no / 0 → yes / 1 | | GPU OOM at the non-greedy sampling wave | per-row retry sampled what the failed command wrote | every row: `MLX eval failed in scheduled_sampling while materializing N arrays: [malloc] …` | no → yes | | error at the greedy MTP verify eval | swallowed; per-row acceptance went on | every row: `MLX eval failed in scheduled_verify_greedy while materializing 1 arrays: <MLX text>` | no → yes | | decode token read (`item_at_int32`) | `Failed to extract int32 scalar (array must have size=1)` | `MLX eval failed in array_item_at_int32: [malloc] Unable to allocate …` | no → yes | | error thrown at the synchronize after the sample | stderr only; the turn went on | `metal_out_of_memory: … (MLX synchronize failed in scheduled_prefill_sample_sync: [malloc] …); …` | no / 0 → yes / 1 | | error at a dense or MoE prefill chunk eval | trace file only; the next chunk ran | `MLX eval failed in paged_prefill_chunk while materializing 1 arrays: <MLX text>` | no → yes | | throw at the layer barrier (P0 run A) | already carried the text | unchanged | yes / 1 | ## Tests and mutations Each mutation was a runtime switch in one test build, checked red with the switch on and green with it off, then removed (`git grep MLX_MUT` = 0). A mutation at a checked eval or synchronize still calls the checked function and only drops its result, so the injected throw is consumed exactly as a swallowing caller would. | test | mutation (→ red) | |---|---| | `array::data::native_error_tests::a_failed_read_carries_the_native_error` | F1_ITEM: a failed read drops the native text | | `array::data::native_error_tests::a_stale_native_error_never_attaches` | F1_STALE: `item_at_*` does not clear the slot first | | `array::data::native_error_tests::a_failed_synchronize_returns_the_native_error` | F1_SYNC: the checked synchronize ignores the status | | `engine::hybrid_scheduler::tests::a_native_gpu_oom_at_the_first_sample_fails_the_turn` (sample eval + synchronize; checks the `metal_out_of_memory:` reply and ledger count 1) | F1_SAMPLE_EVAL, F1_SCHED_SYNC: the checked call's result is dropped | | `engine::hybrid_scheduler::tests::a_native_gpu_oom_at_the_decode_sample_fails_the_turn` (batched greedy decode; `metal_out_of_memory:` reply, ledger count 1) | F1_GREEDY_EVAL: the greedy eval's result is dropped; F1_GREEDY_FALLBACK: a failed greedy eval falls back to per-row sampling | | `engine::batch_sampling::tests::a_native_error_at_the_greedy_eval_fails_the_wave` | F1_GREEDY_EVAL, F1_GREEDY_FALLBACK | | `engine::batch_sampling::tests::a_gpu_oom_at_the_sampling_wave_fails_every_row` | F1_SAMPLING_RETRY: a GPU OOM at the wave is retried per row | | `engine::hybrid_scheduler::speculative::tests::a_native_error_at_the_greedy_verify_fails_the_row` (Qwen3.5 native MTP) | F1_VERIFY_GREEDY: the verify eval's result is dropped | | `models::qwen3_5::model::paged_construction_tests::a_failed_dense_prefill_chunk_eval_fails_the_prefill` | F1_CHUNK: the chunk eval's result is dropped | | `models::qwen3_5_moe::paged_forward::tests::a_failed_moe_prefill_chunk_eval_fails_the_prefill` | F1_MOE_CHUNK: the chunk eval's result is dropped | Fault injection uses `mlx_test_fail_next_native_call`. It follows the repo's existing `bridge_testing` per-thread test-flag pattern, so it is a permanent hook, not an `MLX_MUT` switch. In Rust, `fail_native_call_at(context, text)` arms it only for the checked eval or synchronize with that context. That Rust code is `#[cfg(test)]` only. The C++ check on the hot path is a single empty-string test of a thread-local. ## Gates | gate | result | |---|---| | `cargo fmt --all --check` | pass | | `cargo clippy --workspace --all-targets -- -D warnings` | pass | | `mlx-core --lib` (full, one build, `--test-threads=1`) | 4833 passed, 0 failed, 221 ignored | | `cargo test -p mlx-paged-attn --lib --tests` | 16 binaries (211 lib), 334 passed, 0 failed | | `cargo test --workspace --test '*' --no-fail-fast` | 112 binaries, 323 passed, 0 failed, 193 ignored | | `#[napi]` surface | unchanged (no `index.d.cts` change) | | Live T=0 smoke, qwen3.5-0.8b bf16, 48 tokens, `MLX_PAGED_PREFILL_CHUNK_SIZE=64`, whole-turn and `MLX_CONTINUOUS_BATCHING=1` | byte-equal before (#377 base) / after in both modes (gate build profile, no fat LTO) | ## Not covered - A real command-buffer failure (`[METAL] Command buffer execution failed: Insufficient Memory`) is not reproduced. The tests inject the throw at the native entry point, which is where MLX raises such an error. MLX's ordering (stored on the encoder, thrown once at the next encode, synchronize or event wait) is from reading `device.cpp` and `error.h`. - The synchronize after a non-final prefill slice and after a replay slice, the VLM chunk evals (dense and MoE), the forced verify row eval and the per-row greedy DSpark accept get the same one-line change but have no dedicated mutation test. - A non-OOM failure at the non-greedy sampling wave still retries per row (the existing row-isolation contract). Only a GPU OOM skips the retry. - Other swallowing `MxArray::eval` sites (MTP prompt-hidden evals, whole-turn `paged_turn`/`mtp_turn`/`dspark_turn` synchronizes, other families' whole-turn decode) are unchanged. Only the scheduler acts on a synchronize status. - `to_float32/int32/uint32` and the `probability_*` readers do not attach the text, since they are not on the token path. The slot never leaks into a later `item_at_*` or synchronize because both clear it on entry. ## Review notes - Rejected (local Codex): "an already-signaled failed event is detached without its error". On the pinned MLX, `array::is_available()` → `detach_event()` → `event.check_error()` (`mlx/array.h:417`, upstream #3742) throws the stored error; the completion handler stores it (`device.cpp:766`) before signaling (`:773`). So the checked eval returns Err. - Known gap, not measured: an eval that spans several command buffers, where an earlier buffer fails and the last succeeds, can pass its wait before the handler marks the event; the error then surfaces at the next encode on that stream (one step late through a checked eval, lost through an unchecked `MxArray::eval`). Upstream's blocking `Event::wait` has the same window. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
…eces and q offset views (#380) Follow-up to #377. Fixes the Codex findings on #377 and the gaps found while fixing them. ``` host short of spare memory (7 GB runner): #374 governor refuses Optional claims GDN ladder rung refused ──► #377: kept for the turn's cold sidecar capture this PR: at most TWO held rungs per scheduled sequence — the deepest, and the deepest within the reach this turn's K/V capture walk can get — cleared at that sequence's turn end; MoE gets the same fix GPU without MPP prefill pipelines ──► portable varlen prefill bf16 rows in pieces ──► each piece is evaluated before the next (workspaces no longer overlap) piece = q view at an offset ──► paged reads accept a q view at a whole-head offset (all callers) ``` ## Changes - `qwen3_5` / `qwen3_5_moe` `gdn_prefix.rs`: a refused rung is held in `gdn_unclaimed_rungs: HashMap<Option<SeqId>, Vec<_>>` (key = `active_scheduled_seq`, `None` = serial lane). `hold_refused_rung` keeps at most two per key: the deepest, and the deepest at or below the predicted capture reach. The reach comes from `ColdTierWalk::capture_reach`, which probes the same K/V chain keys and per-turn block budget as `capture_chain` (blocks already on disk are free); with no cold tier only the deepest is held. The capture reads only the finishing sequence's rung; its turn end removes only that entry; `release_scheduled_recurrent_for(seq)` drops a vacated sequence's rung; `clear_reuse_state` drops all. The bound is two extra rungs per live sequence (was: every refused rung of the ladder, held through decode, outside reclaim). Deepest-only failed the e2e on the runner: the harness captures 12 blocks per turn, so the reach (192–768 tokens) was below the deepest rung (1248) and no sidecar was written. - MoE: a refused rung was dropped, so no MoE rung reached the cold tier on such a host; it now follows the dense rule. - `paged_kv_cache_adapter.rs` `portable_prefill_attention`: every bf16 piece but the last is evaluated before the next is built. Measured on 16 pieces: peak growth 293.7 MB → 34.3 MB (one piece's partials 17.0 MB). - `mlx_paged_ops.cpp`: `PagedAttention`, `PagedAttentionVarlen` and `PagedPrefillAttention` accept a row-contiguous `q` at a non-zero offset that is a whole number of heads. Every kernel binds `q` through `CommandEncoder::set_input_array`, which adds `a.offset()`; no host code does pointer math on `q`. Pools, scales, block tables, seq lens, cu_seqlens and workspace keep the zero-offset rule. A copy in the FFI could not work: the alias appears only inside `Contiguous::eval_gpu`. ## Tests - `qwen3_5_cold_tier_restart_parity` under a local runner simulation (portable prefill, 5,010,305,024 B working set, 7 GiB host with 2.5 GiB spare): FAIL before this fix (`boundary_skips=2`, anchored at 0, as CI run 43378257889), PASS after (cached 64 / 304 / 304, `installed=2`, anchored at 304), PASS without the simulation. - `a_refused_rung_within_the_capture_reach_reaches_the_cold_tier` (+ MoE twin), `a_rung_refused_ram_still_reaches_the_cold_tier`, `moe_rung_refused_ram_still_reaches_the_cold_tier`, `overlapped_sequences_each_send_their_refused_rung_to_the_cold_tier` (+ MoE twin), `portable_prefill_pieces_do_not_hold_their_partials_together`, `portable_verify_pieces_at_long_context_attend` (8 rows at 131,072 tokens, piece 2 at offset 14,336), `paged_q_offset_view` (decode v1/v2, varlen v1/v2, int8 tiled, MPP prefill, off-head-boundary refusal). - One mutation per defect, each red when on and green when off, then removed: f1, f2, f3 (now q_offset), f4, H1, q_align, deepest-only. - `cargo +1.100.0 clippy --workspace --all-targets` with warnings denied: clean. Touched modules' tests green. ## Not in this PR - The scheduler sets `active_cache_owner_id` only at admission, so an overlapped sequence's capture can filter by the wrong owner. S13 replaces this capture path. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…art (#378) Stage S13 of the Splash int8 KV alignment (follows stack #344, now in main). Base: main. > This branch sits on #377 (main CI fix) and shows its 2 commits until #377 merges; then it is rebased onto main. Review only the last commit. DFlash2 states (GDN cell + 4-bit draft window) now get an SSD tier, on by default like Splash. An evicted state is written to disk and read back on a later hit. With `--persistent-cache` the tier stays across restarts. Splash: `StateCache` disk copies, `WriteBehind`, `SlotFile`, `openDiskTier`, `DiskSpace`. ``` before: evict state ──► gone (next turn re-prefills) qwen3_5 cold tier: off in serve; per-turn KV + GDN sidecar when on after: evict state ──► has disk copy? yes ──► free RAM now no ──► stage one write (NeedsWrite), free RAM now hit ──► RAM or disk (deepest) ──► read into lane ──► optional promotion tier: temp dir $TMPDIR/mlx-node-cache-* (default, auto quota ≤ 32 GiB) <cache-dir>/<namespace> + flock (--persistent-cache, adopted at load) stop: closeCache ──► one 6 s flush ──► temp dir removed ``` ## Changes - New `disk_tier.rs`: tier options, auto quota `min(32 GiB, room / 4)`, a namespace from the target, draft and window, temp vs persistent, a held lock, stale namespace removal at every start (Splash `CacheDirectory::removeStale`). - `cold_cache` (mlx-paged-attn): a `DFlash2State` object with spans `[cell, window]`, charged its file size (Splash `slotBytesFor(payload)`). A state lane goes before queued blocks. A non-space write failure stops tracked writes; ENOSPC / EDQUOT count as space errors. - Store entries hold RAM, disk or both, with one staging buffer and one write in flight. The memory plan sets the staging buffer aside (`state_staging_bytes`, Splash `stateStagingBytes`). - Ledger: `Victim.later`, uncopied runs and copy demand (60 s). An Immediate claim passes units that land later; a CanWait claim waits on a pending write. - Copy demand is Splash's first term: 2 × the pages the running lanes' next commands add beyond what they hold (`next_command_pages`, `Tick::Full { command_pages }`). - A disk state keeps its KV chain until the chain is on disk. A reclaim's chain goes before a copy ahead. - Write-behind (port of `WriteBehind`): ordinary points ≥ 2048 tokens due after 10 s; a persistent tier copies all, a temp tier only on copy demand; the state first, then its chain. - A refused capture goes to disk from the lane (Splash `publishStateToDisk`). - Restore takes the deepest RAM or disk state; the payload must equal the state size. A bad read discards the state and resumes lower. Promotion is Optional and Immediate. AR turns read disk states too. - Restart: `adopt_all` takes back states whose whole chain is on disk, after fitting the quota. - `closeCache` (napi, dense and MoE) flushes by a deadline. `serve` and `mlx agent` take `--max-cache-disk`, `--persistent-cache` and `--cache-dir`; the host closes every cache in one flush budget, and `mlx agent` stops serve after 15 s (`supervision.ts`). - `/health` `memory_governor.dflash2_states` gains the disk fields (entries, bytes, offloads, failures, promotions, publications, write-behind counts). ## Memory plan | plan | before | after | |---|---|---| | 27B int8 + DFlash2 window (unit-test estimate, tier Auto) | 221,177 | 212,985 | | state staging | – | 159,842,304 B | The window drops 8,192 tokens: the staging buffer of one state is now fixed. With the tier off the window stays 221,177. ## Deleted - `--no-persist-cache`, `persistPagedCache` (agent and override), qwen3_5 / MoE `persist_paged_cache` and their `MLX_PERSIST_PAGED_CACHE` reads. - The qwen3_5 per-turn KV and GDN cold sidecar path: `ColdGroup::GdnState`, the sidecar capture / install, `ColdTierContext.sidecar_policy` (now `ColdContextBacking`), qwen3_5 in `COLD_RESTORE_FAMILIES`, the qwen3_5 cold parity tests. - The GDN ladder retention (`want_ladder`, `GdnRetentionPolicy` Ladder, the same-owner victim search); 2 checkpoints per owner. - `Ledger::uncopied_need_bytes`, `SHUTDOWN_TIMEOUT_MS`, `SERVE_STOP_GRACE_MS`. ## Tests - 58 named mutations, each red when on and green when off: 53 Rust runtime switches on one test binary, 5 TS source edits. Examples: state charged the read bound (K81), state lane behind blocks (SL1), auto quota ignores room (DQ1), held namespace not locked (PL1), staging left out of the plan (SG1), `later` ignored by Immediate (LT1), failed copy kept (WF1), chain mark dropped at landing (CM1), write-behind copies without demand (WB1), no disk arm on a refused capture (DP1), a bad read not discarded (BR1), adoption without the whole-chain check (AD1), flush that writes nothing (FL3), reclaim chain behind a copy ahead (CY1), held blocks not subtracted (CP1), stale namespaces kept on a temp open (SC1), no quota fit at adoption (FQ1), write failure not stopping the tier (WS1), full volume not refused (FS1), replaced lock file (NL1), host flush budget per model (HC1), agent drops `--persistent-cache` (TSF1). - `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -D warnings`, `yarn build:native` (index.d.cts unchanged), `yarn typecheck`, `yarn tsc -b --force`, `vp fmt --check` and `vp lint --type-aware --type-check` on the touched TS files: clean. - `RUST_TEST_THREADS=1`: `cargo test -p mlx-paged-attn` (lib + tests) 337 passed, 0 failed; mlx-core `--lib` 4,829 passed, 0 failed, 218 ignored; `cargo test --workspace --test '*'` 281 passed, 0 failed, 191 ignored; the other crates' lib / bin tests 25 passed. - CI VM run (local switch, not committed: no Apple GPU family, paged prefill pipelines fail to build, 4,259,180,544 B working set; CI env): mlx-core `--lib` and `--test '*'` green after the skip below. - `vp test` on `__test__/cli`, `__test__/server`, `packages/{agent,cli,dashboard,lm}/__test__`, `packages/server`: 139 files, 2,936 tests passed, 8 skipped. ## Rebase onto main - `draft_context.rs`: main added `eval()`, S13 added `write_bytes` / `read_bytes`; both kept. `read_bytes` now evaluates with `eval_arrays_with_context`, so a failed read is an error before the bounds move (main's rule for `snapshot` / `copy_from`). - `dflash2_decode.rs` tests: main's `chunk_kv_is_booked_before_its_capture` and S13's disk tests both kept. The 8 new disk tests that prefill on the pool take main's `paged_prefill_unsupported` skip (they failed only on the CI VM). - `utils/functional.rs` (#348): its MoE test config named fields main no longer has (`paged_cache_initial_memory_mb`, `use_block_paged_cache`) plus `persist_paged_cache`, which S13 removes; it now lists main's fields (`rope_scaling: None`). This lib test target did not compile on main. - S13's deleted qwen3_5 cold parity tests and `retention_sim.rs`: main had not changed them. ## Gaps - No per-leaf KV demotion; a disk state writes its chain after itself (S23). - One object file per state or block, not slot files; a crash leaves the temp dir until the next start (S23). - No write budget (`--max-cache-disk-writes`) (S23). - Disk recency is the object's last access; no relabel at stop (S23). - Restore reads run on the model thread (S24). - SHA-256 over every object, not CRC-32C per segment. - Host staging copies from MLX arrays on write and on read. - A qwen3_5 load without a DFlash2 draft has no SSD tier. - Each loaded model opens its own tier and writer thread. - Copy demand has no growth term; a whole DFlash2 turn adds nothing between commands (S15). - Old `gdn_state` objects in `~/.mlx-node/cache/paged/v1` are not indexed or removed, and a crash between `mkdtemp` and the rename leaves a `.mlx-node-cache-new-*` dir. - No probation and no clean-end record (S23). - During a long DFlash2 turn an owed chain moves only between commands (S24). - The R2 lock test checks `named()` directly; the R1 space check is tested with a large reserve, not a real full volume. ## Not in this PR (live, not run) - L0 window and `/health` disk fields on the 27B GGUF, S vs S12; L1 restart survival with `--persistent-cache` (turn 2 reads the prefix back); L2 eviction writes under `--max-memory 22G` with the default temp tier, temp dir gone after stop; L3 decode speed S vs S12 (within 3%). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Why
main CI run 43254067201 (61e72da, after #344 and #348) failed three jobs.
tiny_moe_configinutils/functional.rsbuildsQwen3_5MoeConfigwith two fields #344 removed and missesrope_scalingerror[E0560]: struct Qwen3_5MoeConfig has no field named paged_cache_initial_memory_mb(functional.rs:2032), same foruse_block_paged_cache(2034)Qwen3.5: paged_cache_memory_mb 512 exceeds the 181 MiB of KV pool the model and this Mac's memory allow; omit it or set at most 181(p2_paged_thinking_honors_enable)Cargo stops at the first failing test binary, so the rest of the leg never ran. Two more tests in it had the same problem:
p2_paged_thinking_honors_enableqwen3_5_sessionqwen3_5_cold_tier_parity(harness)qwen3_5_delta_chat,qwen3_5_concurrent_batched_parityFix
functional.rs: droppaged_cache_initial_memory_mbanduse_block_paged_cache, addrope_scaling: None.persist_paged_cachestill exists on main and stays. The struct now matchesQwen3_5MoeConfigandtests/common/mod.rs.p2_paged_thinking_honors_enable,qwen3_5_session: stop writingpaged_cache_memory_mb, so the plan sizes the pool. The 512 was only there to keep the pool small, and the pool now grows by extents.paged_block_size = 16stays because the session test's prefix assertion depends on it.pool_memory_mbbecomesOption<u32>. The default staysSome(256), and the newwith_planned_pool()leaves the key out. The qwen3_5 gate uses it: the 181 MiB planned pool holds about 15k BF16 tokens, and the gate needs two prompts of about 1,260 tokens each. Measured:evictions=0.Other legs, checked:
qwen3_paged_vs_flat_parity,qwen3_cold_tier_parity,qwen3-paged-*.test.tslfm2_paged_vs_flat_parity,lfm2_cold_tier_paritygemma4_grouped_cold_tier_parity*_paged_vs_flat_parity,*_mtp_midcycle_stateLocal repro
Model:
yarn mlx download model -m Qwen/Qwen3.5-0.8B+yarn mlx convert -d bf16 -m qwen3_5, as in ci.yml. The runner's working set is simulated with an uncommitted, env-switched override ofmlx_max_recommended_working_set_sizeand therecommendedMaxWorkingSetSizeread inmlx_paged_dispatch.cpp. A working set of 5,010,305,024 B reproduces the CI message exactly (... exceeds the 181 MiB ...). The whole leg ran with the CI env (CI=true,MLX_METALLIB_STRICT=1,MLX_TEST_REQUIRE_METAL=1for lib_tests,QWEN35_STAGE2_MODEL_PATH+MLX_SCHED_MAX_NUM_SEQS=2for stage2,--test-threads=1), with--no-fail-fast.Gates
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test -p mlx-core --libcargo test --workspace --test '*' --no-fail-fast(MLX_TEST_REQUIRE_METAL=1)No TS changes.
Portable prefill path for GPUs that cannot build the MPP kernel (34d5b06)
Problem. Since S10 (#368) and S10f (#369), every Qwen3.5 dense / MoE prefill chunk and every MTP / DFlash2 verify block attends only through the MPP tensor-op kernel
paged_prefill_attention_{bf16,q8}_split_g*_d*. The hosted macOS VM cannot build those pipelines, so the e2eqwen3_5-denseleg failed:Fallback.
PagedKVCacheAdapter::paged_prefill_attentionnow goes one of two ways:mlx_paged_prefill_mpp_builds()tries to build all 24 MPP pipelines. If any build throws, the answer is false. Linux returns false. The answer is never taken from catching an error on a single call.paged_prefill_portable.kernels/prefill/paged_attention.metal,paged_attention_tile.h).Tests
portable_prefill_matches_the_tile_kernelcheckOutputbound. Pools: int8 and bf16. Geometry: g4/D128, g8/D256, g16/D256. Cases (committed, rows): (0, 40), (40, 24), (600, 9) (past the 512-token switch), and a 5-row verify. Largest difference between fallback and MPP: 0.25 (values carry ×60 outliers). On the VM it runs the fallback half only.prefill_routes_once_and_to_mpp_where_it_buildsportable_prefill_turn_matches_the_tile_turnpaged_attention_reads_its_own_rows_backMutations (one build, runtime switches, removed before the commit)
one tile launch per chunk, left 0, right 2committed - 1All three passed with the switch off.
VM simulation (uncommitted; removed). It forces the working set to 5,010,305,024 B, makes every MPP pipeline throw the CI error text, and makes
mlx_test_gpu_lacks_apple_familyreturn true. Each run is the fullqwen3_5-denseleg asci.ymlruns it.skippingskippingGates (logs in
/Volumes/PM9A1/claude-scratchpad/7e002cb3-kv-int8/fallback/)cargo fmt --all -- --checkgate-fmt.log)cargo clippy --workspace --all-targets -D warningsgate-clippy2.log)cargo test -p mlx-core --libgate-lib.log)cargo test -p mlx-paged-attngate-paged-attn.log)cargo test --workspace --test '*' --no-fail-fastgate-int.log)smoke-{before,after}-*.json)No
#[napi]change, so noindex.d.ctsupdate.Known gaps
rows × Hq × ceil(ctx/512) × (D+2) × 4 B. int8 is bounded by the kernel's 2,048 row-partition tiling.🤖 Generated with Claude Code