Skip to content

kimi-k3: K3.1 runs a prompt as passes past the indexer's top-k; the pass keeps the dial's NVMe arena - #1184

Merged
midagedev merged 10 commits into
mainfrom
arenapass
Nov 8, 2026
Merged

midagedev merged 10 commits into
mainfrom
arenapass

Conversation

@midagedev

Copy link
Copy Markdown
Owner

K3.1이 2,048 위치를 넘어 프롬프트 패스로 돌고, 패스 plan이 dial의 NVMe arena를 유지해 decode 2.94 → 4.46 tok/s.

What and why

The v0.3.13 re-cut's K3.1 work, on main. A K3.1 prompt pass now selects per row past the indexer's top-k (the step's own pick and selected core). So a prompt runs whole as placed passes, and the seat runs passes by default (--prefill pass|steps). The pass plan keeps the split dial's NVMe arena (expert_nvme_tier_for_passes) and takes the arena's floor only where the dial gives none. Before, it always took the floor, and decode after a pass fell to 2.94 tok/s.

Release notes: Fixed — Kimi K3.1 serves past 2,048 positions with its prompt run as passes, and decodes after a pass at the split dial's arena.

Code shape

  • No second copy. The pass plan and the step plan share split_nvme_tier; the pass only picks its grant.
  • Model code holds only architecture facts. kimi_k3_pass moved under crates/gpu-gates/src/arch/ (check-arch rule 4).
  • Dead code is gone. with_arena_at_floor was renamed to with_pass_arena; no old name is left.
  • No silent failure.
  • Comments state what is true now.
  • No relaxed gate. No gate was relaxed. The arena test pins the dial's arena (192,696,700,800 B at 200 GiB) and the floor (22,603,677,696 B at 250 GiB). Mutant .mutants/arenapass-floor-always.patch turns it red.
  • fmt and clippy are clean (just remote-static origin/main).

Duplication found or removed: none.

What I ran

  • tools/gate-batch.sh --list <narrowed affected> --tier fixture --ledger on the box (3090 + A6000): DONE total=208 red=0 tier=fixture skipped=0 wall=2410s deferred=266 real_only=40 real_file=20 needs_env=9
  • gate_kimi_k3_place on the K3.1 fixture: clauses: 30 ran, 0 left to the real tier; ok pass past top-k ... last logits row bits equal: true
  • K3.1 UD-IQ1_S, A6000 + 3090, D=512, 512 generated, 232G room, two drives (card docs/cards/arenapass-k31.card): pass decode 4.46 tok/s and prompt 10.2 tok/s. On the floor arena it was 2.94 / 12.48. Under --prefill steps it was 4.99 / 3.80.

Hardware

Box: RTX A6000 + RTX 3090 (250 W cap), driver 580, two NVMe drives.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XgzWzhZmMb7Ec2SohqrR1A

midagedev and others added 10 commits November 8, 2026 21:43
…hape its plan holds (--prefill pass|steps)

pick_shape is lifted to crates/gpu-gates/src/kimi_k3_pass.rs, which generate_kimi_k3 and the seat both call.
The hybrid seat gains generic hooks: a body that keeps its load's slot map (unset residency resolves off,
why fixed_place; a set word other than off is refused by name before the fetch), a family's pass plan, the
prompt_pass record and listening's prompt=pass|steps. A plan that holds no pass shape steps, named.

