Repository navigation
feat(kv-int8): DFlash2 states are ledger claims, captured at the KV hit and on rolling checkpoints - #376
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. |
bd0b0ef to
b7f7b08
Compare
72a4854 to
6b628b5
Compare
…it and on rolling checkpoints A DFlash2 turn plans its state points like Splash configureDraftStatePlan: rolling checkpoints every 2 x draft window, a junction at the KV hit, and the replay point. Each capture is a ledger claim (Splash Engine::stateClaim): the replay point is InService and can wait, checkpoints and the junction are Optional and Immediate, and a refused checkpoint can come from the lane. States are published after every prefill chunk, so a cancel keeps them. A state is the GDN cell plus a 4-bit draft context window (Metal store, load and copy). The state budget is gone: checkpoints are the first state units the ledger takes. The live lane is gone: a DFlash2 turn releases its lane at the end, keeps its ring and window in an idle lane, and the next turn resumes at the deepest stored state. The draft K/V is a fixed ring. A DFlash2 turn suspended by the serial lane replays from its deepest state. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Splash Engine::prepare runs growLane before reserveCaptures. S12 claimed the capture first, so an optional state's reservation could take the room the chunk's KV growth needed and a cold prefill failed with capacity_exhausted. book_chunk now records the chunk, then claims the capture, in the dense and MoE loops. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…al buffers A DraftContextWindow snapshot or copy whose GPU eval fails now returns the error instead of publishing the window or moving its bounds (Splash NativeRuntime::executionFailed publishes nothing). The idle lane materializes the ring and window it keeps and drops them if that fails, so a restore claim credits only storage that exists (Splash QwenStateStorage::releaseLane pools allocated rings). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The hosted macOS runner is a VM whose GPU reports no Apple GPU family and whose compiler rejects the tensor ops of the paged prefill kernels, so every test on that route failed or hung there. A test hook reports the missing family; the pipeline-build test expects no pipelines then, and each paged prefill test prints a skip and returns. A real Mac (Apple7 and up) still runs them. - Qwen4 fixture load: the fixture-host child also gets the fixture's working set (12 GiB), not the VM's 4 GB. - grouped_deferred_matches_the_prepare_chain: skips when the device declines the fused GDN step, as the other fused tests do. - int8_varlen_prefill_reads_past_the_aux_cap: ignored (heavy GPU, timed out on the VM). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e family The integration suite still ran the paged prefill kernels on the hosted VM GPU, which has no Apple GPU family and cannot build them. The synthetic MoE MTP gate failed there with "Failed to extract int32 scalar": the pipeline error from the prefill eval was swallowed, and only the verify step's token read reported it. The two paged-attn prefill tests failed at eval for the same reason; the earlier failing binary hid them. Both now skip through the mlx_test_gpu_lacks_apple_family hook, as the lib tests do. A real Mac (Apple7 and up) still runs them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
free_at dropped `at` on a release that left another holder, so kept tables released out of turn-end order stamped the older end and eviction took a recently used prefix first. Every Some(at) release now raises the leaf to max(own, at); a None release still stamps only when the cache is the sole holder (Splash KvCache::releaseActive). Co-Authored-By: Claude Opus 5.5 <[email protected]>
caea776 to
481fa1a
Compare
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 (SplashEngine::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.Changes
dflash2_state/plan.rs(new):planned_checkpoints,replay_state_boundary,configure_draft_state_plan,plan_draft_contextandcommand_breaks(SplashreserveCaptures"passed" rule). The checkpoint margin is the constantPREFILL_STEP_SIZE(SplashprefillTokenBudget).StateClass(checkpoint / ordinary), dedup, upgrade on an ordinary publication (keeps the publication, SplashmakeOrdinary),use_state/end_use,checkpoint_state,state_below, and lineage bytes in each entry's size.state_claim+reserve_capture, claimed after the chunk's KV is booked (book_chunk, SplashEngine::prepare:growLanebeforereserveCaptures), 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 asSettledOnceand snapshots inside the claim (Reached::FromLane, SplashfromLane). A refused capture still runs use, dedup and retire.admitIdleLane). Wait retries; Fail makes the turn cold (Splashadmit).register_committed_blocksregisters a chunk's full blocks before its states are published, so a cancelled prefill keeps what earlier chunks published.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 (SplashrestoresDraftState).lazy_junctionscounted once per admission (SplashrecordLookup), plan and restore decision at resolve. A turn without cache reuse keeps its turn state with an empty plan.save_paged_historyskips the frontier check on a released lane, so the GDN dirty latch stays clear.Cache::nextUnitPhase::Checkpoints).admitorder). A vacate publishes nothing.memoryGovernorStatus().dflash2Statesand/healthdflash2_states(Splash keys).Memory plan
kv_ring_bytes)laneBytesDeleted
MLX_DFLASH2_STATE_BUDGET_MBand 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.DFlash2Hit::Live,reusable_paged_dflash2_prefix,StoreHit::beats_live, the keep-live finalize.live_window_prefixstays only in the offlinereplay.rs, private.DRAFT_KV_STEPand ring regrowth,DFlash2Attention.sliding_window(the mask is per block now),trace::JUNCTION_MIN_GAP.Tests
MUTATIONS.md). 44 mutations: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).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).rolling_checkpoint_keeps_one_and_the_one_below_r(RC1, RP1),cancelled_prefill_keeps_reached_states(CN1),committed_blocks_register_once(RB1).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).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).checkpoints_go_before_ordinary_states(CF1),ar_turn_restores_gdn_from_a_composite_state(AR1).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).vacate_of_a_dflash2_turn_publishes_nothing(VC1, RK1),moe_suspension_replays_on_the_lane_buffers(MVC1, MVP1).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).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).draft_kv_ring_bytes_match_the_window_buffer_cap,qwen38_27b_lane_bytes_against_splash,dflash2_takes_the_one_pool_window(numbers above).cargo fmt --all -- --checkandcargo clippy --workspace --all-targets -- -D warningsclean. 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:nativepassed,index.d.ctsunchanged after the copy.yarn typecheckandtsc -b --force(23 projects) clean.vp lintandvp fmtonhealth.tsandhealth.test.tsclean.vp test __test__/server packages/server packages/lm/__test__: 1,596 passed, 7 skipped.engine::587 passed,models::qwen3_5(dense + MoE) 594 passed,models::qwen3::46 passed, 0 failed. No#[napi]or TS file changed.--lib4,819 passed, 0 failed, 220 ignored; mlx-paged-attn 210 passed, 8 ignored;yarn build:nativepassed,index.d.ctsunchanged;yarn typecheck,tsc -b --forceclean;vp test1,596 passed, 7 skipped.Phaseorder), and the stop-during-replay rule moved with the replay intosuspended_wait.Gaps
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.checkpoint_pinnedis always false. No capture is ever Pending (no SSD state tier).unprovenStateandlostStateMissesare not ported.stateCapturesis not counted (mlx-node chunks end at every captured point).reserve); only the ledger's dead-leaves unit follows the checkpoints.skipCacheand plans no junction. Outputs stay correct.suspend_in_place); only the prefill unwinds throughDFLASH2_SUSPENDED. The tests force the yield with a test hook, not with host pressure, because a real HostPressure denial first takes the checkpoints.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 (SplashNativeRuntime::executionFailed).Not in this PR (live, not run)
LIVE.md.🤖 Generated with Claude Code