Skip to content

spark25, minimax_m3 cuda: a prompt chunk's last layer runs only the rows something reads - #3122

Merged
ashhart merged 2 commits into
mainfrom
lead/cuda-prompt-tail-spark25-minimax
Nov 15, 2026
Merged

ashhart merged 2 commits into
mainfrom
lead/cuda-prompt-tail-spark25-minimax

Conversation

@ashhart

@ashhart ashhart commented Nov 13, 2026

Copy link
Copy Markdown
Owner

On CUDA, Spark 2.5 and MiniMax-M3 ran the last layer of every prompt chunk over all its rows, though only the final rows feed anything. The prompt-tail skip Qwen already uses now covers both: earlier chunks stop the last layer at its cache writes, and the last chunk runs the full layer only on the rows something reads. With DSpark, MiniMax's drafter reads layer 59 for the last ~4.1K rows, so those rows still run it. Both prompt matrix kernels work in 128-row blocks with one fp32 chain over K, so a row's result doesn't depend on its block; every tensor-parallel rank computes the same tail.

Tests: test-minimax-cuda-host 16 (main 14) and test-spark25-host 13 (main 12) pass; check-native-cuda-host reaches every changed function; compile-cuda-tests passes for aarch64 and x86_64.

Device check pending (GB10): Spark 2.5 and MiniMax (one rank and the TP group, with and without DSpark), greedy and sampled token hashes equal to main's on multi-chunk prompts whose last chunk is 129-200 rows or a whole 512 or 2,048-row chunk; first-token logits byte-equal; tf-cuda-test spark25-pages passes; prefill A/B.

@ashhart

ashhart commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

GB10 A/B on this head (Spark 2.5, pp, sweep, chat and long cells): GREEN, every token hash equal to main, speed level. No box of ours has a MiniMax-M3 checkpoint, so the MiniMax half rests on its host tests and on the tail kernels' row independence argued above. Queued to land.

  • Synthena (Ash's Agent)

…ows something reads

Both families now take core's prompt tail, as Qwen 3.5's CUDA forward does. The last layer still projects and writes
every row's keys and values (and MiniMax's index keys), then runs attention, o, the norms and the MLP or MoE only for
the prompt's last chunk's tail: from core's start (the last 128 rows) rounded down to a 64-row boundary, so its rows
keep the tiles they have in the whole chunk. An earlier chunk's head is never read, so its last layer stops at its
cache writes and the head is skipped. With MiniMax's DSpark drafter the tail starts no later than the first row its
absorb reads (its window and a window's rows before the prompt's end), since those rows' layer-59 taps feed it; every
tensor-parallel rank derives the same rows from the chunk and the prompt's length.

Every key, value and index key is written as before, the tail rows run the same prompt kernels at the same positions
(EXL3 and affine prompt GEMMs in 128-row blocks with one fp32 chain over K, row-independent attention, selection and
experts), and the kept last row is in the tail, so every token is unchanged.

test-minimax-cuda-host and test-spark25-host: which rows each chunk runs, with and without DSpark.
@ashhart
ashhart force-pushed the lead/cuda-prompt-tail-spark25-minimax branch from b420524 to f657e5a Compare November 15, 2026 18:41
@ashhart
ashhart merged commit 811c384 into main Nov 15, 2026
13 of 20 checks passed
@ashhart
ashhart deleted the lead/cuda-prompt-tail-spark25-minimax branch November 15, 2026 18:41
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