Box (A6000+3090, fixture tier): gate_kimi_k3_serve 8 checks PASS, prompt_runs_as_passes and
passes_answer_as_steps new. Mutant .mutants/k3seatpass-open-stepped.patch: check prompt_runs_as_passes FAIL,
reversed. The residency clause's why moves from prefill_steps to fixed_place (PIN 2026-11-08).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XgzWzhZmMb7Ec2SohqrR1A
…(the step's own pick and selected core), so a prompt runs whole as passes

Each pass row on a selecting load runs the batched front, the index projections and one key launch for the
pass's rows, then per row the step's pick and selected attention (kimi_k3::attend_rows_sel), then the batched
out. check_pass, pass_prefix and score_crossing are gone; Batch::prompt passes the whole prompt.
gate_kimi_k3_dsa's pass refusal becomes the positive pass clause (every row's gated heads, key rows and cache
rows the steps' bits); gate_kimi_k3_place's pass past top-k pins token, position, every logits row and the
continuation. The k31dsa pass mutants are retired with the refusal they pinned (2026-11-08: the behaviour they
caught is removed); four k31passdsa mutants replace them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XgzWzhZmMb7Ec2SohqrR1A
…the floor only where the dial gives none (expert_nvme_tier_for_passes); with_arena_at_floor → with_pass_arena

The pass plan took the arena at its floor (22.6 GB) whatever the dial gave, so at a room under H/2 (K3.1 at 232G:
the dial's 228.8 GB) the pass's load decoded on a tenth of the step's arena. kimi_k3_meta pins both rooms
(250 GiB: the floor; 200 GiB: the dial's 192.7 GB for both plans), FAIL-first .mutants/arenapass-floor-always.patch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XgzWzhZmMb7Ec2SohqrR1A
…r 0.3.13); steps the pick past a reply of ~7× the prompt; the arenapass card's outcome

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XgzWzhZmMb7Ec2SohqrR1A
@midagedev
midagedev merged commit 8a7b2d3 into main Nov 8, 2026
5 checks passed
@github-actions github-actions Bot added documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja placement Placement planning: crates/placement tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Nov 8, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: MUST_FIX: one proven in-diff duplicate (the count-word staging); the rest of the change reads correct, gated and measured.

Must fix

1. Two owners stage a pass's count words

crates/gpu/src/arch/kimi_k3/rows.rs:103 (PassIn::stage_words) and crates/gpu/src/arch/kimi_k3/pass.rs:1171 (inline in placed_rows) hold the same knowledge: pass_words into the host slice, then one copy_from_host of m · WORDS words into the buffer's head. Both are new in this diff; a change to the staging (WORDS, the fill) must now be made twice.
Cost: today the fix is a hoist; after more callers it is a hunt.
Fix — one owner beside pass_words in index.rs (delete PassIn::stage_words):

/// The count words of `m` rows from `pos` over lists of `top_k` rows ([`pass_words`]), staged
/// to the first `m · WORDS` words of `words` in one copy.
pub(super) fn stage_pass_words(
    stream: &CudaStream,
    host: &mut [u32],
    words: &mut DeviceBuffer<u32>,
    (pos, m): (u32, usize),
    top_k: u32,
) -> Result<(), GpuError> {
    let host = &mut host[..m * WORDS];
    pass_words(host, pos, top_k)?;
    let mut dst = WindowMut::<u32>::of_mut(words, 0, m * WORDS)?;
    Ok(dst.copy_from_host(stream, host)?)
}

Body::rows (rows.rs): index::stage_pass_words(gpu.stream(), &mut pass.input.words_host, &mut pass.input.words, (pos, m), sel.top_k())?;
placed_rows (pass.rs): index::stage_pass_words(stream, &mut pass.words_host, &mut pass.words, (pos, m), sel.top_k())?;

Non-blocking

⚠ Name the scan behind the narrowed gate list: the body ran a narrowed gate list, but a launch formula moved (the per-row pick and selected core, index.rs:497) and a byte formula moved (pass_bytes grew the iq/iw/words buffers); AGENTS' narrowing rule runs the whole list when a kernel, a launch or a byte formula moved. The class's proof (owning gates plus a timed A/B) is in the cards; add the ptx-scan/canon-check line for the covering bins, or name the whole-list run.

⚠ The residency pick is resolved against the step's plan before the pass's plan replaces it: tiered.rs:1075 computes pick inside streamed over asked.plan; tiered.rs:1141 swaps in the pass's plan. The only pass family (SLOT_MAP_FIXED) has a plan-independent pick and open_pass refuses a non-off residency by name, so nothing loads quietly today; a family that later adds PASS with a running residency machine would print its residency lever record for a plan it does not load. One doc line on Tiered::pass_plan naming that order, or move the pick after the walk.

Optimization headroom

  • D (more at once): index.rs:497 launches enqueue_pick once per row, but every key row is written by project_pass before the loop, so an m-row pick launch would serve a whole chunk: for a 512-row pass at 8-row chunks, 64 × 7 ≈ 450 fewer pick launches per latent layer (≈ 0.4 ms a layer at c_node 0.85 µs [derived]). The per-row core stays forced by cache-row causality.

Checked

Duplicates: 30 new items grepped (kimi_k3_pass, pass_words, attend_rows_sel, PassPick, project_pass, mla core/front_rows/out_rows, PassSel, Sel::top_k/pass_pick, expert_nvme_tier_for_passes, with_pass_arena, the seat's Walk/PassPlan/Flags family, record keys, probe env vars); one in-diff twin (must-fix 1); the refactor removed two existing twins (the AttendIn/AttnBufs build in gated_mla, the shape-pick loop in generate_kimi_k3). Complexity: crapper did not run; the largest new functions (attend_rows_sel, tiered::run's walk block, past_top_k_arms) are checks over one loop; no kernel body was split. Silent failure: 6 sites followed — the seat's steps fallback prints why and names the walk in listening; Grant::AtLeastFloor cannot return a sub-floor arena; run_mixer_rows's mismatch arm refuses by name, and (index, k.index, pick) all key on the one fact index::selects; no new unwrap_or/.ok(). Tests: every new clause names a mutant with expected red lines (.mutants/: arenapass-floor-always, k31passdsa-*, k3seatpass-open-stepped); passes_answer_as_steps has none of its own; its partner clause carries the FAIL-first. Gates: PIN(2026-11-08) on UNSET_WHY with reason; no band moved; the arena meta test pins both rooms. Escape catalog: none matched (no new pipes or process matching).

Notes

  • dryer and crapper did not run (ModuleNotFoundError for both); the duplicate and complexity checks above are manual.
  • The body's evidence carries card, driver, model, commands and output in two card files; the literal nvidia-smi line and the base hash of the A/B pair are not in the body.

Card check: gpu-evidence. This pull request changes crates/app/src/arch/kimi_k3/mod.rs, crates/gpu-gates/src/arch/kimi_k3_pass.rs, crates/gpu-gates/src/bin/gate_kimi_k3_dsa.rs … and carries a gate run on the author's card, which counts as verified.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@github-actions github-actions Bot added the gpu-evidence Verified on the author's card: the pull request carries the gate run and its output label Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app gpu-evidence Verified on the author's card: the pull request carries the gate run and its output model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja placement Placement planning: crates/placement tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant