Repository navigation
scheduler: a prompt arriving while others decode runs one prefill chunk a tick (4/4, stacked on 3/4) - #433
Conversation
…(ATLAS_SKINNY_MMA) Inkling's verify rows keep the decode row's arithmetic so text with drafts is the text without. For the Spark NVFP4 projections and head that meant the scalar batch GEMV tiers, which repeat the one-row kernel's FMA chain and are issue-bound: at eight verify rows they read Inkling's [3072 x 2304] projections at about 90 GB/s, and they were about 14 ms of a 68 ms drafted step on one GB10. ATLAS_SKINNY_MMA's kernels compute a row the same way at every width, so decode and verify stay exact twins on the tensor cores: - skinny_mma.cu moves from the qwen3.6-27b overlay to gb10/common, so every GB10 target (Inkling 2 Mini's included) ships it; the lever stays off unless set. - Under the lever Inkling's one-row fused projection kernel (inkling2_proj_gemv_mixed, the scalar arithmetic) is not used, so a decode row takes the skinny kernels as a verify row does. - An exact verify's NVFP4 projections and the verify head go to the skinny kernels in one call (up to 128 rows) instead of 15- and 16-row passes that read the weight again. - skinny_mma_microtest covers Inkling's shapes and runs on its kernel set. Observed on one GB10, dev build, Spark weights, DFlash2 drafter, voice engines resident, preliminary, single runs: skinny_mma_microtest passes at Inkling's shapes (rows byte-identical at 1..128, error against FP64 no worse than w4a16_gemv). Greedy text for 8 prompts x 320 tokens with drafts at one, four and eight requests, and plain at eight, identical to drafts off one at a time. A drafted step at one request 68.5 -> 54.6 ms; RigMark short code C1/C2/C4/C8 aggregate 65.8 / 73.9 / 108.7 / 149.1 tok/s with the lever (release 0.5.0, voice suspended: 58.7 / 77.6 / 103.0 / 136.0). Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 19f3e27)
…move skinny_mma_microtest's shape table moves to skinny_mma_microtest_parts/ shapes.rs and GlueKernels::window_meta to glue/route.rs beside kv_write; code moved as is. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-residual passes, ldmatrix W4A4 tile A 32K-token cold prefill on one GB10 (Spark weights, 4,096-token chunks, nsys, 2026-11-26, preliminary single runs): TTFT 9.56 s -> 7.79 s with ATLAS_BF16_GEMM_CUTLASS=1 (7.42 s at 8,192-token chunks). - inkling2_flash_prefill: the relative bias BF16(rel . rel_proj) is a rank-16 product of BF16 values, so per key tile a warp computes its 16 rows x 47 distances on the tensor cores (6 m16n8k16 MMAs), stages them in its shared memory and reads them back along the diagonals. The scalar sum (16 multiply-adds a score) held the sliding-window visits, biased in every tile, to ~14 TFLOPS against ~48 for the full ones: attention 2.40 s -> 1.53 s. Only the bias's summation order changes. The kernel also applies the output gate in its epilogue (inkling2_gate_mul's arithmetic) and no longer spills. - Message gates (prefill): inkling2_block_res_row writes each output row's sum of squares, so the fused gate reads its rows twice instead of three times, and each step's global loads now overlap the step before (one barrier a step): 1.08 s -> 0.73 s. - inkling2_block_res_row: 8 channels a thread (H / 8 threads), each state loaded once with 16-byte loads and held in registers for both passes: 0.78 s -> 0.58 s. - nvfp4_w4a4_tile.cuh (Inkling and Qwen3.8 Flash-Next experts): A and B fragments by ldmatrix.x4, one instruction for four 4-byte loads; same operands, bit-identical outputs; ~2% (the tile is still bound by its shared-memory pipe, 31% tensor utilization). - The per-head kernel's bias table is cut to the 63 rows it serves (it was sized for a whole chunk: 201 MB at 4,096 rows). Prefill numerics: prompt logprobs of 56 calibration documents and seven 8K-token prompts move against the previous build by as much as changing the chunk size moves them (8K prompts: KL(top-5) 0.002-0.008 for both); mean next-token NLL 1.1683 (previous, 4,096 chunks), 1.1676 (previous, 2,048), 1.1678 (this). Decode and verify rows keep their kernels. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit dd80b21)
- inkling2_block_res_row norms its outputs (inkling2_rmsnorm's formula) on a prefill chunk's visits no message gate rewrites: the attention inputs and the MLP input leave as BF16 normed rows and the fp32 mix is never written and read back. Decode and verify rows keep their kernels, so text with drafts is still the text without (greedy, 8/8 prompts at 1, 4, 8 requests). - The post-attention and post-MLP short convs add their BF16 output straight into the residual stream (inkling2_residual / inkling2_layer_out's arithmetic, bit-identical); those two kernels and their buffers are gone. Preliminary, single runs on one GB10 (Spark weights, CUTLASS BF16 GEMMs): 32K cold prefill TTFT (nsys) 7.79 -> 7.52 s at 4,096-token chunks, 7.12 s at 8,192. Prompt logprobs move against the previous build within the chunk-size noise floor (mean NLL 1.1659 vs 1.1676-1.1683). (cherry picked from commit 2212872; the ATLAS_PREFILL_BUSY_TOKENS chunk cap it also added is left out: the next change in this series makes it unnecessary and removed it.) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r BF16 states On a prefill chunk's gated visits the message block residual no longer writes its four fp32 message planes: inkling2_block_res_row stores each row's mix weights (p_out, 144 bytes a row) and the messages' sums of squares, and gb10's inkling2_msg_gate_fused rebuilds every message it needs from the message stack's BF16 states with those weights, in the mix's own operation order, so each value is the fp32 message bit for bit. All of a launch's gates now share one read of the states (and of h when they share it) a step; the kernel moves to dynamic shared memory (78.7 KB). The AMD WMMA port keeps reading the fp32 messages. The fused gate now runs on prefill chunks only (it also took plain decode batches of 16 rows or more, whose text then depended on the batch size). Preliminary, one GB10, 32K-token cold prefill at 4,096-token chunks (nsys): TTFT 7.52 -> 7.32 s (gates 726 -> 671 ms, block residuals 542 -> 414 ms). Prompt logprobs bit-identical to the previous build on 56K positions; greedy text with drafts equals text without at 1, 4 and 8 requests. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 3a1a6ba)
inkling2_flash_prefill took one KV head and 64 query rows per CTA: 12 warps for the group's 3 query heads, 32-key tiles, 168 registers, one CTA an SM. Sliding-window visits ran at about 31 TFLOP/s. The kernel now follows the layout of knapcio/Inkling-2-Mini-1x-DGX-Spark's inkling_attn (MIT), with our numerics and gated epilogue: - one query head a CTA, 4 warps, two CTAs an SM; heads fastest in the grid, so the group's query heads read a KV tile from L2; - 64-key tiles, newest first, K and V in single buffers that alternate (V loads under QK^T, the next K under PV), rows XOR-swizzled for ldmatrix.x4; - the bias tile staged as BF16, read two at a time from parity-shifted rows, added in one loop; masks in a second loop, only on tiles at the diagonal or the window's edge; - exp2.approx.ftz, -inf masks, scale plus bias as one fma; - keys located by shifts (block sizes are powers of two, now checked); - rel_proj on gb10 as BF16 lanes [extent + 1, 16], one 8-byte load per bias MMA fragment with a zero row past the extent (bias_lanes; AMD keeps the F32 table). Per-score branches had made the compiler copy the softmax per path; the loop is now about 1,600 SASS instructions with 242 registers. One GB10, 8,192 rows, kernel against kernel (preliminary): sliding window 3.09 -> 2.28 ms, a global visit after 24,576 keys 53.5 -> 41.3 ms; error against an FP64 reference no larger at any tested shape. Spark, 32,768-token cold prompt at 8,192-token chunks (nsys): attention 1.57 -> 1.18 s, TTFT 6.87 -> 6.48 s. Numerics: rounding moves with the tile order and size. Teacher-forced prompt logprobs on 56 1K-token and 7 8K-token documents: per-document median NLL unchanged (+0.0009), five categories flat; chat reasoning and tool calling means rose (one unstable document, and eight sharing a prefix), as earlier rounding changes moved them either way. The same code with 32-key tiles, oldest first and the old arithmetic reproduces the old kernel bit for bit. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 2b6c199)
Prefill's routed experts wrote gate_up as BF16 [slots, 2 I] (302 MB a visit at 8,192-row chunks) and read it back to apply the softcapped SwiGLU and quantize it for the down GEMM. Both now happen in the gate_up GEMM's epilogue, bit for bit as before: - NVFP4 (inkling2_moe_fused_gate_up_fp4): a row's outer scale needs its maximum over all I values, which the 18 column tiles of its row tile hold between them. Persistent CTAs take (row tile, column tile) items in order from a counter; each tile stages its SwiGLU values, publishes its rows' partial maxima, meets its row tile's other tiles at a counter, then quantizes its own blocks. Taken items are always a prefix, so a waiting tile's partners are running or will be taken by CTAs that are not waiting; at least one row tile's tiles must be resident at once (checked). Round-robin items were 25% slower: the CTAs drift apart and the experts' weights leave L2. - MXFP8 (inkling2_moe_fused_gate_up_mx8): a 32-value block is half a tile, so no tile waits. inkling2_situ_quant_fp4 / _mxfp8 are gone; on gb10 gu shrinks to the fused kernel's scratch (about 300 MB less arena at 8,192-row chunks). Both kernels read tiles[0] through a volatile load: through `const __restrict__` ptxas scheduled it ahead of the PDL wait (ACQBULK), so CTAs started early took the previous visit's count and the prefill hung. No other PDL kernel in the Inkling or common sets loads ahead of its wait (SASS scan). One GB10 (preliminary, single runs): gate_up + SwiGLU-quantize at 8,192 rows 6.93 -> 5.31 ms in a standalone bench (outputs byte-identical); a 32,768-token cold prompt at 8,192-token chunks 6.48 -> 6.35 s (nsys), the 63 prompts of the prompt-logprob check identical to the previous build's. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 4c1154a)
The fused gate_up kept its per-row partial maxima slot-major ([slots, N / 128]), so each tile's 128 stores and the 18 __ldcg reads per row were strided (L1 is bypassed). Back to the tile-major [row tiles, N / 128, 128] the bench measured: 6.37 -> 5.64 ms a call at 8K-token chunks (median over 176 calls, one 32K prefill on one GB10; the down GEMM beside it unchanged at 2.52 / 2.53 ms), 32K TTFT 6.35 -> 6.21 s (preliminary, single run). Prompt logprobs on the 63-prompt set byte-identical to the unfused build. The buffer grows by experts x 18 x 512 bytes (~1.2 MB). Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 859bcf0)
The PDL contract (pdl_target_kernels_wait_exactly_when_listed) wants atlas_pdl_enter() as a listed kernel's first statement; both fused kernels declared their shared memory before it. No change to the generated waits. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit a4dbba3)
The gb10 flash prefill now takes one query head a CTA and gates its output; the strix-hip wave32 WMMA port keeps the previous geometry and ungated output. Say so where the two bodies meet; attn_ops.rs launches each on its own platform. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Formatting only (cargo fmt --all). Co-Authored-By: Claude Opus 5.5 <[email protected]>
A visit's k/v convs and per-head norms move to forward_heads.rs as kv_convs_and_head_norms; the code is moved as is, with the batch's positions passed in for the log-length scale. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A new prompt's first chunk runs inline while new requests are admitted; the continue phase then ran its second chunk in the same tick, so a stream decoding beside it waited two chunks. Only EP models and the decode-share levers ended the tick after the first chunk. Now any model does when sequences were decoding before the tick. Inkling 2 Mini, Spark, one GB10, a 32,768-token prompt beside one streaming request (preliminary, single runs): one 8,192-token chunk a tick took 7.24 s with a 2.09 s worst stream gap, one chunk's compute; plain 8,192-token chunks before this change gave 3.47 s gaps. (cherry picked from commit d24c56a; the ATLAS_PREFILL_BUSY_TOKENS cap it removed was never proposed here.) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@data-angel Gated as the tree Probe: two streaming decodes run, then a cold, unique prompt arrives. I record the decoders' longest inter-token gap while that prompt is in flight, and its TTFT. 3 reps each, medians shown; the reps are within ±0.1 s.
So the worst gap drops by a third to a half wherever the new condition fires, for about 1% of the joining prompt's TTFT. Where a decode-share lever was already on, nothing moves, as the code says. Your 3.47 → 2.09 s receipt matches the 8,192-chunk row. Text is unchanged: greedy C1 / C8 parent vs PR are 8/8 · 8/8 on Inkling Spark, Qwen3.8-27B (both profiles; lp_dump max|Δ| 0 on 26,912 tokens) and Flash-Next. The release profile is 8/8 at C1, and cachehit warm == cold 6/6. 0 ERROR lines anywhere. No kernel changes, so there's no strix-hip leg. CI workspace jobs pass. Merging after #432, which is waiting on an AMD ST-995. sparky nightq 212 / 214 · parent 🤖 Generated with Claude Code |
Change 4 of 4 porting the SparkInkling 0.5.1 engine to
main, stacked on #432 (one commit past it).What
This changes the shared scheduler, for every model. A new prompt's first chunk runs inline while new requests
are admitted; the continue phase then ran its second chunk in the same tick, so a stream decoding beside it waited
two chunks. Only EP models and the decode-share levers ended the tick after the first chunk. Now any model does when
sequences were decoding before the tick (
decoding_beforejoinshead_just_started's condition). With nothingdecoding, a prompt still runs its chunks back to back.
What it costs: a prompt that arrives while others decode starts one chunk a tick, so its TTFT includes the decode
steps between its chunks. What it buys: the longest gap a decoding stream sees is one chunk's compute, not two,
which is what lets SparkInkling 0.5.1's profiles run 8,192-token chunks (
--max-prefill-tokens 8192; 0.5.0 ran4,096) without longer stalls for the streams beside a long prompt. On the fork this replaced an
ATLAS_PREFILL_BUSY_TOKENSchunk cap, which is not proposed here.Observed: the commit message's figures are the fork's preliminary single runs on one GB10 (Inkling 2 Mini,
Spark, a 32,768-token prompt beside one streaming request: worst stream gap 3.47 s with plain 8,192-token chunks,
2.09 s with one chunk a tick). SparkInkling 0.5.1's SparkModelBench numbers (#432) were measured with this change.
No other model was measured with it; GLM's prefill levers (
ATLAS_GLM_WARM_CHUNK_RUN,ATLAS_GLM_PREFILL_YIELD_MS) are unchanged.The series
The engine of SparkInkling 0.5.1
(
Enntity/atlasinkling2/rc-0.5.1-20261126ata4dbba378), ported ontomain(9f4fd773f) as one changeper PR, stacked linearly:
The DFlash2 drafter commits that 0.5.0 carried are already on
main. Two things are not in this series:the fork's
ATLAS_PREFILL_BUSY_TOKENSchunk cap (#4 here makes it unnecessary, and the fork removed it, so it isnot proposed and no PR adds an
ATLAS_*name) and the opt-in LoopCD (--loopcd), which is not proposed for now.After #4, the engine files these commits touch equal
a4dbba378's except formain's own changes underneaththem (
glue.rs'sroute/kv_writenow inglue/route.rs;weights.rs,serve_load.rs),rustfmt, code movedas is to keep files under the 500-line cap (#2, #3), and the AMD flash prefill kept beside the new gb10 kernel (#3).
Where the numbers come from. Every GPU number below was measured on the fork's engine on its older base
(before #413 and #426), not on these branches: SparkModelBench
293a44f(RigMark protocol 1.3.0, RigMark Qualityv0.0.2,
reasoning_effort: low) on one DGX Spark, SparkInkling 0.5.1's default profile, published with receipts inresults/2026-11-27-rc-0.5.1.
No GPU has run these rebased branches.
Test plan
-D warnings, spark-runtime / spark-model / spark-server,--tests),cargo test --releaseof those crates (spark-model 2,526, spark-runtime 608 and spark-server 3,258 passed; the same five spark-server tests fail onmainin this container (three need a.gitcheckout, two read the disk's free space)), the 500-line cap, SPDX and kernel-shadow checks; no newATLAS_*nameAuthorship
AI-authored: Claude (Opus 5.5) in Claude Code, directed and reviewed by a human; no hand-written code.
CLA
🤖 Generated with Claude Code