Skip to content

feat(kv-int8): a decoding lane waits at most 500 ms behind a prefill - #375

Merged
Brooooooklyn merged 4 commits into
mainfrom
feat/kv-int8-s33-measured-prefill-cut
Nov 12, 2026
Merged

Brooooooklyn merged 4 commits into
mainfrom
feat/kv-int8-s33-measured-prefill-cut

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Stage S33 of the Splash int8 KV alignment (stack #344). Base: S11 (#374).

Qwen3.5 dense and MoE now cut a prefill that runs beside a decoding lane. The cut is the rows the last timed unit says fit in 500 ms, so a decoding lane waits about 500 ms at most behind a prefill. Splash: Scheduler::planPrefill, cutRows, leadsBefore, decode debt, prefillAdmissionOrder. Every other family keeps the fixed 2048-row budget and plans exactly as before.

before:  one step = decode rows + prefill rows from ONE 2048-token budget (MLX_SCHED_MAX_BATCHED_TOKENS)
         a decoder beside a long prompt waits for a whole 2048-row prefill row every step
         leader = FCFS; admission = FCFS; no prefill timing

after:   one step = decode rows (outside the unit) + one prefill unit (leader + up to 3 joiners)
         no decoder  -> unit 2048 rows
         a decoder   -> unit = cut_rows(leader): 512 until a unit is timed, then
                        clamp(R_last * 500 ms / T_last * deeper, 512, 2048); a rest < 512 rides along
         after a contended unit the decoders are owed 0.5 x its wall (decode-only steps)
         leader = overdue (3 overtakes) oldest, then fewest remaining, then order
         a start is admitted only when the next unit serves it

Changes

  • engine::scheduler: PrefillUnit::{Fixed, Measured}. Fixed { budget } is the old loop. Measured ports cutRows, leadsBefore with MAX_OVERTAKES 3, the joiner rule (remaining − 1) % 2048 + 1 (skipped when it does not fit), at most 4 lanes (PREFILL_MAX_LANES), and the attention-pair bound dense_attention_pairs(native − 2048, 2048) (the leader halves down to 64 rows while above it). Cancelled rows and S11 waiters whose retry is not due never lead and never size the unit.
  • Measure: the step's prefill-phase wall, taken only when every planned row ran timed. A failed or untimed row sizes nothing.
  • Decode debt: a contended unit adds decode_share × wall to decode_debt_ms; decode steps pay it down; it drops when no lane decodes (Splash dropStaleDecodeDebt).
  • --decode-share <share> on mlx serve and mlx agent → host → loader → the qwen3_5 / MoE load option decodeShare. Parsed as Splash parse_decode_share (finite, ≥ 0). Default 0.5. The loader refuses it for other families.
  • Admission (hs): a start waits until serves_candidate says the next unit serves it. A live continuation counts the tokens it keeps. A held start takes Splash deferWait + deferAdmission: its wait resets and its ledger claim stops waiting. Held starts wait in their own queue in submission order and hold back nothing (Splash Engine::admitQueued: "The others wait for scheduling, and hold back nothing"), so a later short start is admitted past a held long one. Only a start refused memory or a lane holds back the starts after it. A held start keeps the submission order it took when first held, and each prefill unit that serves a later submission overtakes it (Splash Scheduler::complete), so after 3 it is overdue, leads and is admitted. A later turn of a held owner, a reset, a barrier or an exclusive command does not pass a held start. Held starts are not retried while a lane is suspended (Splash recovery tries no start of that priority).
  • Executor: times its decode and prefill phases (StepResult.decode_wall_micros, prefill_wall_micros). A prefill claim ends at its row's end (row_work_end, Splash Engine::workEndOf).
  • One G: DECODE_GAP_MS (500) feeds the cut and S11's decode-gap classifier. The prefill wall of a step reaches every decoding lane beside it, so a gap over 500 ms there is counted as PrefillUnit (decode_gap_causes.prefill_ms).
  • Status: memoryGovernorStatus().scheduler[] and /health memory_governor.scheduler[], one entry per model with Splash's names: queued, waiting_resources, waiting_prefix, prefilling, decoding (by phase, as Splash Scheduler::snapshot), prefill_batches, prefill_rows, prefill_units, bound_cuts, decode_batches, decode_batches_by_width, decode_gap_target_ms, contended_prefill_ms (Splash FineLatencyHistogram), replans. The counters are atomics the model thread registers once; /health joins the served model name.
  • LatencyHistogram moved to engine::latency beside the new FineLatencyHistogram.

Deleted

  • MLX_SCHED_MAX_BATCHED_TOKENS, scheduler_max_batched_tokens, Scheduler::max_num_batched_tokens, StepPlan::token_budget, its docs row. git grep finds none of them.
  • DECODE_GAP_SECONDS and PassWork::ran_prefill (replaced by DECODE_GAP_MS and the step's prefill wall).

Plan numbers

No existing plan number moved: no assertion of an existing test changed, and every Fixed scheduler test is unchanged. The new numbers below come from the new tests.

case rows
no decoder, no measure 2048
a decoder, nothing timed yet 512
a decoder, last unit 2048 rows in 2048 ms at position 0, leader at 2048 512 (floor)
a decoder, last unit 2048 rows in 204.8 ms, leader at 2048 1667
a decoder, 900 left, cut 512 900 (the rest rides)
3 decoders with draft allowance 4, leader unmeasured 512 (decode rows outside the unit)
leader at 16,384, native window 8192 512 (pair bound)
debt after one 512 ms contended unit at share 0.5 256 ms, paid by 9 decode-only steps of 30 ms

Tests

  • 37 new tests (35 Rust, 2 TS), 38 named mutation runs (MUTATIONS.md). Each test is red under its mutation and green without it. Rust mutations ran as runtime switches on one test binary; the TS ones by edit, then reverted. All switches are gone (git grep MLX_MUT = 0).

    • Plan: Q1 unit always 2048, Q3 deeper = 1, Q2 no rest rule, Q4 untimed rows timed, J1 joiner takes what is left, B1 decode rows charged to the unit, L1 FCFS leader, O1 no overtake count, W1 no width break, P1 no halving, C1 cancelled lanes lead, E1 retry clock ignored, K1 a refused lane is skipped in overtakes.
    • Debt, counters, admission: S2 share 0, C2 every unit in the histogram, H1 bucket = floor ms, A1 every candidate served, AW1 admitted waiters left out of the candidate's plan, W3 a waiting lane counts as waiting for resources.
    • Held starts (hs): AQ1 a held start kept as a refused one (it blocks the later short start), AQ2 held starts never overtaken, HR1 the retry takes all held starts out first (a GPU OOM restart then misses the ones not yet tried), HD1 a held start keeps its host refusal (it stays in the host deficit).
    • Wiring (hs): M1 the hook never applied, W2 prefill claim ends at the pinned break, T1m prefill wall left 0, G2 the pass keeps no prefill wall, S3 admission skips the gate, H1 kept tokens not counted, D3 a held start keeps its wait, P1 the prepared start left out of the gauges, R1 the scheduler not registered, D2 the dense hook ignores the load's share.
    • Status and gaps: S1 one entry for all models, G1 the step's wall not added to the lane.
    • TS: D1 the parser accepts negatives (__test__/cli/serve.test.ts), the health name join skipped (__test__/server/health.test.ts).
  • Gates on the squashed head: cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, yarn build:native (+ index.d.cts copy, no diff), yarn typecheck, yarn tsc -b --force, vp lint --type-aware --type-check and vp fmt --check on the touched files: clean. mlx-core --lib (RUST_TEST_THREADS=1): 4,773 passed, 0 failed, 220 ignored. vp test (touched tests, __test__/server, packages/server, packages/lm/__test__, packages/cli/__test__): 78 files, 1,865 passed, 8 skipped.

  • After the rebase onto S11 d81f71b: S11's decode work end no longer adds +1 (the pending token is already in num_tokens), so row_work_end follows it and a_prefill_claim_ends_at_its_row_end now expects 21. fmt, clippy, yarn build:native, yarn typecheck, yarn tsc -b --force: clean. mlx-core --lib (RUST_TEST_THREADS=1): 4,787 passed and 1 failed (that test, since fixed); engine:: rerun: 581 passed, 0 failed.

  • Review round r1 (held starts queue apart): cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings: clean. mlx-core --lib (RUST_TEST_THREADS=1): engine:: 583 passed, models::qwen3_5 (MoE included) 567 passed, models::qwen3:: 46 passed, 0 failed. No #[napi] or TS file changed.

  • Review round r2 (held starts stay visible to recovery and leave the host deficit): the held retry takes each start from the queue only when it tries it, so a GPU OOM restart fails the rest. A held start clears its host refusal (Splash Engine::deferWait), since sync_claims never visits it. fmt, clippy: clean. engine:: 585 passed, models::qwen3_5 567 passed, models::qwen3:: 46 passed, 0 failed.

  • Review round r3 (a start admitted earlier in the same pass is a lane to the next candidate): serves_candidate plans over the running lanes plus the admitted Waiting turns not yet promoted (Splash Scheduler::admit sets Phase::Prefill at once). Probe: a 40,000-token start waiting for promotion now holds back a 50,000-token candidate and still lets a 300-token one join. fmt, clippy: clean. engine:: 586 passed, models::qwen3_5 567 passed, models::qwen3:: 46 passed, 0 failed. No #[napi] or TS file changed.

Gaps

  • The unit is all prefill rows of one step, each its own forward after the decode batch. Splash joins them in one command, so joiners here add their forward's fixed cost. No stage owns a batched prefill forward.
  • qwen4_exp (Flash Next) prefill is never cut; Splash runs streamed-weight groups in layer passes.
  • The admission-time GDN prime over a cached prefix, and the same prime on a resume, run uncut between steps (S12 resumes at state boundaries).
  • A cached prefix a start would hit only in the prefix cache counts as uncached (no admission prefix probe), so such a start is admitted later than in Splash.
  • Each start is checked against the resident lanes and the starts already admitted (Splash Scheduler::admit makes them Prefill lanes at once), one candidate at a time in submission order; Splash plans all candidates of a pass together and replans without the unserved ones, so here a start admitted earlier in a pass is not re-checked when a later one leads it (Splash would hold the earlier one).
  • No priority tier, no Spill lanes or restoring starts in admission.
  • MLX_SCHED_LONG_PREFILL_TOKENS, the pinned grid and MLX_PAGED_PREFILL_CHUNK_SIZE stay for the other families; qwen3_5 does not read the grid.
  • Refused or blocked rows are left out of the sample; joiners already planned still run (Splash replans the command).
  • Share 0 gives one decode row and one unit per step; Splash alternates whole commands.
  • Status leaves out waiting_mask, terminal, pass and index-page counters; decode_batches_by_width has one key per width up to max_num_seqs.
  • prefill_units, prefill_batches and prefill_rows count only units with a timed row; Splash counts each committed command and each completion, failed rows included.
  • A step whose only prefill rows are cancelled, stopped or blocked still has a prefill wall of a few µs, so a gap over 500 ms in that step reads as PrefillUnit with about 0 ms (inherited from S11's classifier).
  • No tiny Qwen3.5 forward exists, so the_step_times_its_prefill_phase runs the real executor on the test model, and the publish_gauges() call inside drive has no test of its own.

Not in this PR (live, not run)

  • L1: qwen3.8-27b, MLX_CONTINUOUS_BATCHING=1; A decodes while B sends about 32K tokens. Pass: A's largest gap ≤ 1000 ms, A still decodes after B's first token, scheduler.bound_cuts > 0. Before row on S11.
  • L3: B alone, TTFT on S33 vs S11 (information).

🤖 Generated with Claude Code

@Brooooooklyn
Brooooooklyn added this pull request to stack #344 November 12, 2026 07:39
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e38f74f4-0f96-4890-8dd7-2b4636b3f089

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T16:00:41.985464Z 6b628b5 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ce5404afe

ℹ️ 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".

@Brooooooklyn
Brooooooklyn force-pushed the feat/kv-int8-s33-measured-prefill-cut branch from 0315514 to 72a4854 Compare November 12, 2026 13:41
@Brooooooklyn
Brooooooklyn force-pushed the feat/kv-int8-s11-memory-ledger branch from d81f71b to 8478008 Compare November 12, 2026 13:41
@Brooooooklyn
Brooooooklyn removed this pull request from stack #344 November 12, 2026 15:43
@Brooooooklyn
Brooooooklyn force-pushed the feat/kv-int8-s11-memory-ledger branch from 8478008 to dd91726 Compare November 12, 2026 15:58
Base automatically changed from feat/kv-int8-s11-memory-ledger to main November 12, 2026 15:58
Brooooooklyn and others added 4 commits November 12, 2026 23:58
Qwen3.5 dense and MoE cut a prefill that runs beside a decoding lane to
the rows the last timed unit says fit in 500 ms (Splash
Scheduler::planPrefill, cutRows). Every other family keeps the fixed
2048-row budget.

- Plan: Splash leadsBefore (overdue, fewest remaining, order) with
  3 overtakes, joiner rows that spare a chunk, at most 4 lanes, the
  attention-pair bound, cancelled and waiting lanes left out.
- Decode debt: a contended unit owes the decoders decodeShare (0.5) of
  its wall; --decode-share sets it (serve, agent, host, loader).
- Admission: the prepared start waits until the next unit serves it
  (Splash prefillAdmissionOrder); a held start drops its memory wait.
- The executor times its prefill and decode phases; a prefill claim
  ends at its row's end; the decode-gap classifier reads one G and
  counts the prefill beside a lane (decode_gap_causes.prefill_ms).
- Status: memory_governor.scheduler[] per model (prefill units, bound
  cuts, contended prefill latency, decode batches, gauges by phase).
- Deleted: MLX_SCHED_MAX_BATCHED_TOKENS, StepPlan::token_budget.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Starts the scheduler does not want yet (Splash Engine::admitQueued's
queue) wait in their own queue in submission order instead of the one
refused slot, so a later short start is admitted past a held long one.
Only a start refused memory or a lane holds back the rest. A held start
keeps its submission order and is overtaken by each prefill unit that
serves a later submission, so it turns overdue and leads. A later turn
of its owner, a reset, a barrier or an exclusive command does not pass it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… deficit

The held retry takes each start from the queue only when it tries it, so
a GPU OOM restart in one start's prefix preparation fails the starts not
yet tried instead of admitting them without an owner. A held start
clears its host refusal (Splash Engine::deferWait), since sync_claims
never visits it and its demand would stay in the host deficit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… candidate

serves_candidate plans over the running lanes plus the admitted Waiting
turns not yet promoted, as Splash Scheduler::admit makes a start a
Prefill lane at once. A burst no longer admits a start its first unit
would not serve.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Brooooooklyn
Brooooooklyn force-pushed the feat/kv-int8-s33-measured-prefill-cut branch from 72a4854 to 6b628b5 Compare November 12, 2026 15:58
@Brooooooklyn
Brooooooklyn merged commit 7cd3c6b into main Nov 12, 2026
1 check failed
@Brooooooklyn
Brooooooklyn deleted the feat/kv-int8-s33-measured-prefill-cut branch November 12, 2026 15:58
Brooooooklyn added a commit that referenced this pull request Nov 12, 2026
…it and on rolling checkpoints (#376)

Stage S12 of the Splash int8 KV alignment (stack #344). Base: S33
(#375).

A DFlash2 turn now plans and claims its states like Splash. It plans
rolling checkpoints, a junction at the KV hit and the replay point
(Splash `configureDraftStatePlan`). Each capture is a ledger claim
(Splash `Engine::stateClaim`). States are published after every prefill
chunk. A state is the GDN cell plus a 4-bit draft context window. The
live lane between turns is gone: the next turn resumes at the deepest
stored state.

```
before:  prime: live lane (seq 0 kept live) | store hit | cold; no junction
         prefill breaks: GDN ladder rungs + R; one publish after the prefill (abort drops it)
         state = GDN cell + bf16 draft K/V window; 3,072 MiB state budget, oldest first
         draft K/V = sliding buffer, +256-row regrowth
after:   lookup: deepest store state S; probe the whole KV hit K; J = K if a state sits below K
         plan: checkpoints 4096·k (disposable) + J (ordinary) + R (ordinary, in use)
         each chunk: book its KV (growLane), then claim its capture:
                                  R InService CanWait | checkpoint / J Optional Immediate
                                  refused + reclaimable checkpoint -> SettledOnce, from the lane
         publish after every chunk: register blocks, publish, retire the older checkpoint
         state = GDN cell + 4-bit window (5,898,240 B on the 27B); no budget, checkpoints go first
         end: register + release; ring + window -> idle lane; draft K/V = fixed 2,048-slot ring
```

## Changes
- `dflash2_state/plan.rs` (new): `planned_checkpoints`,
`replay_state_boundary`, `configure_draft_state_plan`,
`plan_draft_context` and `command_breaks` (Splash `reserveCaptures`
"passed" rule). The checkpoint margin is the constant
`PREFILL_STEP_SIZE` (Splash `prefillTokenBudget`).
- Store: `StateClass` (checkpoint / ordinary), dedup, upgrade on an
ordinary publication (keeps the publication, Splash `makeOrdinary`),
`use_state` / `end_use`, `checkpoint_state`, `state_below`, and lineage
bytes in each entry's size.
- Captures are claims: `state_claim` + `reserve_capture`, claimed after
the chunk's KV is booked (`book_chunk`, Splash `Engine::prepare`:
`growLane` before `reserveCaptures`), so an optional state is refused
instead of taking the room the chunk needs. A refused checkpoint with a
reclaimable checkpoint on the lane retries as `SettledOnce` and
snapshots inside the claim (`Reached::FromLane`, Splash `fromLane`). A
refused capture still runs use, dedup and retire.
- The restore is a claim too: GDN cell, plus the ring bytes the idle
ring lacks, plus a window only when the draft is rebuilt and the idle
lane has none (Splash `admitIdleLane`). Wait retries; Fail makes the
turn cold (Splash `admit`).
- `register_committed_blocks` registers a chunk's full blocks before its
states are published, so a cancelled prefill keeps what earlier chunks
published.
- 4-bit draft context window: Metal store, load and copy
(`draft_context.metal.inc`, `mlx_draft_context.cpp`),
`DraftContextWindow`. Rows are cast to bf16 before the store. A restore
dequantizes and projects the window, and skips it when the first point
is a full window past the resume (Splash `restoresDraftState`).
- Resume: junction probe over the whole KV hit, `lazy_junctions` counted
once per admission (Splash `recordLookup`), plan and restore decision at
resolve. A turn without cache reuse keeps its turn state with an empty
plan.
- DFlash2 finalize registers, releases, then ends the replay-point use.
`save_paged_history` skips the frontier check on a released lane, so the
GDN dirty latch stays clear.
- AR turns read GDN from a store entry (in use, restamped at the end).
- Unit order: a model's checkpoints go first, then the stamp merge of
ordinary states and idle owners (Splash `Cache::nextUnit`
`Phase::Checkpoints`).
- Draft K/V is a fixed ring of 2,048 slots plus the block rows, with a
per-row mask in eager and compiled paths. The ring and window live in an
idle lane between turns. Aborts and a dropped stepper also put them
back. The idle lane counts in the states account.
- Serial-lane suspend: a DFlash2 prefill or verify that yields vacates,
waits, then claims the lane buffers, then the KV, and replays from its
deepest state (Splash `admit` order). A vacate publishes nothing.
- Counters in `memoryGovernorStatus().dflash2States` and `/health`
`dflash2_states` (Splash keys).

## Memory plan

| plan | before | after |
|---|---|---|
| 27B draft K/V ring (`kv_ring_bytes`) | 47,329,280 (2,311 rows) |
42,106,880 (2,056 rows) |
| 27B lane beyond the pool cell | 201,273,344 | 201,949,184 (ring +
5,898,240 window) |
| 27B lane vs Splash `laneBytes` | 905,216 short | 229,376 short (conv
alignment −393,216, ring rows +163,840) |
| M3 Pro 27B int8 + DFlash2 pool blocks | 14,137 | 14,136 |
| M3 Pro 27B int8 + DFlash2 window | 221,177 | 221,177 |
| M3 Pro 27B bf16 + DFlash2 window | 112,473 | 112,473 |
| M3 Pro 27B serial MTP window | 155,641 | 155,641 |
| 27B state (GDN cell + window) | – | 159,842,304 + lineage bytes |

## Deleted
- `MLX_DFLASH2_STATE_BUDGET_MB` and the state budget
(`STATE_BUDGET_ENV`, `DEFAULT_STATE_BUDGET_MB`, `parse_state_budget`,
`with_state_budget`, `trim_to_budget`).
- `DFlash2States.unregistered`, `drop_unregistered`,
`settle_replay_state`, `publish_replay_state`, `replay_capture_row`,
`draft_keep_from`.
- The live lane: `DFlash2Hit::Live`, `reusable_paged_dflash2_prefix`,
`StoreHit::beats_live`, the keep-live finalize. `live_window_prefix`
stays only in the offline `replay.rs`, private.
- `DRAFT_KV_STEP` and ring regrowth, `DFlash2Attention.sliding_window`
(the mask is per block now), `trace::JUNCTION_MIN_GAP`.

## Tests
- No model loads. Each test was run once with its mutation on (red) and
once off (green), on one test binary (`MUTATIONS.md`). 44 mutations:
- plan and store: `planned_checkpoints_match_splash` (CK1),
`plan_merges_points_like_configure_draft_state_plan` (JG1, PS1),
`draft_spans_match_plan_draft_context` (DS1),
`ordinary_publication_upgrades_a_checkpoint` (UP1),
`state_bytes_count_the_lineage` (TB1),
`state_below_sees_strict_ancestors_only` (SB1).
- 4-bit window: `context_window_quantizer_matches_the_kernel` (Q15),
`state_bytes_27b_geometry` (WB1),
`restore_rebuilds_the_draft_or_starts_empty` (RD1),
`rows_of_a_non_bf16_draft_store_as_bf16` (CB1).
- publish: `rolling_checkpoint_keeps_one_and_the_one_below_r` (RC1,
RP1), `cancelled_prefill_keeps_reached_states` (CN1),
`committed_blocks_register_once` (RB1).
- claims: `capture_claims_follow_state_claim` (SC1, RB2, RW1),
`refused_checkpoint_comes_from_the_lane` (FL1, FL2),
`chunk_kv_is_booked_before_its_capture` (KV1, review C1).
- resume: `junction_at_the_kv_hit` (JN1),
`dflash2_turns_resume_at_the_deepest_state` (LV1, SV1),
`a_resumed_lane_counts_no_junction` (JR1),
`a_turn_without_reuse_publishes_no_state` (RU1),
`a_paged_turn_without_a_replay_point_keeps_its_junction` (TJ1).
- units and AR: `checkpoints_go_before_ordinary_states` (CF1),
`ar_turn_restores_gdn_from_a_composite_state` (AR1).
- ring and lane: `ring_after_n_cycles_holds_the_sliding_rows` (RG1),
`ring_attention_matches_the_sliding_window` (DM1),
`lane_buffers_are_reused_between_turns` (LB1),
`length_exit_runs_no_terminal_forward` (TF1),
`idle_lane_counts_in_the_states_account` (IA1),
`aborted_turns_leave_their_lane_buffers_idle` (AB1, SD1).
- suspend: `vacate_of_a_dflash2_turn_publishes_nothing` (VC1, RK1),
`moe_suspension_replays_on_the_lane_buffers` (MVC1, MVP1).
- after the rebase:
`a_suspended_dflash2_lane_drops_its_cells_and_idles_its_ring`, dense and
MoE (R1m, RI1); `a_stop_during_the_replay_completes` (R4);
`dead_leaves_go_after_checkpoints_before_ordinary_states` (DL1, new).
- review round 2: `a_failed_window_copy_is_an_error` (EV1, EV2: a window
copy that fails on the GPU is an error, never a published state or moved
bounds), `the_idle_lane_holds_materialized_buffers` (IR1, IR2: the idle
lane keeps only materialized ring and window, so a restore credits only
real storage).
- Re-pinned: `draft_kv_ring_bytes_match_the_window_buffer_cap`,
`qwen38_27b_lane_bytes_against_splash`,
`dflash2_takes_the_one_pool_window` (numbers above).
- Gates on the squashed commit: `cargo fmt --all -- --check` and `cargo
clippy --workspace --all-targets -- -D warnings` clean. mlx-core `--lib`
(`RUST_TEST_THREADS=1`): 4,798 passed, 0 failed, 220 ignored. `cargo
test -p mlx-paged-attn --lib`: 210 passed, 8 ignored. `yarn
build:native` passed, `index.d.cts` unchanged after the copy. `yarn
typecheck` and `tsc -b --force` (23 projects) clean. `vp lint` and `vp
fmt` on `health.ts` and `health.test.ts` clean. `vp test __test__/server
packages/server packages/lm/__test__`: 1,596 passed, 7 skipped.
- Review round 2 (H1, M1): fmt and clippy clean; scoped `engine::` 587
passed, `models::qwen3_5` (dense + MoE) 594 passed, `models::qwen3::` 46
passed, 0 failed. No `#[napi]` or TS file changed.
- After the rebase onto S33 0315514: fmt and clippy clean; mlx-core
`--lib` 4,819 passed, 0 failed, 220 ignored; mlx-paged-attn 210 passed,
8 ignored; `yarn build:native` passed, `index.d.cts` unchanged; `yarn
typecheck`, `tsc -b --force` clean; `vp test` 1,596 passed, 7 skipped.
- Rebase mapping: a verify still lends its GDN cells to the target
across its claim (S11), so a suspend drops them before the wait; its
ring now goes to the idle lane instead of being dropped. The S11
dead-leaves unit now sits after the checkpoints (Splash `Phase` order),
and the stop-during-replay rule moved with the replay into
`suspended_wait`.

## Gaps
- 16-token blocks, so points round to 16 (Splash pages are 32). Ring
attention uses MLX SDPA with a per-row mask, so its summation order
differs from Splash's tiles (no bit parity).
- No shared-prefill points (Splash `addSharedPrefillBoundaries`); one
turn plan per model. The idle lane is never taken by a claim, and it is
counted in the states account but is not a ledger unit.
- No restore lease: `checkpoint_pinned` is always false. No capture is
ever Pending (no SSD state tier).
- `unprovenState` and `lostStateMisses` are not ported.
- Decode registers its blocks only at finalize, so a cancel during
decode loses the decode KV.
- A passed checkpoint is never captured as a fallback when a chunk's KV
claim is refused, and `stateCaptures` is not counted (mlx-node chunks
end at every captured point).
- A block reserve still evicts dead leaves before any checkpoint (the
allocator does it inside `reserve`); only the ledger's dead-leaves unit
follows the checkpoints.
- DFlash2 turns still publish GDN ladder rungs when a cold GDN sidecar
policy is on. AR turns keep the ladder, the history entry and the live
lane.
- After a restore claim fails, the cold turn still plans its junction.
In Splash the request is `skipCache` and plans no junction. Outputs stay
correct.
- The serial decode suspend stays in place (S11's `suspend_in_place`);
only the prefill unwinds through `DFLASH2_SUSPENDED`. The tests force
the yield with a test hook, not with host pressure, because a real
HostPressure denial first takes the checkpoints.
- The MoE prefill has no cancel hook, so there is no MoE
cancelled-prefill test.
- The target side of a paged prefill chunk still evaluates with the
error-swallowing `MxArray::eval` (`hidden_states.eval()` in
paged_forward.rs, older than this PR), so a GPU failure there is only
logged; the draft window's own copies now fail the turn (Splash
`NativeRuntime::executionFailed`).

## Not in this PR (live, not run)
- L0 sanity on the full release build; L1 teacher-forced acceptance,
fresh vs restored turn (4-bit window), S vs base; L2 turn-2 TTFT without
the live lane; L3 states after one 64K prompt (rolling checkpoints, no
budget); L4 DFlash2 decode at 8K and 64K, S vs base. Commands:
`LIVE.md`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant