Repository navigation
score: one-pass prefill-only scoring (/v1/score) and W4A4 dense 27B prefill kernels for GB10 - #331
Merged
AzeezIsh merged 61 commits intoNov 10, 2026
Conversation
Score a shared prefix and N branch continuations in ONE forward pass: the head stream (prefix[0..F)) and every branch (prefix[F..L) ++ q_i) are stacked in one varlen batch, so norms, projections and MoE read their weights once per request. Branch block tables share the head's whole blocks (ref-counted); attention needs no ordering because the batched varlen kernel derives each stream's causal offset from kv_lens. Only the GDN recurrence is ordered: head first, then its conv window and h state are copied into each branch before the branches run together. Returns per-branch softmax over single option tokens at the branch's last row. Jobs run on their own scheduler channel at a quiescent point. ATLAS_SCORE_TRACE=1|2 logs phase timings. Also: ChatTokenizer::vocab_size() avoids rebuilding the 248k-entry vocab map (~45 ms) on every /v1/completions token-id validation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…head With --lm-head-dtype bf16 the score path computes only the N x K option logits (FP32 dot products against cached BF16 head rows) instead of the full-vocabulary head and full-row host copies. Checkpoints that ship a pre-packed NVFP4 head keep the full-vocabulary path. Splits the score head and the ATLAS_SCORE_TRACE=2 profiler out of score.rs (500-LoC cap). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Model::score_branches becomes Model::score_requests over a slice of ScoreInput: every request's head (prefix[0..F)) runs first, all heads in one varlen GDN scan from the zero state; each head's conv window and recurrent state are then forked into its own branches, and all branches of all requests run in one varlen scan. Norms, projections and MoE still run once over every row, so queued requests share one read of the weights. The scheduler packs queued /v1/score jobs into one pass up to the prefill arena and the SSM slot count; a failed merged pass retries each job alone. Responses report how many requests shared the pass (batched). Observed (one Spark, KnowLine-35B-A3B NVFP4, 300-token states with 4 questions each; preliminary, single run): 8 concurrent requests finish in 1.07 s against ~1.50 s sequential, with probabilities bit-identical to each request run alone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…L_BF16MMA)
Opt-in routed-expert prefill for qwen3.6-35b-a3b/nvfp4: a gate/up GEMM
with SiLU·mul in its epilogue and a down GEMM, both mma.sync m16n8k16
BF16 with the NVFP4 weights dequantized in registers.
The FP8 kernels dequantize each B tile into shared memory between two
barriers and run M64 tiles that are half empty at ~33 rows per expert.
Here weights are the MMA A operand and tokens the B operand (8-token
tiles), each warp dequantizes its own features once per CTA (bit
placement + one bf16x2 multiply) for all token tiles of a <=64-row chunk,
and the K order inside a stage is permuted so a thread's k range is one
scale group. Weights come from the transposed prefill tables the FP8
kernels already read; the checkpoint [N, K/2] layout streamed at 124 vs
207 GB/s for the same bytes.
Precision: e2m1 x e4m3 block scale is exact in BF16 (scale pre-multiplied
by 2^118, global scale applied to the FP32 accumulators) and activations
stay BF16 instead of E4M3. Isolated, vs an FP64 reference: mean error
1.1e-3 of row RMS (BF16 output rounding) vs 2.8e-2 for the FP8 kernels.
Per MoE layer, one score pass (spark serve --profile), FP8 -> BF16-MMA:
rows gate_up (us) down (us, incl. SiLU before)
96 756 -> 601 439 -> 312
288 1055 -> 777 649 -> 423
1056 1860 -> 1283 1288 -> 729
2112 2924 -> 1939 2229 -> 1093
4128 4871 -> 3136 3911 -> 1700
Lever off is bit-identical to the parent build (169 score distributions).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…alves 256-thread CTAs: two 128-thread halves with their own weight features read one staged token tile, halving token reads from L2, and two cp.async stages keep 2 CTAs (16 warps) per SM. The token-tile count is a template argument so the tile loads issue ahead of the MMAs. Same per-thread K order, so the outputs are bit-identical to the previous commit (169 score distributions). Per MoE layer, one score pass (spark serve --profile), previous -> now: rows gate_up (us) down (us) 1056 1283 -> 1108 729 -> 679 2112 1939 -> 1560 1093 -> 967 4128 3136 -> 2385 1700 -> 1444 96 and 288 unchanged (weight-bandwidth bound). Co-Authored-By: Claude Opus 5.5 <[email protected]>
With 16 warps per SM, chaining four down tiles per CTA no longer pays (isolated: 0.90 vs 0.86 ms at 1k rows), so every CTA computes one tile and both kernels stage their epilogue through shared memory. What the chaining still bought in serve was fewer empty CTAs: the down grid now covers 4x the average expert along y and the kernel strides the rest. Gate/up keeps the full grid, where the hot experts' serialized chunks cost more. Down per layer, one score pass, previous -> now (us): 96 309 -> 292, 288 420 -> 415, 1056 679 -> 662, 2112 967 -> 944, 4128 1444 -> 1481. Outputs bit-identical (169 score distributions). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
/v1/score accepts "attention": "prefix_bidir" (d3-style decision models): in the full-attention layers the prefix is a state block read in both directions that never sees a branch, and each branch is a question block that reads the whole state and itself in both directions; GDN layers stay causal. The batched paged attention kernels (BF16/FP8/NVFP4 KV) take a per-stream state_end (PREFILL_STATE_END; -1 or NULL keeps a stream causal, byte-identical to before): a query at slot p < state_end reads keys below state_end, any other query reads every key of its stream. A bidirectional head reads the state's partial last block from its first branch, so its KV extent is the state end. Causal and bidirectional requests can share a pass. Checked on KnowLine (causal) that the causal path is unchanged (same battery KL and latency), and that prefix_bidir is deterministic and merged == solo for prefixes of 12, 37, 64 and 300 tokens. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A /v1/score job whose rows or sequences exceed one pass (the prefill arena, the SSM slot count) runs as several passes over its prefix and consecutive subsets of its branches, reassembled in order, instead of failing with 'rows exceed the prefill arena'. Found by Decision Index long-context rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Model::score_capacity reports the rows and sequences one score pass can take: the prefill arena capped by the GDN prefill buffers (sized min(max_batch_tokens, max_seq_len)) and the SSM state pool. The score path checks it with an actionable error, and the scheduler packs and splits jobs to it. Before, a pass over max_seq_len rows overran the GDN buffers (cuMemcpyDtoDAsync invalid value). Co-Authored-By: Claude Opus 5.5 <[email protected]>
A 33-stream, ~31k-row Decision Index request passed the arena and GDN checks but overflowed the fixed metadata scratch. score_capacity now caps rows by what the scratch holds (MoE top-k staging, per-stream metadata, staged positions and slots, per-stream pointer entries), so the scheduler splits such requests instead of failing them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fill Moves the cp.async staging, exact NVFP4 dequant, block-scale swizzles, slot loads and the m16n8k16 BF16 MMA of moe_bf16mma_prefill.cu into kernels/gb10/common/bf16mma_dequant.cuh, adds the exact e4m3 -> BF16 pair decode the dense FP8 path needs, and moves the MoE GPU test's FP64 reference helpers into layers/bf16mma_test_ref.rs for reuse. The MoE kernel's PTX is byte-identical before and after (md5 ba911a66, nvcc 13.0 -O3 -arch=sm_121a --fmad=false). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ILL_BF16MMA)
Opt-in prefill GEMMs for the qwen3.6/3.8-27B target, mma.sync m16n8k16
BF16 with the weights dequantized exactly in registers (the MoE kernel's
design: weights are the A operand, tokens 8-row B tiles, two 128-thread
feature halves sharing a staged token tile):
* NVFP4 MLP: gate+up in one GEMM with SiLU*up in the epilogue, then down,
on the transposed [K/2, N] prefill tables (two launches for three GEMMs
and a SiLU-mul).
* GDN in_proj_qkvz / out_proj: the checkpoint's per-tensor FP8 [N, K] rows
(block-scale grid checked constant along K at load), where the default
quantized activations per 128 for an FP8 x FP8 GEMM at 12.6 TFLOPS.
* Attention q/k/v/o: the transposed NVFP4 tables.
* GDN in_proj_ba + gates: a token-tiled MMA kernel (the token-parallel one
re-read the weights from L2 per token: 0.67 ms per layer at 1k rows).
Activations stay BF16 where the default W4A16 tile kernels round them to
E4M3. The grid is rasterized in 16-chunk groups so a weight tile streams
from DRAM once per 1024 rows, and the host picks the row-chunk count for
the wave count; every output is one CTA's fixed-order K loop, so results do
not depend on the grid (115 score distributions bit-identical across two
grid choices). Lookups happen only with the lever set, so other targets'
boot audits are unchanged; lever off is bit-identical to the parent on the
d3 oracle set.
Preliminary, single-harness (ennspark04, d3-ultra-NVFP4, serve flags as in
the SparkScore runbook, ATLAS_SSM_DECODE_RING=0 ATLAS_GDN_BATCHED_FLA=1,
score_sweep prefix_bidir, one rep of 5, median engine ms):
rows parent lever on
96 258.7 145.3
288 569.8 280.2
1056 1830.5 905.8
2112 3495.2 1798.8
4128 6824.5 3530.6
(gdn_ba_gates_prefill was measured at every row count; it now starts at
256 rows, where its few CTAs stop losing to the old kernel: 79 vs 62 us at
96 rows.)
d3 oracle (d3_mask_check, 49 answers, d3's BF16 logits): prefix_bidir mean
KL 0.0163 -> 0.0106, argmax agree 47/49 -> 47/49; causal 0.0494 -> 0.0474.
A/B vs the parent over 115 distributions: mean KL 2.4e-3, max |dp| 0.11,
one argmax flip (the parent's E4M3 activation noise; the oracle moves
toward d3's own runtime).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eam/systemone-score-20261105
… lever Only qwen3.6-35b-a3b ships moe_bf16mma_prefill, and a lookup that misses fails the boot audit, so other MoE targets must not issue it. The GPU test resolves the kernels directly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A score pass computes exactly rows [0, total), but zeroed the whole prefill essentials (hidden, residual and the dense FFN scratch, about 1.8 GB at a 16K-row arena: ~9 ms of memset ahead of the first kernel on every pass). Zero each buffer's share of the pass's rows instead; rows past it keep what an earlier pass left, as they already do in every prefill chunk after the first. Probs are bit-identical to the previous build over a 16-request set run largest-first (stale rows present). Preliminary, single-harness (with the next commit, d3-ultra-NVFP4, score_sweep_d3 N=1 median of 5, one box): engine ms 145.1/281.0/905.3/3538.9 -> 134.6/269.2/891.1/3509.9 at 96/288/1056/4128 rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
rope_forward_mrope_interleaved evaluated an FP64 pow and a sincos per (position, pair, head), 28 times over at the 27B's head count. The angle depends only on (position, pair): a block now walks heads x, x+grid.x, ... with one evaluation. grid.x = heads is the old launch exactly; the launcher gives each block several heads once the row count alone fills ~4 blocks an SM, and decode-sized calls keep one head a block. Same arithmetic per element: probs bit-identical to the previous build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…UNK_TC)
One kernel per GDN scan in place of the FLA path's three (recompute_wu,
the state spine, fwd_o): a CTA per (stream, value head, 64-column value
block) walks the stream's 64-token chunks with every matmul on mma.sync
m16n8k16 and FP32 accumulation, and only the output and the final state
leave it. Per chunk:
T = (I + L)^-1 FP32 diagonal blocks, split-BF16 MMA merges
R = V - diag(e^gc) K S so uc = T diag(b) R = U - W S without W or U
O = (diag(e^gc) Q S + P uc) / sqrt(d)
S <- e^gc_last S + (K diag(decay))^T uc (S FP32 in registers)
FP32 intermediates that feed a product (S, R, T diag(b), P, uc, decayed
K) are split into BF16 hi + lo; the in-chunk gate sum stays serial in
token order. Two warp groups overlap the state-free half of a chunk
(K K^T, the inverse) with the state half (K S, Q S, Q K^T), and the next
chunk's K and V stream in with cp.async while the current one computes.
Each stream is computed by its own CTAs, so results do not depend on what
shares the launch. Wired into the single-stream, uniform-batch and varlen
scans; the module ships for the 27B dense targets and is looked up only
with the lever set.
Isolated kernel, 48 v-heads, one stream (ennspark03): T=256 100 us,
T=4096 1376 us. nsys GPU ms per pass for the GDN scan kernels (three FLA
kernels -> this one), preliminary, single-harness: d3-ultra-NVFP4, serve
flags --kv-cache-dtype bf16 --max-seq-len 16384 --max-num-seqs 32
--max-batch-size 32 --max-prefill-tokens 16384
--gpu-memory-utilization 0.80 --disable-thinking --lm-head-dtype bf16,
ATLAS_SSM_DECODE_RING=0 ATLAS_GDN_BATCHED_FLA=1
ATLAS_DENSE_PREFILL_BF16MMA=1, score_sweep_d3 shapes N=1, ennspark03,
2026-11-06, one captured pass each:
rows 288: 29.6 -> 7.5 rows 1056: 105.4 -> 21.1 rows 4128: 384 -> 73.5
Engine ms, this commit vs its parent, median of 5:
rows parent lever on
96 134.6 125.6
288 269.2 247.3
1056 891.1 803.1
4128 3509.9 3250.0
d3 oracle (49 answers vs d3's BF16 logits): prefix_bidir mean KL
0.00964 -> 0.00890, argmax agree 47/49 -> 47/49; causal 0.0471 -> 0.0469.
Repeat passes are bit-identical; merged-vs-solo matches the parent's
(three small-prefix requests differ in both: the attention BR choice).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
alloc_sequence resets a slot's whole SSM column (h, conv, and the MTP intermediates and checkpoints: ~1.7 ms of memset per stream on the 27B) and synchronizes. A score branch with a head gets the head's conv window and recurrent state copied over whole, and a score pass never reads the MTP scratch, so allocate score streams without the reset and zero h and conv only for streams that start from zero (heads, and branches of a prefix shorter than a block). The slot's next owner still resets it on claim. Probs bit-identical to the parent over the 16-request set. Preliminary, single-harness (same serve flags and levers as the previous commit plus ATLAS_GDN_CHUNK_TC=1, score_sweep_d3 median of 5, ennspark03), engine ms parent -> this commit: L=64: N=1 124.7 -> 125.8 N=4 192.1 -> 187.9 N=16 529.4 -> 510.2 L=256: N=1 247.2 -> 246.2 N=4 328.3 -> 322.0 N=16 665.9 -> 642.5 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s (ATLAS_DENSE_PREFILL_LOWP)
Opt-in on top of ATLAS_DENSE_PREFILL_BF16MMA=1, per projection group:
`gu,dn,qkv,o` (NVFP4 weights x NVFP4 tokens, W4A4), `gu8,dn8,qkv8,o8`
(NVFP4 weights x E4M3 tokens, W4A8) and `qkvz,gout` (the GDN FP8 weights
x E4M3 tokens, W8A8); `all` = every W4A4 / W8A8 group. The BF16-MMA
kernels' CTA tiling, raster and weight staging are shared (db_body gains
the token format as a template parameter; the BF16 instantiations are
unchanged, lever off is bit-identical on the d3 oracle set):
* W4A4: mma.sync kind::mxf4nvf4 m16n8k64; the MMA applies both E4M3
per-16 block scales, so the weights are the checkpoint's bytes
(byte-transposed in registers from the [K/2, N] prefill tables).
* W8A8: m16n8k32 e4m3 on the per-tensor FP8 rows.
* W4A8: kind::mxf8f6f4 scale_vec::1X; each feature's NVFP4 values are
re-encoded per 64-K stage as E4M3 of w*s/2^E with 2^E as the UE8M0
row scale (values with <= 4 significant bits exact, the rest round
once). Correct but ALU-bound as written.
* Tokens are quantized per token by dl_quant_nvfp4 (the ModelOpt
NVFP4 quantizer under a power-of-two per-token global scale) or
dl_quant_fp8 (E4M3, power-of-two per-token scale) into the arena's
ffn_act scratch; the GEMM epilogue applies the token scale with the
weight tensor scale. Fixed K order per output, as before.
GPU test: the kernels against an FP64 reference on the activations read
back from the scratch (the quantizer checked on the way: power-of-two
token scale, block scales within E4M3 rounding, nearest codes).
Preliminary, single-harness (one GB10, d3-ultra-NVFP4, serve flags of
the SparkScore runbook, ATLAS_SSM_DECODE_RING=0 ATLAS_GDN_BATCHED_FLA=1
ATLAS_DENSE_PREFILL_BF16MMA=1, score_sweep_d3 prefix_bidir, one rep of 5,
median engine ms):
rows BF16-MMA gu,dn,qkvz,gout all qkvz,gout gu8,dn8,qkvz,gout
96 143.7 135.0 134.8 143.5 152.2
288 280.4 227.5 223.1 273.6 290.6
1056 905.3 651.6 633.8 851.2 850.3
4128 3534.8 2467.5 2381.9 3292.9 3185.7
d3 oracle (prefix_bidir, 49 answers, d3's BF16 logits), mean KL / agree,
and the A/B vs BF16-MMA over 115 distributions (mean KL):
BF16-MMA 0.00964 47/49; gu,dn,qkvz,gout 0.0121 48/49 (2.5e-3);
all 0.0214 47/49 (3.7e-3); qkvz,gout 0.0123 47/49 (4.5e-4);
gu8,dn8,qkvz,gout 0.0145 47/49 (7.8e-4).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
With ATLAS_GDN_CHUNK_TC the scan kernel now normalizes its Q and K rows itself, bit for bit as l2_norm_bf16 (same pair squares, the same butterfly-per-warp reduction rebuilt from the quad that holds a row, eps 1e-6), and prefill_phase1_l2_batched skips the separate pass exactly when the fused kernel serves every scan (`gdn_chunk_tc_serves`, one predicate for both). Paths that normalize on their own only re-normalize unit rows. Probs bit-identical to the parent over the 16-request set, so the d3 oracle is unchanged (prefix_bidir mean KL 0.00890, agree 47/49). Preliminary, single-harness (serve flags and levers as the previous commit, ATLAS_GDN_CHUNK_TC=1, score_sweep_d3 N=1 median of 5, ennspark03), engine ms parent -> this commit: 96 rows 125.8 -> 125.3, 288 246.2 -> 245.0, 1056 800.9 -> 793.4, 4128 3189.9 -> 3172.0 Co-Authored-By: Claude Opus 5.5 <[email protected]>
prefill_phase1_proj_batched ran the BA projection + gates into ssm_gates and then copied the whole [rows, 2 nv] FP32 block into gdn_bufs.gate_beta, which has the same layout. Write it there directly: one D2D copy per SSM layer fewer, and the GPU idle gap it opened between the gates kernel and conv1d. Same values (shared file: only the output pointer of the existing ba_gates_prefill call changes). Probs bit-identical over the 16-request set (measured with the next commit). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d's state in place With ATLAS_GDN_CHUNK_TC a score pass's recurrence is two launches per SSM layer: every head from zero, then every branch with the kernel's new entry-state table pointing at its head's final state, so the 3 MB-per- layer state copy into each branch (and the gap it opened before the scan) is gone. The per-layer state and entry-state pointer tables for all SSM layers are staged once per pass (`score_stage_ssm_tables`; the capacity check counts them). The layer side is a new TransformerLayer method, `score_gdn_scan` (default Ok(false), shared trait: one method added); without the lever the pass keeps the fork + group path unchanged. Probs bit-identical to the parent over the 16-request set; merged-vs-solo unchanged (the three small-prefix mismatches predate this branch: the BA-gates kernel switches implementation at 256 pass rows). Preliminary, single-harness (serve flags and levers as before, ATLAS_GDN_CHUNK_TC=1, score_sweep_d3 median of 5, ennspark03), engine ms with the previous commit, parent -> this: 96 rows 125.3 -> 123.9, 288 245.0 -> 244.2, 1056 793.4 -> 794.1, 4128 3172.0 -> 3175.2; N=4: 192 rows 187.9 -> 183.0, 384 322.0 -> 318.0 (parent N=4 figures from two builds earlier, same harness) Co-Authored-By: Claude Opus 5.5 <[email protected]>
free_sequence zeroes the slot's h and conv state for all SSM layers and
synchronizes (~1.7 ms of memset per stream on the 27B, inside the score
engine time). Every claim already zeroes what it reads (alloc_sequence's
reset; a score stream zeroes its start state or reads its head's), so
the score pass now frees through free_sequence_dispatch(seq, false),
which releases the slot unzeroed. Every other caller keeps the zeroing
free (`Model::free_sequence` passes true).
Probs bit-identical over the 16-request set run twice back to back (the
second run on unzeroed slots), and a greedy chat completion is identical
before and after score passes. Preliminary, single-harness (as the
previous commit), engine ms parent -> this:
N=1: 96 rows 123.9 -> 120.8, 288 244.2 -> 241.3, 1056 794.1 -> 793.6,
4128 3175.2 -> 3169.4
N=4: 192 rows 183.0 -> 177.0, 384 318.0 -> 310.6
N=16: 576 rows 510.2 -> 458.5, 768 642.5 -> 598.8 (N=16 parent from
two builds earlier)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eaper W4A8 re-encode The low-precision twins run one CTA per SM with 16 token tiles per warp (128-row chunks): each weight tile is read from L2 by half as many CTAs, which bounded W4A4 / W8A8 at a few hundred rows (a loads-only ablation of W4A4 gate+up at 288 rows took 750 of its 786 us, and grew with the chunk count). The K loop is instantiated per tile count instead of switching per stage. Per-output arithmetic is unchanged: 115 d3 score distributions bit-identical to the previous commit. W4A8 re-encodes with cvt.rn.f16x2.e2m1x2 and one f16 multiply per pair, and derives the per-stage UE8M0 exponent from the FP32 bits. Preliminary, single-harness (one GB10, microbenchmark at the 27B shapes, min of 5 x 10 launches, us; BF16-MMA / before / after): W4A4 gate+up 288 rows 1296 / 786 / 755 1056: 4683 / 2722 / 2415 W4A4 down 288 815 / 525 / 372 1056: 2286 / 1159 / 1060 W8A8 qkvz 288 725 / 617 / 530 1056: 2491 / 1591 / 1233 W4A8 gate+up 288 1298 / 1421 / 998 End to end, ATLAS_DENSE_PREFILL_LOWP=gu,dn,qkvz,gout (serve flags of the SparkScore runbook, score_sweep_d3 prefix_bidir, one rep of 5, median engine ms; BF16-MMA -> previous commit -> this one): 96 rows 143.7 -> 135.0 -> 133.3; 288: 280.4 -> 227.5 -> 207.8; 1056: 905.3 -> 651.6 -> 603.2; 4128: 3534.8 -> 2467.5 -> 2450.1. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…w-precision GEMMs Each stage's buffer has a full mbarrier (every thread's cp.async copies, cp.async.mbarrier.arrive.noinc) and an empty one (every thread done reading it); the next stage is issued after computing the current one, so a warp may run a stage ahead of the slowest. A compute-only ablation of W4A4 gate+up at 4128 rows spent a quarter of its time in the per-stage __syncthreads. Four stages for all three kernels (W8A8 at 96 KiB). The lever's `1` now means gu,dn,qkvz,gout (W4A4 MLP, W8A8 GDN). Per-output arithmetic unchanged (115 d3 score distributions bit-identical). Preliminary, single-harness (one GB10, microbenchmark at the 27B shapes, min of 5 x 10 launches, us; previous commit -> this one): W4A4 gate+up 288: 755 -> 656 1056: 2415 -> 1838 4128: 9310 -> 7512 W4A4 down 288: 372 -> 381 1056: 1060 -> 862 4128: 3992 -> 3694 W8A8 qkvz 288: 530 -> 527 1056: 1233 -> 1122 4128: 5090 -> 4764 W4A8 gate+up 288: 998 -> 952 4128: 12852 -> 11836 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e27b-lowp-gemm-20261106
… solo) serves_ba picked the tensor-core BA kernel by the pass's total rows (>= 256), and the two kernels sum in different orders, so a request's gates, and its score probabilities, changed with what it was batched with. The tensor-core kernel now serves every row count on this path: per layer 79 vs 62 us at 96 rows (under 1 ms a pass), 155 vs 674 us at 1056. Merged vs solo (12 d3 answers of 108..149 prompt tokens, solo then all 12 concurrently, three rounds; one GB10, serve flags of the SparkScore runbook plus ATLAS_DENSE_PREFILL_BF16MMA=1 ATLAS_GDN_CHUNK_TC=1): before 4/36 bit-identical (max |dp| 4.0e-4, ATLAS_DENSE_PREFILL_LOWP=gu,dn,qkvz,gout); after 36/36 with that mix, with gu8,dn8,qkv8,o8,qkvz,gout, and with the low-precision lever off. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…_ROWS128)
A FlashAttention-2 layout of inferspark_prefill_paged_batched_64 for the
BF16 KV cache at HDIM 256, same arguments and masks (causal, sliding
window, PREFILL_STATE_END prefix-bidirectional):
* every warp owns 16 query rows end to end: Q as A-fragments in
registers, S, the online softmax and O; P goes from the S
accumulators straight into the PV A-fragments (no P tile, no row-stat
exchange), K and V fragments by ldmatrix (.trans for V);
* K and V double buffered and shared by 128 rows, V converted to FP16
once per tile in place by the threads that loaded it, one barrier per
KV tile, shifts for the power-of-two page size.
Per row it processes the BR=64 kernel's KV tiles plus, at most, tiles
fully masked for that row (exp(-1e30 - m) = 0 leaves m, l and O as they
were), with every MMA, softmax update and rounding in the same order, so
the output is bit-identical: 0 differing elements of 25.2 M against the
BR=64 kernel at 4096 rows in both mask modes, and score probs bit-identical
over the 16-request set (so d3 oracle unchanged, prefix_bidir KL 0.00890).
Isolated, one stream, 24 q / 4 kv heads (ennspark03): prefix_bidir 4096
rows 14.4 -> 7.4 ms (28 -> 55 TFLOPS), causal 7.6 -> 4.0 ms; 2500 rows
bidir 5.6 -> about 3.3 ms. Preliminary, single-harness (serve flags as
before, ATLAS_GDN_CHUNK_TC=1, score_sweep_d3 median of 5), engine ms
parent -> lever on: 96 rows 120.8 -> 122.4, 288 241.3 -> 241.1, 1056
793.6 -> 785.7, 4128 3173.2 -> 3051.4, 2112 rows (L=2048 N=2) 1576.0 ->
1548.7. The module ships for the 27B dense targets and is looked up only
with the lever set.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The GDN W8A8 projections (qkvz, out) stream each weight line through L2 once; their cp.async copies now carry an L2::evict_first cache policy so they do not evict the lines the kernel's other row chunks and the following kernels read. Copies, operands and MMAs are unchanged: results are bit-identical. The W4A4 kernels measured slower with it (their second token tile re-reads the weights from L2), so they keep normal copies. The engine/microbenchmark gap on these kernels (565 vs 454 us for qkvz at 288 rows) was mostly the microbenchmark: back-to-back launches leave part of the weights in L2. With L2 flushed between calls the microbenchmark gives 510 us (and 464 with this change); under Nsight Compute's fixed clocks the engine and microbenchmark differ by 5 %. Preliminary (GB10, d3-ultra NVFP4, one-pass score, all levers incl. PDL, median of 5, one server run; fingerprint: this commit on 6e8c06a): 288 rows, engine ms: W4A4 everywhere 135.3 (6e8c06a 135.7), W4A4 MLP-only 137.2 (140.9), LOWP=1 149.1 (150.2). nsys (PDL off), 288 rows: qkvz 556 -> 529 us a call, out 213 -> 191 us, W8A8 GEMMs 37.9 -> 35.2 ms. All 115 score distributions identical to 6e8c06a in the three mixes; merged vs solo 36/36 (W4A4 everywhere, LOWP=1); oracles 0.01475, 0.01691, 0.00546. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Score jobs moved from the bounded channel into an unbounded Vec, every queued job ran in one tick (blocking chat admission for the whole backlog), and the handler waited without a deadline. - At most MAX_PENDING_JOBS (64) jobs wait; the handler uses try_send and the receiver refuses past the cap, both as 503 "score queue is full". - A job whose client has gone (reply closed) is dropped unrun. - Each quiescent tick takes only the front jobs that share one merged pass (take_tick); the rest stay queued. An oversized job still runs its split passes in its tick. - The handler waits at most --request-timeout (504; the job is then dropped), and fails fast with 422 when even one branch per pass cannot fit the model's score capacity. - score_tx is None (501) when Model::score_capacity is (0, 0). - The merge/split cost uses the server's KV block size, not a fixed 16. - The endpoint doc states the quiescence requirement and its cost under sustained chat traffic. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, capacity) - A failed pass synchronizes the stream before its sequences' KV blocks and SSM slots go back to the pools (work may still be in flight). - Prefix and branch token ids are checked against the model's vocabulary (embedding rows), as option ids already were. - The gathered BF16 head's host row cache moves from a process-wide static keyed by the head's device pointer onto the model (still keyed by that pointer within it), capped at 1024 rows (cleared when full) and cleared on release, so a reload at the same address cannot serve stale rows. Repeated option ids keep the fast path. - The NVFP4/FP8 head runs in groups of as many rows as the logits arena holds (as batch.rs derives it) instead of a fixed 32. - score_capacity is (0, 0) where score_requests refuses (multi-rank, FP32 logits), so the server answers 501 instead of 422 per request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… state_end Only Qwen3AttentionLayer's batched paged kernels (rows128 included) read BatchedAttnMetadata::state_end; MLA, mHC, QSA-indexer and sliding-window attention would read a "prefix_bidir" request causally and return causal probabilities without saying so. A new TransformerLayer capability, honours_state_end (default false), is true for a Qwen3AttentionLayer with none of those, and a score pass refuses a bidirectional request unless every non-SSM layer has it. (HSS, HDIM > 256 and other KV dtypes already refuse batched mode with an error.) The two MoE transpose hooks in qwen3_attention/trait_impl.rs share an each_moe helper in moe_transpose.rs to keep that file under its cap. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ets its own bit - LowpMix::parse_checked returns the mix plus a note for each unknown name (still dropped), each NVFP4 group named in both token formats (`gu,gu8`: W4A8 wins), and `dnmx` without `gu8`; from_env logs them once per process (tracing::warn). The lever set without ATLAS_DENSE_PREFILL_BF16MMA=1 is warned about once too. - DOWN_MX moves from bit 10, which is GDN_QKVZ << A8, to bit 12, above every shifted group. Nothing queried the colliding bit, so results do not change. - DenseBf16mma::lever and the MoE BF16-MMA kernel lookup read their levers through ModelLevers::opt_in, the rule ModelLevers::from_env applies to the same variables (exactly "1"), instead of local copies. - The DEFAULT doc compares against "a BF16 reference" (no internal name); the DenseBf16mma doc no longer says "the three kernels". Co-Authored-By: Claude Opus 5.5 <[email protected]>
…w count serves_mlp / serves_nvfp4 / serves_fp8 required 32 rows, so with ATLAS_DENSE_PREFILL_BF16MMA=1 a solo score pass under 32 rows took the default projection kernels while the same request merged into a bigger pass took the BF16-MMA / low-precision ones: merged != solo. A new ModelLevers::dense_prefill_any_rows (never from the environment) lifts the floor; score_forward sets it on its own copy of the levers. Within these kernels the row count only picks chunking and bit-identical twins (8-warp below 96/129 rows, persistent above), so a request's rows now take the same arithmetic alone or merged. Chat keeps the 32-row floor: decode and verify batches reach the same prefill helpers (DenseFfnLayer::forward_batched) and keep their small-M kernels. With the levers off nothing changes, including upstream's nvfp4_proj_m128 switch above 128 rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s ineligible - mx_on bypassed the k <= QUANT_MAX_K check that lowp_on applies before dl_quant_fp8: the W4A8 gate+up quantizes its h-wide input either way. It now takes [h, inter] and requires 1 <= h <= QUANT_MAX_K; the down asks with its own [n, k] (= [h, inter]), so both sides of the handoff still agree. - nvfp4_ok, serves_fp8 and lowp_on refuse K = 0 (and N = 0): the pipelined loops never advance with zero K steps. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The cp.async power-of-two path read bt[pos >> sh] for each row pair before checking pos < kv_l (only the use was guarded). With 16-row pages, the non-TMA entry and a last tile with kv_len % 32 in (0, 16] (e.g. kv_len 48, kv_s 32, j 2) it read one entry past the block table. Past kv_l both rows of the pair are zero-filled, so the page is now read only when pos < kv_l, as the base LOAD_KV_TILE does. Results unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- dl_pow2_scale clamps its exponent at -126. For a row with amax below about 2^-117 the power-of-two scale went subnormal and 1 / scale was Inf in this module's non-FTZ build, so the codes were 0 x Inf = NaN. A row whose amax / lim is a normal float never reaches the clamp, so every real row quantizes to the same codes and scales as before. - The OUTMX epilogue's E4M3 code tile (after the BF16 tile, 51,200 B at 128 rows) is not counted by db_smem_bytes and fits only because the W4A8 stages are larger (69,632 B): now a static_assert. - Header: the W4A8, MX8-handoff and persistent-twin kernels are listed; the dynamic shared-memory note names db_smem_bytes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
data-angel
added a commit
to Enntity/sparkscore
that referenced
this pull request
Nov 7, 2026
A fresh clone at 8597e49 built the image at the pinned Atlas head (b594151da), converted d3-ultra from scratch to byte-identical weights in 15 minutes, and reproduced the published numbers: JevBench 210/231 on three runs (p50 144-145 ms), BF16 oracle 47/49 at KL 0.0148, merged equal to solo on 60 results across pass shapes, and engine time within 1% of the earlier head in an interleaved A/B. The engine is proposed upstream as Atlas-Inf/atlas#331. Co-Authored-By: Claude Opus 5.5 <[email protected]>
data-angel
added a commit
to Enntity/sparkscore
that referenced
this pull request
Nov 7, 2026
d3-ultra 27B NVFP4 served by Atlas's one-pass score path: JevBench public 90.9% at p50 146 ms per question, 4.3x faster than d3's own runtime on the same Spark. One-command install (start.sh), pinned engine (install/atlas-source.json, proposed upstream as Atlas-Inf/atlas#331), reproducible weights, receipts for every number, and a live demo. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
AzeezIsh
pushed a commit
that referenced
this pull request
Nov 10, 2026
…27B series Co-Authored-By: Claude Opus 5.5 <[email protected]>
AzeezIsh
added a commit
that referenced
this pull request
Nov 10, 2026
AzeezIsh
added a commit
that referenced
this pull request
Nov 10, 2026
pdl.rs: keep both new PDL targets (ricursive-ripple-65b, qwen3.8-27b). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 10, 2026
Contributor
|
Merged after testing it as part of #333's stack on one GB10. #333's profile runs this PR's dense prefill kernels ( The red CI jobs here were all inherited from main:
I haven't exercised |
Merged
1 task
AzeezIsh
added a commit
that referenced
this pull request
Nov 13, 2026
…solo, logprob reference, prefix_bidir, chat C4 Co-Authored-By: Claude Opus 5.5 <[email protected]>
AzeezIsh
added a commit
that referenced
this pull request
Nov 13, 2026
This was referenced Nov 19, 2026
AzeezIsh
added a commit
that referenced
this pull request
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This adds a prefill-only score path (
POST /v1/score) and the dense 27Bprefill kernels that make it fast on GB10. A score request is a state plus
up to 256 short branches. Atlas runs them as one forward pass:
"attention": "prefix_bidir"mask is applied;It returns a softmax per branch. Nothing is sampled or decoded. Concurrent
requests merge into shared passes, and oversized ones are split.
The driving use is typed decision models such as
vllm-sr/d3-ultra(aQwen3.8-27B fine-tune trained with prefix-bidirectional attention). On one
GB10 that model now scores JevBench's 231 public items:
Product and receipts: https://github.com/Enntity/sparkscore (
results/; that repository becomes public with the SparkScore release).Every new speed lever is opt-in and default-off. With the levers off,
existing paths are unchanged except for the three small items listed under
"Default paths".
What's in it
Score path
/v1/score(spark-server/src/api/score.rs,scheduler/score.rs):{prefix, branches, options, attention?};{probs, engine_us, batched}.--request-timeout(504);because they share the prefill arena, the KV pool and the SSM slots.
Each quiescent tick runs one merged pass, and jobs whose client has gone
are dropped. Under sustained chat traffic, score jobs wait; the module
doc says so.
get 501.
spark-model/.../prefill_b/score*.rs):place;
branch.
prefix_bidiris refused unless every attention layer honoursstate_end(TransformerLayer::honours_state_end).cache lives on the model and is bounded at 1024 rows.
Kernels and levers (
kernels/gb10/qwen3.6-27b/nvfp4/,crates/spark-model/src/layers/ops/dense_bf16mma*.rs)Levers
Under
ATLAS_DENSE_PREFILL_BF16MMA=1(the dense projections and MLP on BF16 tensor cores),ATLAS_DENSE_PREFILL_LOWPtakes a comma list of groups. Unknown names, conflicts (gu,gu8: W4A8 wins) and ineffective settings are logged once:gu,dn,qkv,ogu8,dn8,qkv8,o8qkvz,goutdnmxgu8Two shorthands:
1=gu8,dn8,qkv8,o8,qkvz,gout, andall=gu,dn,qkv,o,qkvz,gout.ATLAS_QWEN38_PDL=1turns on programmatic dependent launch for theqwen3.8-27b target: the dense GEMMs, the token quantizers, the BA kernels and
a few elementwise kernels. Every listed kernel calls
atlas_pdl_enter()first.It doesn't change the results.
Token quantizers (
dl_quant_fp8,dl_quant_nvfp4)Each token row gets one CTA and a power-of-two scale, applied once in the FP32
epilogue.
nvfp4_block_quant.cuh),with an E4M3 block scale per 16 values.
W4A8 (
gu8,dn8,qkv8,o8)Each 64-K stage of the NVFP4 weights is re-encoded per feature as E4M3 of
w·s/2^E, where 2^E is a UE8M0 row scale applied by
kind::mxf8f6f4m16n8k32. Values with at most 4 significant bits are exact; the rest round
once to E4M3.
dense_w4a8_*(8-warp)dnmxdense_w4a8ws_*(warp-specialized, persistent)The warp-specialized kernel:
setmaxnreggives theMMA warps 192 registers.
operands in lane order.
bit-identical to the 8-warp kernel.
over the raster tiles, with outputs stored straight from registers.
dnmx(dense_w4a8_gate_up_silu_mx,dense_w4a8mx_nvfp4) changes thehandoff to the down projection:
UE8M0 scale per token and 32-K group, so no quantizer pass runs in between.
A group is not 32 contiguous K: it is the strided set k = 64s + 16c + 8h + i
(i < 8) of a 64-K stage, matching the MMA's operand layout. Producer and
consumer agree on it; it is not the OCP-MX contiguous layout.
opt-in.
W4A4 (
gu,dn,qkv,o)dense_w4a4_*(8-warp)kind::mxf4nvf4m16n8k64; the MMA applies both block scalesdense_w4a4wsl_*(persistent, loader warps, 4 stages)dense_w4a4ws_*(persistent, loader warps, 6 stages)In both persistent kernels:
token scales.
issue its MMAs in its order, so the results are bit-identical to the 8-warp
kernel.
ahead.
W8A8 (
qkvz,gout)dense_w8a8_fp8tmultiplies on the transposed[K, N]FP8 copy and appliesthe per-tensor grid in the epilogue. Its weight copies carry an L2
evict-first hint, which doesn't change the results. Without a transposed
copy,
dense_w8a8_fp8reads the original layout (no cache hint).Dispatch
chunks()picks the row-chunk count from a per-kernel fixedcost (CTA_FIXED, or WS_FIXED for the re-encoding kernels).
results never depend on the chunking or the grid.
Other opt-in levers
ATLAS_GDN_CHUNK_TC=1: fused chunked GDN prefill on BF16 tensor cores,with L2-normalized Q/K inside the scan.
ATLAS_ATTN_ROWS128=1: batched paged prefill attention on 128-row tiles,loading K and V by TMA with the 128-byte swizzle.
ATLAS_MOE_PREFILL_BF16MMA=1: NVFP4 MoE prefill on BF16 tensor cores(qwen3.6-35b-a3b). Its accuracy has not been qualified against a
reference. It is opt-in only; treat it as experimental.
Default paths (levers off)
/v1/completionstoken-id validation now usesmax(base vocab, max added id + 1)instead of the tokenizer's entry count.That is more accurate in most cases, but it changes what is accepted.
identical, but the host launch and the kernel must ship together.
gate_beta. Thebytes are the same and one copy is gone.
Determinism
bit-identical twins: the 8-warp kernel, the warp-specialized kernels and
the persistent kernels. One CTA computes each output in a fixed K order.
under 32 rows uses the same kernels as when merged. Chat keeps the floor.
Measured: the merged and solo results agree exactly across that switch
(see the test plan). BR32 vs BR64 identity was not proven from the code.
nvfp4_proj_m128switch above 128 rowsis unchanged. So merged and solo passes can differ there; that is
upstream behaviour.
Test plan
Without a GPU. All of these ran with the pinned 1.93.1 toolchain on
aarch64, from a
git archiveof the head:cargo fmt --all -- --checkATLAS_SKIP_BUILD=1 cargo clippy --workspace --tests --all-features -- -Dwarningsbash scripts/check-license-headers.shcargo test --workspace: everything passes except 4 tests that failfor reasons outside this branch.
.gitcheckout:bench_selfstartand two intui::bench_variants.hip_kernel_is_the_unmodified_upstream_implementationfails on mainitself. b75da4a (strix-hip DFlash2 selector: exact round top-K (register lists spilled on gfx1151) — 27B DFlash2 +17% #329) changed
dflash2_candidate_selector.cuwithout updating the test's hash, and this branch touches neither file.
On a GB10 (DGX Spark, driver 580.178.04). The model is
vllm-sr/d3-ultraconverted to NVFP4, served with every lever on and W4A4, at this head. These
are the full checks in
https://github.com/Enntity/sparkscore/tree/main/results/2026-11-07-release-replication:
GPU unit tests (
#[ignore]d, GB10 plus a qwen3.8-27b kernel build):dense_bf16mma_matches_exact_dequant_reference;dense_lowp_matches_exact_reference_on_quantized_activations: W4A4,W4A8 and W8A8 at 33, 135, 1,100 and 2,100 rows, plus a persistent
multi-tile run, against FP64;
dense_mx_handoff_matches_reference.All three pass at this head (
cargo test --release -p spark-model --lib -- --ignored, target gb10/qwen3.8-27b/nvfp4).JevBench public (231 items), 3 runs: 210/231 every run, Brier
0.1175, p50 144–145 ms per question. Identical answers to the build before
the review fixes.
Against d3's own BF16 runtime, on its exact prompt tokens (49
questions), with
prefix_bidir: same answer 47/49, mean KL 0.0148. Withcausal attention: 46/49, KL 0.047.
Merged vs solo:
them merged: every one is bit-identical to its solo run.
concurrencyat K = 1..16: max |dp| 0.Endpoint:
Speed: an interleaved A/B against the head before the review fixes
is within 1% at 288, 1,056 and 4,128 rows. Engine time per pass:
About 130 TFLOPS on long passes.
Not run: the
--pull-request-gatesuites. There is no chat-servingchange with the levers off, except the three default-path items above.
Notes for reviewers
crates/**/*.rsfiles over 500 lines are all on the file-size allow-list.New files are at most 479 lines.
stay finite. This module builds without
--ftz.w4a16_gemm_m128_dispatchreadsModelLevers::from_env()and logs onevery call. This predates the branch.
rows by any head-row cache.
--pull-request-gatesuites. The GPU evidence isbelow.
CLA
🤖 Generated with Claude Code