Repository navigation
fix: refused GDN rungs stay bounded per sequence; portable prefill pieces and q offset views - #380
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. |
A host that refused RAM for ladder rungs kept every refused rung as live MLX state until the turn ended, outside the governor's reclaim units: up to one rung per ladder step through decode. The sidecar capture anchors on the deepest checkpoint the persisted chain reaches, so the turn now keeps one refused rung, the deepest, and a deeper refusal replaces it. A reference impl of the lineage trait is now generic. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he cold tier MoE dropped a ladder rung the #374 governor refused, so on a host short of spare memory no MoE recurrent state reached the cold tier. Mirrors the dense fix (Splash publishStateToDisk): the deepest refused rung is held for this turn's sidecar capture and dropped at every turn end. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… one at a time
Two defects in the bf16 piece loop of the portable prefill:
- A piece past the first was a query view at a nonzero offset. When the
parent buffer is within 16 KiB of the piece, MLX `contiguous` keeps the
view, and the varlen primitive refuses it ("q must have offset 0; got
offset 14336" for an 8-row verify block at 131,072 tokens). Each piece
now takes a deep copy when the chunk has more than one piece.
- Every piece allocates its own partials and frees them only when its
command buffer completes, so a lazily built chunk held all pieces'
partials at once (293 MB peak for 16 pieces at 16K tokens vs 34 MB).
Each piece but the last is now evaluated before the next is built.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The held refused rung was one slot for the whole model. Under continuous batching two sequences overlap: B's deeper refused rung replaced A's, and A's turn end emptied the slot before B's capture, so either sequence could lose its cold-tier sidecar (Splash publishStateToDisk). Dense and MoE now hold the deepest refused rung per scheduled sequence; a turn end captures and drops only its own, and releasing a sequence drops its rung. The key is the sequence, not active_cache_owner_id, which the scheduler sets only at admission. Session reset and invalidation still drop every rung. Co-Authored-By: Claude Opus 5.5 <[email protected]>
PagedAttention, PagedAttentionVarlen and PagedPrefillAttention refused
any q at a nonzero byte offset. The FFI's lazy contiguous(q) aliases a
row-contiguous view when its parent buffer is within 16 KiB of it, so a
sliced q reached eval_gpu at an offset and aborted ("q must have offset
0; got offset 14336"). Every kernel binds q through set_input_array,
which adds the array's offset, and no host code reads q, so the offset
is safe: q (and the prefill's staged q) now only needs row contiguity
and an offset of whole heads, the q alignment the kernels already
address. Pools, scales, metadata and workspace keep the zero-offset
rule.
The portable bf16 prefill's per-piece deep copy, which worked around
this for its 1-row piece at 131,072 tokens, is removed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The turn-end sidecar capture anchors only at or below the K/V chain the turn's capture walk persists, and that walk adds at most its per-turn block budget past the chain already on disk. Holding only the deepest refused rung lost every usable rung when that rung sat past the walk's reach: on a host short of spare memory the qwen3_5 restart parity e2e wrote no sidecar (boundary_skips=2, restore anchored at 0). Each sequence now holds at most two refused rungs: the deepest, and the deepest at or below the reach predicted from the walk's own inputs (the blocks on disk plus the per-turn block budget). Dense and MoE. Co-Authored-By: Claude Opus 5.5 <[email protected]>
940c091 to
2f37a38
Compare
…ts (#381) `lfm2_paged_vs_flat_greedy_token_parity` failed once on the CI VM (run 43384271735, PR #380) and passed on rerun of the same commit: ``` prompt #1 "What is 2 + 3? Answer with just the number." FLAT (32 tokens) "The sum of 2 and 3 is" PAGED (32 tokens) "" ``` A bisect under a local runner simulation could not reproduce it (main → #380 head: 9/9, byte-identical output; 12/12 under a two-process stress), and #380's code does not reach LFM2 (instrumented: 0 portable prefill calls, all 16,001 `q` checks at offset 0). The failing VM run was 2–6× slower than its siblings from the bridge test on. The panic message could not tell the two candidate causes apart: - NaN logits collapsing to the pad token (a real defect), - a thinking block that never closed within 32 tokens (a near-tie on the VM's numerics). It now prints, for both paths: `raw_text`, `thinking`, `reasoning_tokens`, `prompt_tokens`, `cached_tokens`. Test-only change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
Follow-up to #377. Fixes the Codex findings on #377 and the gaps found while fixing them.
Changes
qwen3_5/qwen3_5_moegdn_prefix.rs: a refused rung is held ingdn_unclaimed_rungs: HashMap<Option<SeqId>, Vec<_>>(key =active_scheduled_seq,None= serial lane).hold_refused_rungkeeps at most two per key: the deepest, and the deepest at or below the predicted capture reach. The reach comes fromColdTierWalk::capture_reach, which probes the same K/V chain keys and per-turn block budget ascapture_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_statedrops 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.paged_kv_cache_adapter.rsportable_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,PagedAttentionVarlenandPagedPrefillAttentionaccept a row-contiguousqat a non-zero offset that is a whole number of heads. Every kernel bindsqthroughCommandEncoder::set_input_array, which addsa.offset(); no host code does pointer math onq. 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 insideContiguous::eval_gpu.Tests
qwen3_5_cold_tier_restart_parityunder 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).cargo +1.100.0 clippy --workspace --all-targetswith warnings denied: clean. Touched modules' tests green.Not in this PR
active_cache_owner_idonly at admission, so an overlapped sequence's capture can filter by the wrong owner. S13 replaces this capture path.🤖 Generated with Claude Code