Repository navigation
feat(qwen3_5): image entries and the draft need in the Splash 1.6 take order (S18b2) - #347
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. |
9533d3f to
837e50b
Compare
e85d349 to
61602e8
Compare
3374b50 to
8099193
Compare
…e order Image feature entries become the Rebuild stage of `free_for_kv`, and a refused draft fit becomes its own claim with its own entry, `free_for_draft`, over the same skeleton as Splash `MemoryLedger::free`: a need met in place takes nothing, a count that cannot cover it takes nothing, else units go oldest first until it is met; a unit that frees nothing is passed over. What changes: - Rebuild stage (Splash `Order::Stage` Rebuild, the `embeddings` pool): a vision cache entry nothing outside the cache holds (`Arc::strong_count == 1`, Splash's `use_count() > 1` floor) is a unit, least recently used first (`release_one_unheld`). `free_for_kv` takes one only when the state/owner walk is empty, and adds the unheld bytes to the count, both only below the block cap: a pool unit gives bytes and never meets a need of pages alone (Splash `Lacking::meets`). - `KvNeed.rebuilt` is Splash `TakeRights::rebuiltPools`; `in_place` sets it, as every caller is an `InService` or `Start` claim. - A VLM turn holds its image features (`vlm_prepare_vision_features` returns them) until the prefill that reads the merged embeddings is evaluated, then drops them before decode (Splash `Runtime::prefillAsync` gives an image's rows to the cache once they are in). Dense and MoE, both paged VLM turns each. - Path A (scheduler): `SchedReclaim` and the dense and MoE backends expose `rebuilt_bytes` / `release_one_rebuilt`; `capacity_exhausted` names the image features as KV units below the pool's max only, and the idle owners as the only draft units. - Path B (flat DFlash2 lane): `flat_kv_in_reach` counts the unheld image bytes; `flat_reclaim_one` takes one image entry only after its whole state/table walk is empty; `KvGrowth.released_vision_entries` is logged. - Draft need: a short draft fit records `DraftRefusal` (bytes, rows) in the adapter beside the KV refusal (Splash `MemoryLedger::refused`); `reserve_speculative_step` clears its own record first and `clear_refusals` clears both maps each step. `free_for_draft` reads the shortfall live at the recorded rows over the running turns and the preempted one (`DraftUnits`), counts what the idle owners give (released blocks times bytes per block, plus parked rows) and takes idle owners by their own stamps. - One `MetBefore<(SeqId, StepNeed)>` (Splash `Engine::allocate`'s `met` list) serves the KV and the draft need of one blocked step; both are served in one reclaim. A blocked qwen3_5 step with no record of either kind takes nothing: the lowest-SeqId owner loop is gone there. mlx-node choices (labelled): - Image entries are the only Rebuild unit. Taking one costs a re-encode Splash never pays: `vlm_prepare_vision_features` encodes every image of the prompt before the prefix plan, with no cached-prefix length, so a dropped entry is re-encoded on every later turn that sends the image, even when the restored KV prefix covers it. Splash's restore releases the images `ModelRequest::restoredTokens` covers and never needs them again. This is an mlx-node gap; it bites only below the cap, once no state or owner is left. - A locked vision cache reads as `u64::MAX` unheld bytes (unknown): the count may over-count, never under-count. Only the model thread locks it today. - A turn holds its features through the returned clones, not a protected key set. - The rebuild right is a field no production caller sets false. - The draft need has its own entry: the KV count measures blocks, the draft fit measures pool-budget bytes. - Draft units are idle owners only (tables and rows). Store, ladder, history and image entries are left out: the draft fit charges only pool bytes, so dropping them moves no number it reads (Splash's Rebuild pools do serve a state need with refused bytes). - The draft shortfall is re-read live; Splash's need is the recorded refused bytes. - The flat transient loop and the flat-vision pre-evict take no image entry: they run without a count. Gaps: "unheld" is the Arc count, so an MLX graph that still reads a feature buffer after its turn dropped it is not seen; `kv_staging`, `vision_arena` and the hot block cache have no unit; no `Growth` claim or priority tiers, so `rebuilt` is always true; the draft need has no state unit, extent cut or grow, and the fit counts marked chains no draft unit frees; RAM states hold no straddled image rows (`holdStraddledRows`); no test runs a whole qwen3_5 VLM turn, so the four held bindings are pinned at the `vlm_prepare_vision_features` level only. Per family: qwen3_5 dense and MoE take image entries last below the cap and serve the draft need by idle-owner stamps. gemma4, qwen3, lfm2, nemotron_h, muse_glimmer, k2_horizon and qwen4_exp keep their owner loop (`reclaims_in_order` is false) and the inert trait defaults (`rebuilt_bytes` 0, `release_one_rebuilt` false); a draft record their scheduled speculation writes is cleared every step and never read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…re released settle_step restores the preempted turn's block and recurrent-state reservation flags before its reclaim: preempt_running_at clears them, but the turn's caches stay resident until handle_preempted releases them, so the draft need read with the parked turn left its state and bookings out and the idle owner stayed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
61602e8 to
3c1029d
Compare
…353) ## What Stage S36a of the Splash int8 KV alignment. It stacks on #347 (S18b2). The reference is Splash `9124ff2c` (1.6.0). `mlx convert` read one part of a split GGUF (`NAME-0000K-of-0000N.gguf`) and gave no error: the output held only that part's tensors. Now every GGUF entry that reads a single file refuses a lone split part, as Splash `GgufFile::GgufFile` does. ``` mlx convert / --mmproj / --draft ─┐ native prepare ├─> plan_gguf_import ─> reject_split (new, first step) from_asset_dir ─┘ family header check ──────────────────> reject_split, before the architecture check (new) draft preflight ──────────────────────> reject_split (new) native load GgufFileHandle::open ─────> reject_split (unchanged) ``` ## The rule (Splash `GgufFile::GgufFile`) - `split.count` (absent = 1) must be 1. A larger count is refused. The message names the parts (found with `resolve_gguf_shards`) and gives the `llama-gguf-split --merge` command. - `split.tensors.count` (absent = the tensors read) must equal the tensors in the file. - Only integer values count (u8..u64, i8..i64, bool), as Splash reads them. A string, float or array value counts as absent. - The file name is read by a hand-written parser. The split-aware loaders (Flash Next `index_gguf`, DeepSeek V4.1 `shard_paths`) do not reach these checks, so they still load split files. ## Labelled gaps - `split.count == 0` (what `llama-gguf-split --merge` writes) is accepted. Splash refuses it. - A lone-part `--mmproj` is refused only after the main conversion. No output is damaged, because convert stages its output. ## Tests 5 new tests (T1-T5), 8 named mutations, each red then green. Scoped `cargo test -p mlx-core --lib -- utils::gguf engine::checkpoint_source convert::`: 492 passed. `cargo fmt --check` and `cargo clippy --all-targets -D warnings` are clean. Docs: `docs/convert-quantize.md` (trap 13 removed, guard row added), `docs/cli.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
What
Stage S18b2 of the Splash int8 KV alignment. It stacks on #346 (S18b1). The reference is Splash
9124ff2c(1.6.0).It adds the two units that S18b1 left out of the take order:
What changes
Arc::strong_count == 1) is a unit. The oldest goes first, and only after the state and owner walk is empty (SplashOrder::StageRebuild,TakeRights::rebuiltPools). It never meets a pure page need (Lacking::meets).Runtime::prefillAsync). This applies to dense and MoE, in both paged VLM turns.DraftRefusal, next to the KV refusal (MemoryLedger::refused).free_for_draftreads the shortfall live and takes idle owners by stamp.MetBefore<(SeqId, StepNeed)>serves both kinds of need. A blocked qwen3_5 step with no record takes nothing, so the old lowest-SeqId owner loop is gone.mlx-node choices and gaps (labelled)
u64::MAX), so the count can over-count but never under-count.Families
Tests
cargo fmt --checkandcargo clippy --all-targets -D warningspass.cargo test -p mlx-paged-attn --libpasses: 213 tests.cargo test -p mlx-core --lib, run over every touched family and module, passes: 2635 tests.CI does not run on this PR until its base is
main.Review round 1 (2026-11-09)
837e50b54:Scheduler::preempt_running_atclears both reservation flags beforesettle_stepreclaims for the parked turn, while its caches stay resident. The parked turn now gets both flags back before the reclaim, asreinstate_runningdoes, so its draft state and bookings count. Tests run through the realpreempt_running(victim refused, peer refused); 4 named mutations.🤖 Generated with Claude Code