Expand description
Shared kernel dispatch operations.
Freestanding functions wrapping CUDA kernel launches via KernelLaunch.
Layer implementations compose these to build forward passes.
Each function’s parameters exactly match the corresponding CUDA kernel signature. Grid/block dimensions are computed from the problem size.
Refactor wave 4a (2026-05-03): split into ops/ sub-modules with thematic
groupings. All public functions remain available at this path via re-export.
Re-exports§
pub use model_stats::ModelStats;pub use moe_lora_grouped::*;
Modules§
- gdn_
flashinfer - Opt-in FlashInfer GDN prefill via
dlopen(libatlasgdn.so)— behindATLAS_GDN_FLASHINFER=1. - lora_
delta - Runtime LoRA delta: y += scale * (x @ A^T) @ B^T, BF16 side-path. Zero new CUDA kernels — reuses dense_gemv_bf16 / dense_gemm_tc / dense_gemm_bf16 / bf16_scaled_add, all shipped in kernels/gb10/common/.
- model_
stats ModelStats— diagnostic counters and one-shot latches owned by the model.- moe_
lora_ grouped - Device-side MoE expert down_proj LoRA fold launcher (
moe_lora_grouped_down). - token_
overlay - Token-overlay kernel launchers (Feature 2). Thin
KernelLaunchwrappers overkernels/gb10/common/token_overlay.cu:
Structs§
- Dense
MmKernels - The three BF16 dense kernels one projection site can land on, resolved once.
- Derived
Weights - Per-model memo of derived weight encodings.
- Gemm
Dispatch - Which GEMM implementation each projection takes.
- Glm5
Next MhcKernels - Every kernel GLM-5.3’s hyper-connection needs, all from the single module
glm5next_mhc. - Glm5
Next MhcSite Weights - Per-site mHC weights. One set for the attention site, one for the FFN site.
- Model
Levers - Kernel-path levers for one loaded model.
- MoeCutlass
Down Host Tables - Down-projection third of
MoeCutlassHostTables. - MoeCutlass
Host Tables - Host snapshots of the per-expert pointer/scale tables for the CUTLASS
grouped path, owned by the
MoeLayerwhose device tables they mirror.
Enums§
- Derivation
- Which derivation a lookup is for.
- HcVariant
- Which family a site’s weights select.
Constants§
- DENSE_
GEMV_ BATCHM_ DECODE_ MAX_ M - The band the batched GEMV is allowed to CLAIM on the decode paths: the MTP row dispatch and the BF16 lm_head arm.
- DENSE_
GEMV_ BATCHM_ MAX_ M - Dense BF16 batched GEMV (M rows):
C[t] = A[t] @ B^Tfortin[0, M). - GLM5NEXT_
MHC_ MODULE - The one module name GLM’s mHC resolves from.
- MAX_
DYNAMIC_ SMEM - Largest dynamic shared-memory block a kernel may opt into on the GB10 target.
Measured on the device (sm_121):
CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN = 101376(static default is only 49152; per-SM total is 102400). - MHC_
MIX_ MAX_ TOKENS - Token bound on the
mixscratch. The GLM stack drives mHC one token at a time (the highway forces a serial prefill), so this is slack, not a shape — butglm_hc_preREFUSES above it rather than writing past the allocation. - MOE_
TOPK_ SIGMOID_ MAX_ EXPERTS - Largest
num_expertsthe sigmoid routing kernels can hold, from#define MAX_EXPERTSin the same file. Beyond it the kernel silently considers only the firstMAX_EXPERTSexperts (actual_nis amin), so routing stays memory-safe but stops matching the checkpoint. - MOE_
TOPK_ SIGMOID_ MAX_ TOP_ K - Largest
top_kthe sigmoid routing kernels can hold. - NVFP4_
BLOCK_ BYTES - NVFP4_
MMQ_ SMEM - Dynamic shared memory: ids(512) + x-tile(128MMQ_MMA_TILE_X_K_FP4=764) + y-tile(128*144).
- Q2_
0_ BLOCK_ BYTES - sizeof(block_q2_0) bytes: fp16 scale d (2) + 128 codes @ 4/byte (32) = 34.
- Q2_
BATCHM_ MAX_ M - Shared-memory row cap of
q2_0_gemv_vec_batchm(MAX_Min the .cu). The kernel stages exactlyMactivation rows ins_A[MAX_M * TILE_K]; passingM > MAX_Moverflows that tile (OOB smem write) AND drops output rows >= 8 (compute/write loops iteratem < MAX_M). Callers with more rows MUST chunk — done transparently byq2_0_gemv_vec_batchm. - Q4K_
BLOCK_ BYTES - sizeof(block_q4_K) bytes.
- Q4K_
MMQ_ SMEM - Dynamic shared memory for the Q4_K MMQ kernel (mmq_x=mmq_y=128, GB10). >48KB -> registry sets attr.
- QK2_0
- Q2_0 MMQ block size: 128 weights per
block_q2_0. - QK_K
- Q4_K block size (256 weights -> 144-byte block_q4_K).
- QK_
NVFP4 - NVFP4 block: 64 weights -> 36-byte block_nvfp4 {4×ue4m3 scales, 32B e2m1 nibbles}.
- SSD_L
- SSD chunk length (must match
SSD_Lin the kernel). - SSD_PT
- head_dim rows per SSD scan block (must match
SSD_PTin the kernel). - W4A16_
GEMV_ OUTS_ PER_ BLOCK - Base
w4a16_gemv: 4 outputs / 256-thread block. SSOT withkernels/**/w4a16_gemv.cu#define N_PER_BLOCK 4. - W4A16_
GEMV_ SW_ OUTS_ PER_ BLOCK - Single-warp
w4a16_gemv_sw: 8 outputs / 256-thread block. SSOT with#define N_PER_BLOCK_SW 8.
Functions§
- argmax_
bf16 - GPU-side argmax over BF16 logits.
- argmax_
bf16_ batch - Batched argmax: ONE launch, one block per row, instead of n serial launches of
the single-row
argmax_bf16(which is a one-CTA reduction and so uses 1 of 48 SMs). Byte-identical — each block runs the identical per-row body. - argmax_
bf16_ batch_ lp - Batched argmax that ALSO writes each row’s top-1 log-probability
(
out_logprob[row] = log softmax(row)[argmax], FP32), computed by online softmax in the same pass — same bandwidth asargmax_bf16_batch, same index semantics. - batched_
embed - Batched embedding: gather N rows from embedding table in one launch.
- batched_
embed_ fp8 - FP8-table variant of
batched_embed: rows are FP8 E4M3 bytes with a per-row f32 dequant scale (thequantize_bf16_to_fp8layout); the kernel dequantizes on read and writes BF16 rows. - bf16_
absmax - Compute max absolute value of a BF16 buffer into a device-side f32.
- bf16_
concat - BF16 concatenation: out[0..N] = a[0..N], out[N..2N] = b[0..N].
- bf16_
to_ fp8 - Convert BF16 activations to FP8 E4M3 for FP8×FP8 GEMM.
- compute_
gdn_ gates - Compute GDN gates from interleaved BA projection + learned A_log/dt_bias.
- conv1d_
fwd - Full-sequence causal depthwise conv1d + SiLU activation.
- conv1d_
update - Causal conv1d update (decode step, supports batched sequences).
- conv1d_
update_ chunk2 - Fused 2-token conv1d sliding window update + SiLU.
- conv1d_
update_ l2norm - Fused conv1d update + SiLU + L2 normalization for Q/K channels.
- conv1d_
update_ l2norm_ strided conv1d_update_l2normwith INDEPENDENT input/output row strides, so N concurrent decode sequences go in ONE launch instead of N.- conv1d_
update_ prefill - Multi-token conv1d sliding window update + SiLU for prefill.
- cublas_
bf16_ proj - Route a projection
out[M,N] = act[M,K] @ weightᵀthrough cuBLASLt BF16. The FP8 weight is dequantized to BF16 once (cached); W16A16 here is strictly more accurate than the blockscaled W8A8 path it replaces. - cublas_
bf16_ proj_ dense - Route a projection
out[M,N] = act[M,K] @ weightᵀthrough cuBLASLt BF16 for a weight that is already native BF16[N,K](no dequant step). Used by models whose attention/shared-expert weights ship unquantized (e.g. Laguna), which can never satisfy theas_fp8()gate ofcublas_bf16_proj. - cublas_
fp8_ proj - Route a projection through native-FP8 cuBLASLt block-scaled matmul: quantize
the activation to FP8 + per-[token,128-of-K] VEC128 scales (the existing
per_token_group_quant_fp8kernel), feed the FP8 weight + its per-128×128 block scales directly (zero dequant, zero extra weight memory). Both operands 128-block-scaled (cuBLASLt requires it). ~1.8× the bf16 path (152 vs 85 TF). - cublas_
fp8_ rowwise_ proj - Route a projection through ROW-WISE native-FP8 cuBLASLt (the fp8 path GB10
supports). Weight is re-quantized once to per-row fp8 (cached); the activation
is quantized per-token each call. ~1.8× the bf16 path (152 vs 85 TF), and
frees the bf16-dequant memory the bf16 path holds.
act_fp8_scratch≥ m*k fp8 bytes;act_scale_scratch≥ m f32 (e.g. thebuffers.fp8_act/fp8_act_scalearena buffers). - cutlass_
bf16_ proj - Route a projection
out[M,N] = act[M,K] @ weightᵀthrough CUTLASS BF16. - cutlass_
nvfp4_ proj - cutlass_
nvfp4_ proj_ from_ fp8 - Native CUTLASS NVFP4 projection for FP8 checkpoint weights. The FP8 weight is dequantized to BF16 using the existing cache, then packed once into Atlas-transposed NVFP4 data/scales and reused for future calls.
- deinterleave_
qg - Deinterleave Q/Gate from per-head interleaved to contiguous layout (in-place).
- deinterleave_
qg_ split - Deinterleave Q/Gate with split output — Q to separate contiguous buffer.
- deinterleave_
qg_ split_ qnorm - Fused deinterleave Q/Gate + per-head Q RMS norm.
- deinterleave_
qg_ split_ qnorm_ mrope - Fused deinterleave Q/Gate + per-head Q RMS norm + MRoPE.
- deinterleave_
qkvz - Deinterleave QKVZ projection output from GQA-grouped to sequential layout.
- dense_
gemm - dense_
gemm_ ba_ gates_ prefill - Fused BA GEMM + GDN gates for prefill (token-parallel).
- dense_
gemm_ bf16_ pipelined - Pipelined tensor-core BF16 GEMM — drop-in faster
dense_gemm(kerneldense_gemm_bf16_pipelined): mma.sync.m16n8k16 + cp.async 2-stage, 128x128 tile. ~40x the scalardense_gemmon large-M shapes (cosine=1.0, same math). Grid: (ceil(N/128), ceil(M/128), 1) Block: (256, 1, 1) - dense_
gemm_ prefill - Dense BF16 prefill GEMM. Prefer the pipelined tensor-core kernel when the selected target ships it, and retain the scalar kernel as an explicit compatibility fallback for older targets.
- dense_
gemm_ router - Order-preserving register-blocked BF16 GEMM (kernel
dense_gemm_bf16_router). - dense_
gemm_ splitk - Split-K GEMM: partial products over K_splits chunks, then reduce. Uses FP32 workspace of size K_splits * M * N * 4 bytes.
- dense_
gemm_ tc - Dense BF16 GEMM: C = A @ B^T.
- dense_
gemm_ tc_ scaled_ acc output[m, n] += scale * bf16(input[m, k] @ weight[n, k]^T)in ONE pass.- dense_
gemv - Dense BF16 GEMV (M=1): C = A @ B^T for single-row activations.
- dense_
gemv_ ba_ gates - Fused BA projection + GDN gates: dense GEMV + gate/beta transforms.
- dense_
gemv_ batch2 - Dense BF16 GEMV, batched over 2 rows (M=2): one pass over the weight
produces both output rows, halving weight bandwidth vs two
dense_gemvlaunches. Bit-identical to two M=1dense_gemvcalls — each row’s accumulator follows the same K-iteration/reduction order. - dense_
gemv_ batchm - dense_
gemv_ fp8w - Dense FP8-weight GEMV (M=1): C = A @ (dequant(B_fp8) * row_scale).
- dense_
gemv_ fp8w_ batch2 - FP8-weight dual-GEMV.
inputis[2, K]BF16,outputis[2, N]BF16. Grid: (ceil(N/4), 1, 1) Block: (256, 1, 1) - dense_
mm_ bf16 C[M, N] = A[M, K] @ B[N, K]^T, BF16 in and out, output row strideN.- dequant_
nvfp4_ to_ bf16 - Dequantize NVFP4 weight [n, k] (packed E2M1 + E4M3 group scales + per-tensor scale2) -> bf16 [n, k].
- dequant_
q2_ 0_ gn_ to_ bf16 - Dequant a packed Q2_0 weight
[N, K](contiguousblock_q2_0blocks) into a pre-allocated BF16 scratch buffer[N, K]onstream, IN PLACE (no alloc, no host sync). Reuses the load-timedequant_q2_0_gn_to_bf16kernel (dequant_gguf_bf16module). Used by packed-Q2 PREFILL: dequant → transient BF16 → normal BF16 GEMM → free scratch (the resident weight stays 2-bit). - embed_
from_ argmax - GPU-side argmax + embedding lookup — eliminates D2H sync in MTP propose.
- fill_
slots_ from_ block_ table - Fill paged-KV slot mappings on-device from a persistent block table.
- fp4_
act_ scratch_ bytes - block_fp4_mmq activation scratch bytes for [m, k]. +1MB slack: the kernel’s smem copy loop rounds the last y-slice read up to warp granularity (same convention as q8_1_scratch_bytes). Always ≤ q8_1_scratch_bytes(m, k) → fits the shared ffn_act_q8.
- fp8_
fp8_ gemm_ m128_ mfast fp8_fp8_gemm_t_m128_mfast: FP8 A x FP8 B, 128-row M tile, m on the fast axis. A must already be E4M3 (seebf16_to_fp8); the MMA consumed E4M3 either way, so pre-casting A is numerically identical to the BF16-A kernel.- fp8_
fp8_ gemm_ n128 - FP8×FP8 GEMM: A [M, K] FP8 × B [N, K] FP8 → C [M, N] BF16.
- fp8_
fp8_ gemm_ n128_ m128 - M128 variant of fp8_fp8_gemm_n128: halves B re-reads for large M (ISL > 128).
- fp8_
gemm_ m128_ mfast fp8_gemm_t_m128_mfast: 128-row M tile (2 chunks/CTA), m on the fast axis. Halves the B panel passes relative tofp8_gemm_n128_mfast.- fp8_
gemm_ n128 - Pre-dequanted FP8 GEMM (prefill): C = A @ B_fp8.
- fp8_
gemm_ n128_ m128 - M128 variant of fp8_gemm_n128: halves B re-reads for large M (ISL > 128).
- fp8_
gemm_ n128_ mfast - Pre-dequant NVFP4 → FP8 E4M3. One-time conversion at model load.
- fp8_
gemm_ n128_ row_ scaled - Row-scaled FP8 GEMM:
C[M, N] = A[M, K] @ (dequant(B_fp8[N, K]) * row_scale[N]). - fp8_
gemm_ n128_ row_ scaled_ m16 - Small-M row-scaled FP8 GEMM (M ≤ 16) — single warp per CTA variant.
- fp8_
gemm_ t_ blockscaled - W8A8 + FP32 epilogue GEMM with per-token activation scales and per-block weight scales — vLLM-equivalent FP8 numerics.
- fp8_
gemv_ rowscale_ batch8_ rt2 - Register-tiled batched row-scaled FP8 GEMV (M<=8, T=2 outputs/thread) —
the FP8 twin of
w4a16_gemv_batch8_rt2, for the DFlash drafter PROPOSE path.input[M, K]BF16,output[M, N]BF16; per-row f32 scale applied at write-out inside the kernel. Replaces the prefill-class tile GEMMs (fp8_gemm_t_row_scaledM64-tile /_m16) that pad 87%/50% of their M-tile at M=8 (~100 GB/s measured vs 180+ for the rt family). Drafter-side numerics: correctness-free under strict-argmax accept. Kernel:fp8_gemv_rowscale_batch8_rt2(modulefp8_gemv_rt). Grid: (ceil(N/8), 1, 1) Block: (256, 1, 1). Requires K % 16 == 0. - fp8_
gemv_ rowscale_ batch16_ rt2 - MAX_M=16 sibling of
fp8_gemv_rowscale_batch8_rt2for the γ>8 DFlash propose window (flags 9..17). Same template, same launch geometry; added 2026-08-29 after STEP_TIMING measured propose 18.2ms (flag 8, rt2) vs 38.0ms (flag 9, tile fallback) — the whole γ>8 step tax. Kernel:fp8_gemv_rowscale_batch16_rt2(modulefp8_gemv_rt). - fused_
k_ norm_ rope_ cache_ write_ bf16 - Fused K-path: rms_norm → RoPE → BF16 paged cache write in one kernel.
- fused_
k_ norm_ rope_ cache_ write_ bf16_ mrope - MRoPE-interleaved variant — selects abs position from pos_t/pos_h/pos_w
based on
pair_idx % 3. For text-only inputs (pos_h == pos_w == pos_t) the result is bit-identical to the scalar-position variant. - fused_
k_ norm_ rope_ cache_ write_ fp8 - FP8-output sibling of
fused_k_norm_rope_cache_write_bf16. Same semantics; one fewer BF16 round before the saturating FP8 cast. - gated_
rms_ norm - Gated RMS norm (norm_before_gate=False, per-group): output = rms_norm_per_group(input * silu(gate), weight, group_size)
- gated_
rms_ norm_ prefill - Batched gated RMS norm for prefill: all (head, actual_token) pairs in one launch.
- gdn_
decode - Gated delta rule decode (recurrent SSM update, supports batched sequences).
- gdn_
decode_ chunk2 - Fused 2-token GDN decode (speculative verification).
- gdn_
decode_ chunk3 - Fused 3-token GDN decode (K=3 speculative verification).
- gdn_
decode_ f16_ strided_ norm - FP16 h-state twin of
gdn_decode_f32_strided_norm(ATLAS_SSM_H_FP16). - gdn_
decode_ f32_ conv_ norm - Split-v_dim prefill: 2 CTAs per v-head, 64 threads each. FUSED conv1d_update_l2norm + recurrence + gated-RMS-norm decode.
- gdn_
decode_ f32_ norm - FP32 GDN decode fused with gated RMS norm.
- gdn_
decode_ f32_ norm_ snap super::gdn_decode_f32_norm+ inline h-state snapshot.- gdn_
decode_ f32_ strided - Strided FP32 GDN decode for concurrent sequence decode.
- gdn_
decode_ f32_ strided_ norm - Strided FP32 GDN decode fused with gated RMS norm.
- gdn_
decode_ f32_ strided_ norm_ snap super::gdn_decode_f32_strided_norm+ inline h-state snapshot, for the batched-verify arm atbatch_size = nsequences.- gdn_
decode_ wy2 - WY-chunkwise 2-token GDN decode (2-pass algorithm).
- gdn_
decode_ wy3 - WY-chunkwise 3-token GDN decode (2-pass algorithm).
- gdn_
decode_ wy4 - WY-chunkwise 4-token GDN decode (2-pass algorithm).
- gdn_
decode_ wyn - WY-Chunkwise Gated Delta Rule, pool-layout intermediates — K-generic
launch shared by the K=17 DFlash verify (
gated_delta_rule_wy17) and the chain-verify K∈{5..8} instantiations (gated_delta_rule_wy5..wy8, one templated sourcegated_delta_rule_wyn.cu). K is compile-time in the kernel; the caller selects it via thekernelhandle. Computes K H·k dot products in 1 pass over H, applies WY algebraic correction over K tokens (K*(K-1)/2 inter-token k-dots), then applies K state updates in a second fused pass writing Hi_0..Hi_{K-2} + final H. - gdn_
prefill - Gated delta rule prefill (multi-token, sequential SSM update within kernel).
- gdn_
prefill_ fla - FLA multi-kernel chunked GDN prefill (
ATLAS_GDN_FLA=1). - gdn_
prefill_ persistent - Persistent GDN prefill — h_state stays in shared memory for entire sequence.
- gdn_
prefill_ persistent_ batched - Batched persistent GDN prefill (uses gated_delta_rule_prefill_persistent_batched or gated_delta_rule_prefill_persistent_wy4_batched).
- gdn_
prefill_ persistent_ smem - Persistent GDN prefill with explicit shared memory size. Used for WY4-persistent variant which needs more shared memory.
- gdn_
prefill_ persistent_ smem_ batched - Batched WY32 persistent GDN prefill (uses gated_delta_rule_prefill_wy64_batched).
- gdn_
prefill_ regresident - Register-resident token-sequential prefill recurrence (warm-replay path).
- gdn_
prefill_ split - Split-v_dim prefill: 2 CTAs per v-head, 64 threads each.
- gdn_
prefill_ split4 - 4-way split prefill: 4 CTAs per v-head, 32 threads each (128 total CTAs).
- gdn_
prefill_ split4_ batched - Batched split4 GDN prefill (uses gated_delta_rule_prefill_split4_batched).
- gdn_
verify_ fused_ conv_ k2 - STAGE 1 fused K=2 MTP-verify conv1d+L2norm: both draft positions in one
launch, with the position-0 conv-state snapshot written inline (replaces
the per-token
conv1d_update_l2norm×2 + interveningcopy_d2d). - gdn_
verify_ fused_ conv_ kn - gdn_
verify_ fused_ conv_ kn_ batched - Fused generic-K DFlash-verify conv1d+L2norm: ALL K draft positions in one
launch, with every per-token conv-state rollback snapshot written inline
to a strided intermediates array (replaces the per-token
conv1d_update_l2norm×K +copy_d2d×K sequence — 34 serialized ops at K=17).conv_stateis left holding the committed (post final-position) window, which the kernel also duplicates as snapshot K-1, so the caller issues NO copies. - gdn_
verify_ fused_ conv_ kn_ f32 - FP32-output twin of
super::gdn_verify_fused_conv_kn: one launch for all K verify positions of conv1d+SiLU+L2norm, FP32 conv rows (what the sequential-decode-exact GDN chain reads), every per-token conv-state rollback snapshot written inline.output_strideis in FP32 elements. - gdn_
verify_ fused_ norm_ k2 - STAGE 1 fused K=2 MTP-verify gated-RMS-norm: both draft positions in one
launch (replaces the per-token
gated_rms_norm×2). The Z gate is read from the deinterleaved [Q|K|V|Z] buffer atz_offsetper position. - gemv_
sw_ from - Kill-switch polarity for lossless SW GEMV. ON unless
ATLAS_NO_GEMV_SWis exactly"1".=0does not disable (same== "1"reading asATLAS_NO_LM_HEAD_BATCH_GEMV). - glm_
hc_ expand - Expand one BF16 hidden state into the
hc_multFP32 highway streams. First layer only. - glm_
hc_ post glm_hc_post:out[j] = post[j] * block_out + Σ_i comb[i][j] * residual[i].- glm_
hc_ pre hc_pre: collapse thehc_multFP32 streams to one BF16 sequence and emit this site’spost/combmixing coefficients.- grouped_
gemm_ mla - Grouped GEMM for MLA: G independent
[M,K_g]@[N_g,K_g]^T→[M,N_g]in one launch. Grid: (M*G, ceil(N_g/4), 1) Block: (256, 1, 1) - hc_
expand - Broadcast a single hidden state into
hc_multidentical streams:streams[t, i, d] = hidden[t, d]. One block per token. - hc_head
- Final collapse before the LM head: a single learned sigmoid-weighted sum
over the
hc_multstreams. One block per token. - hc_
head_ lowrank - The model-level mixer (
use_combine=False): the same collapse with no injection vector. - hc_
head_ mean - Final collapse before the LM head: an unweighted mean over the
hc_multstreams. - hc_
head_ site - The model-level final collapse before the LM head.
- hc_post
- Expand the sublayer output back into
hc_multstreams, mixing the saved residual streams through the doubly-stochasticcomb.outmay aliasresidual. One block per token. - hc_
post_ lowrank - Inject the block output back into every stream:
out[t, s*H + d] = residual[t, s*H + d] + block_out[t, d] * inj[t, s]. - hc_
post_ site - Inject the block output back into every stream.
outmay aliasresidual. - hc_pre
- Collapse
hc_multstreams to one (RMS-rescaled mix → sigmoidpreweighted sum) and emitpost/comb(Sinkhorn) for the matchinghc_post. One block per token. - hc_
pre_ lowrank - Collapse the
hc_multstreams to one, and emit the per-stream injection weights the matchinghc_post_lowrankneeds. - hc_
pre_ site - Collapse the streams to one and emit whatever the matching
hc_postneeds —post+combfor Sinkhorn, the injection vector inpost_outfor low-rank. - int8_
gemm_ faith2_ prefill - int8 W4A8 prefill GEMM: requant BF16 activations to int8 (per-32 F32 scale)
then
C = (A_i8 * W_i8)folded with per-32 A/W block scales viaint8_gemm_faith2. The weight is already int8 (seerequant_w_nvfp4_int8). - l2_norm
- L2 normalization (in-place):
data[i] = data[i] / sqrt(sum(data^2) + eps). - log_
cutlass_ nvfp4_ route - log_
gemm_ shape - Roofline instrumentation: log each unique (kernel, M, N, K) GEMM shape once,
gated by
ATLAS_GEMM_SHAPE_LOG=1. Used to cross-reference nsys per-call durations → achieved TFLOPS/bandwidth vs GB10 peak. - mamba2_
ssd_ bmm - K2:
CB[c][g][t][s] = C_t . B_s(raw, fp32). - mamba2_
ssd_ cumsum - K1: per-chunk dt (softplus+clamp) and inclusive cumsum of the log-decay.
- mamba2_
ssd_ scan - K3: fused chunk_state + state_passing + chunk_scan (h0 stays in shared memory,
so the per-chunk
statestensor vLLM round-trips through DRAM never exists). - mamba2_
ssm_ prefill - Mamba-2 SSM prefill: sequential recurrence across
seq_lentokens in a single kernel. - mamba2_
ssm_ prefill_ persistent - Persistent Mamba-2 SSM prefill: H in shared memory, reduces global traffic. Same parameters and launch config as mamba2_ssm_prefill.
- mix_hc
mix_hc— the row count ofhc_fnandhc_base:(2 + hc_mult) * hc_mult.- mla_
batched_ gemv - Paged decode attention (FP8 KV cache, single/multi sequence).
- mla_
cache_ assemble - MLA cache assembly: fuse [kv_latent|k_rope]→K and [kv_latent|zeros]→V into 1 kernel.
- mla_
cache_ assemble_ batched - Batched MLA cache assembly for N tokens: K=[latent|rope], V=[latent|zeros]. 1 kernel replaces N*4 D2D copies+memsets per layer.
- mla_
fused_ prefill - Fused MLA prefill: Q_absorption + attention + V_extraction in one kernel. Grid: (num_heads, seq_len, 1) Block: (256, 1, 1)
- mla_
kv_ assemble_ batched - Batched K/V assembly from kv_expanded + k_rope for N tokens. 1 kernel replaces Nnkv3 D2D copies per layer.
- mla_
paged_ decode_ fp8 - MLA Paged Decode — FP8 variant for DeepSeek-V4-Flash with FP8 KV cache.
- mla_
paged_ decode_ nvfp4 - MLA Paged Decode — NVFP4 variant for DeepSeek-V4-Flash.
- mla_
prefill_ attention_ 320 - MLA absorbed prefill attention (HDIM=320, simple scalar kernel). Grid: (num_q_heads, ceil(seq_len/16), batch) Block: (256, 1, 1)
- mla_
q_ final_ assemble_ batched - Assemble Q_final from Q_absorbed + Q_rope: [absorbed|rope] per head per token.
- mla_
q_ rope_ extract_ batched - Batched Q rope extract: [N, nq, hd] → [N, nq, rope] at offset nope per head. 1 kernel replaces N*nq D2D copies per layer.
- mla_
q_ rope_ scatter - MLA Q_rope scatter: copy rope portion from q_full to strided q_absorbed_buf. 1 kernel replaces 32 D2D copies.
- mla_
q_ rope_ writeback - MLA Q_rope writeback: scatter RoPE’d rope portions to strided layout. 1 kernel replaces 32 D2D copies.
- mla_
q_ rope_ writeback_ batched - Batched Q rope writeback: [N, nq, rope] → [N, nq, hd] at offset nope per head.
- moe_
batched_ blend - Batched sigmoid blend: output += sigmoid(dot(normed, gate_weight)) * shared_out.
- moe_
bf16_ grouped_ gemm - BF16 grouped GEMM for sorted MoE prefill (FP8-dequant-on-load path).
- moe_
build_ tile_ worklist - Build the compacted (expert, m_tile, n_tile) work-list for the
persistent grouped-GEMM grid. Single-block, thread-0 serial — mirrors the
moe_sort_by_expertlaunch style (grid[1,1,1], block[256,1,1]). - moe_
decode_ atomic_ c4_ finalize - moe_
decode_ atomic_ c4_ silu_ down_ accum - moe_
expert_ gate_ up_ shared - Fused gate+up expert GEMV with shared expert as extra blockIdx.y slot.
- moe_
expert_ gate_ up_ shared_ batch2 - Fused gate+up expert GEMV for K=2 tokens with shared expert.
- moe_
expert_ gate_ up_ shared_ batch3 - Fused gate+up expert GEMV for K=3 tokens with shared expert.
- moe_
expert_ gate_ up_ shared_ batch2_ t - NVFP4 fused gate+up GEMV (transposed). K=2 batch.
- moe_
expert_ gate_ up_ shared_ batch3_ t - NVFP4 fused gate+up GEMV (transposed). K=3 batch.
- moe_
expert_ gate_ up_ shared_ bf16 - Fused gate+up expert GEMV with shared expert for BF16 weights.
- moe_
expert_ gate_ up_ shared_ bf16_ batch2 - Fused gate+up expert GEMV with shared expert for BF16 weights — K=2 batch.
- moe_
expert_ gate_ up_ shared_ fp8 - Fused gate+up expert GEMV with shared expert for FP8 weights.
- moe_
expert_ gate_ up_ shared_ fp8_ batch2 - FP8 fused gate+up GEMV for batch=2 (MTP K=2 verify). Grid: (ceil(N/8), 2*(top_k+1), 2) Block: (128, 1, 1)
- moe_
expert_ gate_ up_ shared_ fp8_ batch3 - FP8 fused gate+up GEMV for batch=3 (MTP K=3 verify). Grid: (ceil(N/8), 3*(top_k+1), 2) Block: (128, 1, 1)
- moe_
expert_ gate_ up_ shared_ fp8_ batch2_ t - FP8 fused gate+up GEMV (transposed). K=2 batch.
- moe_
expert_ gate_ up_ shared_ fp8_ batch3_ t - FP8 fused gate+up GEMV (transposed). K=3 batch.
- moe_
expert_ gate_ up_ shared_ fp8_ t - FP8 fused gate+up GEMV (transposed weight). Single-token decode.
- moe_
expert_ gate_ up_ shared_ prefill - Fused gate+up expert GEMV for N-token prefill with shared expert.
- moe_
expert_ gate_ up_ shared_ t - NVFP4 fused gate+up GEMV (transposed weight). Single-token decode.
- moe_
expert_ gemv - Batched MoE expert W4A16 GEMV: runs top_k expert GEMVs in one launch.
- moe_
expert_ gemv_ gate_ up - Fused gate+up expert GEMV: both projections in one kernel launch.
- moe_
expert_ gemv_ gate_ up_ 2x - Register-tiled fused gate+up expert GEMV: 2 output rows per thread.
- moe_
expert_ gemv_ silu_ down - Fused SiLU+down expert GEMV: computes silu(gate)*up inline as activation.
- moe_
expert_ gemv_ silu_ down_ 2x - Register-tiled fused SiLU+down expert GEMV: 2 output rows per thread.
- moe_
expert_ silu_ down_ shared - Fused SiLU+down expert GEMV with shared expert as extra blockIdx.y slot.
- moe_
expert_ silu_ down_ shared_ batch2 - Fused SiLU+down expert GEMV for K=2 tokens with shared expert.
- moe_
expert_ silu_ down_ shared_ batch3 - Fused SiLU+down expert GEMV for K=3 tokens with shared expert.
- moe_
expert_ silu_ down_ shared_ batch2_ t - NVFP4 fused SiLU+down GEMV (transposed). K=2 batch.
- moe_
expert_ silu_ down_ shared_ batch3_ t - NVFP4 fused SiLU+down GEMV (transposed). K=3 batch.
- moe_
expert_ silu_ down_ shared_ bf16 - Fused SiLU+down expert GEMV with shared expert for BF16 weights.
- moe_
expert_ silu_ down_ shared_ bf16_ batch2 - Fused SiLU+down expert GEMV with shared expert for BF16 weights — K=2 batch.
- moe_
expert_ silu_ down_ shared_ fp8 - Fused SiLU+down expert GEMV with shared expert for FP8 weights.
- moe_
expert_ silu_ down_ shared_ fp8_ batch2 - FP8 fused SiLU+down GEMV for batch=2. Grid: (ceil(N/8), 2*(top_k+1), 1) Block: (128, 1, 1)
- moe_
expert_ silu_ down_ shared_ fp8_ batch3 - FP8 fused SiLU+down GEMV for batch=3. Grid: (ceil(N/8), 3*(top_k+1), 1) Block: (128, 1, 1)
- moe_
expert_ silu_ down_ shared_ fp8_ batch2_ t - FP8 fused SiLU+down GEMV (transposed). K=2 batch.
- moe_
expert_ silu_ down_ shared_ fp8_ batch3_ t - FP8 fused SiLU+down GEMV (transposed). K=3 batch.
- moe_
expert_ silu_ down_ shared_ fp8_ t - FP8 fused SiLU+down GEMV (transposed weight). Single-token decode.
- moe_
expert_ silu_ down_ shared_ prefill - Fused SiLU+down expert GEMV for N-token prefill with shared expert.
- moe_
expert_ silu_ down_ shared_ t - NVFP4 fused SiLU+down GEMV (transposed weight). Single-token decode.
- moe_
fp8_ grouped_ gemm - FP8 grouped GEMM for sorted MoE prefill — grid-compaction over the COMPACTED
work-list built by
moe_build_tile_worklist. THE routed-expert FP8 prefill kernel. - moe_
fp8_ grouped_ gemm_ ptrtable_ n128 - FP8-A pointer-table grouped GEMM with transposed NVFP4 weights.
- moe_
gate_ topk_ fused - Fused gate GEMV + topK softmax for M=1 decode.
- moe_
grouped_ down_ cutlass - Single-launch CUTLASS grouped NVFP4 DOWN projection.
ais the post-SiLU intermediate[total_expanded, inter](already expert-contiguous — no gather).hostis the down third of the load-time snapshot;expert_offsetsis the device i32[num_experts+1]prefix sum. - moe_
grouped_ gate_ up_ cutlass - Single-launch CUTLASS grouped NVFP4 fused gate_up GEMM (Phase-2).
- moe_
hash_ route - GPU-side MoE hash routing (DeepSeek-V4 hash_moe layers).
- moe_
hash_ route_ batched - Batched GPU-side MoE hash routing (DeepSeek-V4 hash_moe layers, prefill).
- moe_
permute_ tokens - Gather token rows into expert-sorted order:
permuted[i] = hidden[sorted_token_ids[i]].permutedis[total_expanded, hidden]. One block per output row, threads stride overhidden. Used by the FP4 grouped gate_up path (the CUTLASS escape-hatch needs contiguous per-expert rows; the FP8 fused kernel gathers internally so it doesn’t need this). - moe_
silu_ mul - Element-wise SiLU activation + multiply:
output[i] = silu(gate[i]) * up[i]. - moe_
sort_ by_ expert - moe_
topk_ sigmoid - moe_
topk_ sigmoid_ batched - Batched sigmoid + correction-bias top-K MoE routing.
- moe_
topk_ softmax - GPU-side MoE top-K softmax.
- moe_
topk_ softmax_ batched - Batched top-K softmax: N tokens in parallel.
- moe_
topk_ softmax_ bias - GPU-side MoE top-K sigmoid routing (Nemotron-H).
- moe_
topk_ softmax_ bias_ batched - Batched twin: one block per token.
- moe_
topk_ sqrtsoftplus - GPU-side MoE top-K sqrtsoftplus routing (DeepSeek-V4).
- moe_
topk_ sqrtsoftplus_ batched - Batched sqrtsoftplus + correction-bias routing (DeepSeek-V4 prefill).
- moe_
transpose_ u8_ batched - moe_
unpermute_ reduce_ indexed - Unpermute + weighted reduce with pre-built reverse map.
- moe_
w4a4_ grouped_ gemm_ relu2 - Grouped W4A4 expert UP GEMM with fused relu^2 (native FP4 tensor cores). A is the pre-quantized NVFP4 latent (packed E2M1 + per-16 E4M3 scales); B comes from the per-expert NVFP4 pointer tables unchanged. Grid: (ceil(n_out/128), max_m_tiles, num_experts) Block: (128, 1, 1)
- moe_
w4a16_ fused_ gate_ up_ k64_ m128 - K64 fused gate+up GEMM — M=128 variant (Block D #3 — Avarok pattern).
- moe_
w4a16_ fused_ gate_ up_ k64_ n128 - K64 fused gate+up GEMM — zero pipeline stall for K=h (2048 for 35B), 32 K-steps vs 64.
- moe_
w4a16_ fused_ gate_ up_ n128 - Fused gate+up grouped GEMM — single launch for both projections.
- moe_
w4a16_ grouped_ gemm - MoE grouped GEMM: per-expert W4A16 matrix multiply.
- moe_
w4a16_ grouped_ gemm_ ptrtable - Pointer-table grouped GEMM: one launch covers all experts.
- moe_
w4a16_ grouped_ gemm_ ptrtable_ k64_ n128 - K64 down GEMM: K_STEP_T=64 eliminates pipeline stall (compute=128 cycles > load ~100 cycles). Use when K=inter (512 for 35B) — 8 K-steps vs 16 with K32.
- moe_
w4a16_ grouped_ gemm_ ptrtable_ m256 moe_w4a16_grouped_gemm_ptrtablewith M_TILE=256 (512-thread block, 16 warps). Caller must passmax_m_tilescomputed against 256, not 64 — see thediv_ceil(4)at the call site, mirroring the m128 variant’sdiv_ceil(2).- moe_
w4a16_ grouped_ gemm_ ptrtable_ n128 - Pointer-table grouped GEMM with N_TILE=128 (transposed or wide kernels).
- moe_
w8a8_ grouped_ gemm - W8A8 + FP32 epilogue grouped MoE GEMM (vLLM-equivalent).
- moe_
w8a8_ grouped_ gemm_ pm4 - W8A8 + FP32 epilogue grouped MoE GEMM — PM4 geometry over the COMPACTED
work-list built by
moe_build_tile_worklist(kernelmoe_w8a8_grouped_gemm_pm4, same module/numerics asmoe_w8a8_grouped_gemm: bit-identical output, measured). - moe_
weighted_ sum_ blend - Fused SiLU+down expert GEMV, wide variant (16 outputs/block for small K).
- moe_
weighted_ sum_ blend_ batch2 - Fused weighted sum + sigmoid blend for K=2 tokens.
- moe_
weighted_ sum_ blend_ batch3 - Fused weighted sum + sigmoid blend for K=3 tokens.
- moe_
weighted_ sum_ blend_ prefill - Fused weighted sum + sigmoid blend for N-token prefill.
- moe_
zero_ expert_ add out[t, :] += zero_accum[t] * x[t, :]— the identity-expert blend.- native_
q2_ mmq_ enabled - Sub-flag gating the native Q2_0 MMQ prefill path (
ATLAS_GGUF_NATIVE_Q2_MMQ=1). Default off: keep the transient-dequant stopgap so the two can be A/B’d on GPU. (ATLAS_GGUF_NATIVE_Q2still gates keep-packing overall — this only chooses how the kept-packed weight is consumed in PREFILL.) - nvfp4_
mmq_ gemm - NVFP4 W4A4 MMQ GEMM: C[m,n] (bf16, missing ×scale2) = A_fp4[m,k] x W_nvfp4[n,k].
- nvfp4_
mmq_ gemm_ tiled - NVFP4 W4A4 MMQ GEMM with an M-SIZED TILE.
- nvfp4_
mmq_ quantize_ act - Quantize bf16 activations [m, k] -> block_fp4_mmq (e2m1 + ue4m3 group-16, ±2 scale
search) into
out_y. One thread per 16-value group; ne0 padded to 256. - nvfp4_
mmq_ repack - Repack a checkpoint NVFP4 weight (packed E2M1 [n, k/2] low=even/high=odd + E4M3 [n, k/16] scales) into llama block_nvfp4 rows [n][k/64]. Raw bit shuffle — the e2m1 codes and e4m3 scale bytes are reused verbatim (scale2 folded downstream).
- nvfp4_
mmq_ smem - Dynamic shared memory for a given M-tile, from the vendor’s layout: ids_dst[mmq_x] + y-tile[mmq_x * MMQ_TILE_Y_K(=36) ints, padded to 256] + x-tile[128 * MMQ_MMA_TILE_X_K_FP4(=76) ints], all 4-byte. Reproduces the previously-hardcoded 57856 at mmq_x=128, which is the check that this derivation matches the kernel’s actual layout.
- nvfp4_
mmq_ weight_ bytes - Bytes for the block_nvfp4 form of an [n, k] weight (k % 64 == 0).
- nvfp4_
scale_ bf16 - In-place ×scale2 for the down-projection MMQ output ([m, h] bf16).
- nvfp4_
silu_ mul_ quant - Fused SiLU-mul + block_fp4_mmq quantize for the down-MMQ path: reads RAW gate/up MMQ outputs, applies the scale2 folds + swiglu clamp + SiLU-mul, and quantizes straight into the down GEMM’s y-format — the intermediate bf16 activation tensor is never written (this round-trip is why the unfused down arm measured neutral).
- nvfp4_
silu_ mul_ scaled - SiLU(gate×gs)×(up×us) with the per-projection scale2 fold (swiglu ±10 clamp, mirrors moe_silu_mul). In-place safe (out may alias gate).
- paged_
decode_ attn_ bf16 - paged_
decode_ attn_ bf16k_ turbo2v - Paged decode attention for Bf16K + Turbo2V asymmetric KV cache (6.4x V comp).
- paged_
decode_ attn_ bf16k_ turbo3v - Paged decode attention for Bf16K + Turbo3V asymmetric KV cache.
- paged_
decode_ attn_ bf16k_ turbo4v - Paged decode attention for Bf16K + Turbo4V asymmetric KV cache.
- paged_
decode_ attn_ fp8 - paged_
decode_ attn_ fp8k_ turbo2v - Paged decode attention for Fp8K + Turbo2V asymmetric KV cache (6.4x V comp).
- paged_
decode_ attn_ fp8k_ turbo3v - Paged decode attention for Fp8K + Turbo3V asymmetric KV cache.
- paged_
decode_ attn_ fp8k_ turbo4v - Paged decode attention for Fp8K + Turbo4V asymmetric KV cache.
- paged_
decode_ attn_ nvfp4 - Paged decode attention (NVFP4 KV cache, single/multi sequence).
- paged_
decode_ attn_ reduce_ fp8 - Reduce split-K partials into final BF16 output (FP8 variant).
- paged_
decode_ attn_ reduce_ nvfp4 - Reduce split-K partials into final BF16 output.
- paged_
decode_ attn_ splitk_ fp8 - Split-K paged decode attention (FP8 KV cache).
- paged_
decode_ attn_ splitk_ nvfp4 - Split-K paged decode attention (NVFP4 KV cache).
- paged_
decode_ attn_ turbo3k_ turbo8v - Paged decode attention for Turbo3K + Turbo8V asymmetric KV cache.
- paged_
decode_ attn_ turbo4k_ turbo3v - Paged decode attention for Turbo4K + Turbo3V asymmetric KV cache.
- paged_
decode_ attn_ turbo4k_ turbo8v - Paged decode attention for Turbo4K + Turbo8V asymmetric KV cache.
- per_
token_ group_ quant_ fp8 - Per-token-per-128-K-group FP8 activation quantization. Output: A_fp8
[M, K] FP8 E4M3 + a_scale [M, K/128] FP32. Matches vLLM’s
per_token_group_quant_fp8. - ple_
add_ highway highway += ple_out, in FP32. The reference adds PLE’s output to the residual before that layer’s attention hyper-connection.- ple_
conv - Depthwise causal conv, kernel
k_size, dilationdilation, plus the SiLU and the residual add against the un-normalized gated value. - ple_
gate - Gate the n-gram value by the highway, and emit both the gated value and
its
norm_conv’d twin. - predequant_
nvfp4_ to_ fp8 - prefill_
attention - Flash Attention v2 prefill on contiguous Q/K/V.
- prefill_
attention_ 64 - Contiguous prefill Flash Attention — BF16, BR=64 (256 threads).
- prefill_
attention_ 512_ sink - DeepSeek-V4 full-attention (non-CSA) prefill with a per-head attention sink.
- prefill_
attention_ fp8kv - Contiguous prefill Flash Attention — FP8 E4M3 K/V variant (BR=64).
- prefill_
attention_ paged - Paged prefill Flash Attention — reads K/V from paged KV cache via block_table.
- prefill_
attention_ paged_ 64 - Paged prefill Flash Attention — BF16 KV cache, BR=64 (256 threads).
- prefill_
attention_ paged_ 512 - Paged prefill Flash Attention for HDIM=512 (Gemma-4 full-attention) — BF16 KV.
- prefill_
attention_ paged_ batched - Batched BF16-KV paged prefill attention (BR=32).
- prefill_
attention_ paged_ batched_ 64 - Batched BF16-KV paged prefill attention (BR=64, 256-thread variant).
- prefill_
attention_ paged_ bf16k_ turbo2v_ 64 - Prefill paged attention — TurboQuant+ safer-asym Bf16K + Turbo2V (BR=64).
- prefill_
attention_ paged_ bf16k_ turbo3v_ 64 - Paged prefill (BR=64) for Bf16K + Turbo3V asymmetric KV cache.
- prefill_
attention_ paged_ bf16k_ turbo4v_ 64 - Prefill paged attention — TurboQuant+ safer-asym Bf16K + Turbo4V (BR=64).
- prefill_
attention_ paged_ dflash - DFlash γ-block paged Flash Attention — BF16 KV cache variant.
- prefill_
attention_ paged_ dflash_ bf16_ indirect - DFlash γ-block paged Flash Attention — BF16 KV cache, INDIRECT scalar args.
- prefill_
attention_ paged_ fp8 - Paged prefill Flash Attention — FP8 KV cache variant.
- prefill_
attention_ paged_ fp8_ 64 - Paged prefill Flash Attention — FP8 KV cache, BR=64 (256 threads).
- prefill_
attention_ paged_ fp8_ batched - Batched FP8-KV paged prefill attention (BR=32).
- prefill_
attention_ paged_ fp8_ batched_ 64 - Batched FP8-KV paged prefill attention (BR=64, 256-thread variant).
- prefill_
attention_ paged_ fp8_ dflash - DFlash γ-block paged Flash Attention — FP8 KV cache variant.
- prefill_
attention_ paged_ fp8k_ turbo2v_ 64 - Prefill paged attention — TurboQuant+ asym Fp8K + Turbo2V (BR=64, 6.4x V comp).
- prefill_
attention_ paged_ fp8k_ turbo3v_ 64 - Prefill paged attention — TurboQuant+ asym Fp8K + Turbo3V (BR=64).
- prefill_
attention_ paged_ fp8k_ turbo4v_ 64 - Prefill paged attention — TurboQuant+ asym Fp8K + Turbo4V (BR=64).
- prefill_
attention_ paged_ nvfp4 - Paged prefill Flash Attention — NVFP4 KV cache variant.
- prefill_
attention_ paged_ nvfp4_ 64 - prefill_
attention_ paged_ nvfp4_ batched - Batched NVFP4-KV paged prefill attention (BR=32).
- prefill_
attention_ paged_ nvfp4_ batched_ 64 - Batched NVFP4-KV paged prefill attention (BR=64, chunk_len >= 256).
- prefill_
attention_ paged_ turbo2_ 64 - prefill_
attention_ paged_ turbo3k_ turbo8v_ 64 - Prefill paged attention — TurboQuant+ asym Turbo3K + Turbo8V (BR=64).
- prefill_
attention_ paged_ turbo4k_ turbo3v_ 64 - Prefill paged attention — TurboQuant+ asym Turbo4K + Turbo3V (BR=64).
- prefill_
attention_ paged_ turbo4k_ turbo8v_ 64 - Prefill paged attention — TurboQuant+ asym Turbo4K + Turbo8V (BR=64).
- prefill_
attention_ paged_ turbo_ 64 - Paged prefill Flash Attention — symmetric TurboQuant KV cache, BR=64.
Shared launch wrapper for the turbo8 / turbo4 / turbo3
_64kernel entries: identical ABI, the caller selects the dtype viakerneland passes that pool’s block stride + data-section offset. - prefill_
batched_ first_ chunk_ enabled - Whether chunk-zero streams may use the paged batched-prefill path.
- prefill_
varlen_ enabled - VARLEN (ragged) batched prefill enabled? (
--prefill-varlen-batch, legacyATLAS_PREFILL_VARLEN=1; default OFF). - q2_
0_ gemv - Q2_0 GEMV (M=1 decode):
C[1,N] = A[1,K] @ dequant(B), weights kept packed. - q2_
0_ gemv_ batchm - Q2_0 batched GEMV (M=1..8 decode):
C[M,N] = A[M,K] @ dequant(B). - q2_
0_ gemv_ vec - Q2_0 GEMV (M=1 decode), CANDIDATE B:
C[1,N] = A[1,K] @ dequant(B). - q2_
0_ gemv_ vec_ batchm - Q2_0 batched GEMV (M>=1 decode), CANDIDATE B:
C[M,N] = A[M,K] @ dequant(B). - q2_
0_ mmq_ gemm - Q2_0 MMQ GEMM:
C[m,n](bf16) =A_q8[m,k]xW_q2_0[n,k]. Fused bf16 store. - q2_
0_ mmq_ gemm_ packed - Q2_0 MMQ GEMM against a
PackedQ2Weight(assertsgroup == 128, the only group the MMQ block layout supports — callers fall back to transient-dequant for group 64). Convenience overq2_0_mmq_gemm. - q2_
0_ weight_ bytes - Bytes for the packed
block_q2_0form of an[n, k]weight (k % 128 == 0). - q4k_
mmq_ gemm - Q4_K MMQ GEMM: C[m,n] (bf16) = A_q8[m,k] x W_q4k[n,k]. Fused bf16 store.
- q4k_
weight_ bytes - Bytes for the Q4_K-quantized form of an [nrows, n_per_row] weight (n_per_row % 256 == 0).
- q8_
1_ scratch_ bytes - q8_1_mmq activation scratch bytes for [m, k]; generous (kpad rounded to 256).
- qsa_
block_ pool - Pool
n_newfreshly complete blocks starting atfirst_block: mean overratioraw keys -> RMSNorm*(1+w) -> rope at block-start pos. - qsa_
gather - Pack the selected tokens’ K/V rows into contiguous NHD scratch.
- qsa_
prefill_ attn - Stage 2: per-row selected-set attention, overwriting the context rows.
- qsa_
qprep - One decode query: per head, RMSNorm*(1+w) + partial rope at
pos-> FP32. - qsa_
qprep_ rows - Stage 2: per-row q prep for a contiguous selective row range.
- qsa_
score scores[b]= sum_h relu(q_h . k_b) / sqrt(hd) overn_blocksblocks.- qsa_
score_ rows - Stage 2: per-row block scores, -inf beyond each row’s complete count.
- qsa_
score_ rows_ tc - Tensor-core
qsa_score_rows(split-q). Geometry differs from the per-(row,block) kernel: one CTA covers 16 rows x 64 blocks with 8 warps, so the launch count drops from rows*blocks to ~1/1000th of that. - quant_
gemm - Unified GEMM dispatch: select kernel based on weight quantization format.
- quant_
gemv - Unified GEMV dispatch: select kernel based on weight quantization format.
- quantize_
act_ q8_ 1 - Quantize bf16 activations [m, k] -> q8_1_mmq (DS4 layout) into
out_q8. - quantize_
bf16_ to_ fp8 - Quantize a BF16 weight matrix
[N, K]to FP8 E4M3[N, K]with per-row f32 scales[N]. One CTA per row, 256 threads — parallel absmax reduction over K, then per-element saturating cast to E4M3. - quantize_
bf16_ to_ nvfp4 - Quantize a BF16 [M, K] matrix to NVFP4 (single-level, scale2=1.0): packed E2M1
[M, K/2]+ per-group-16 E4M3 scales[M, K/16]. Prepares W4A4 prefill activations. Grid = M rows (one block/row), block 128 (threads stride groups). - quantize_
weight_ q4k - Quantize bf16 weights [nrows, n_per_row] -> GGML block_q4_K (at model load).
- read_
expert_ ptrs_ u64 - One blocking D2H of a device
[n]u64 pointer table. Load-time only. - read_
expert_ scales_ f32 - One blocking D2H of a device
[n]f32 scale table. Load-time only. - requant_
w_ nvfp4_ int8 - Requant an NVFP4 weight (packed E2M1 + per-16 E4M3 block scales + per-tensor
scale2) into an int8 weight + per-32 F32 block scale, for the int8 W4A8 prefill GEMM (int8_gemm_faith2). One-time conversion per weight at load (or lazily on first int8 prefill). - reshape_
and_ cache - Write K/V to paged FP8 cache using slot_mapping.
- reshape_
and_ cache_ bf16k_ turbo2v - Write K/V to paged Bf16K + Turbo2V (TurboQuant+ safer-asym) cache (6.4x V comp).
- reshape_
and_ cache_ bf16k_ turbo3v - Write K/V to paged Bf16K + Turbo3V (TurboQuant+ safer-asym) cache.
- reshape_
and_ cache_ bf16k_ turbo4v - Write K/V to paged Bf16K + Turbo4V (TurboQuant+ safer-asym) cache.
- reshape_
and_ cache_ flash_ v_ only - V-only paged cache write — companion to the fused K-path so the
K side of the cache stays exclusively owned by
fused_k_norm_rope_cache_write_*. Use this when the fused K kernel is active to avoid the existingreshape_and_cacheoverwriting the correct K values with a double-rounded copy. - reshape_
and_ cache_ fp8 k_cache/v_cacheare the full pool base pointers.cache_strideis in elements (block_size * num_kv_heads * head_dim).- reshape_
and_ cache_ fp8k_ turbo2v - Write K/V to paged Fp8K + Turbo2V (TurboQuant+ asym) cache (6.4x V comp).
- reshape_
and_ cache_ fp8k_ turbo3v - Write K/V to paged Fp8K + Turbo3V (TurboQuant+ asym) cache.
- reshape_
and_ cache_ fp8k_ turbo4v - Write K/V to paged Fp8K + Turbo4V (TurboQuant+ asym) cache.
- reshape_
and_ cache_ nvfp4 - Write K/V to paged NVFP4 cache (E2M1 data + per-group FP8 scales).
- reshape_
and_ cache_ turbo3k_ turbo8v - Write K/V to paged Turbo3K + Turbo8V cache.
- reshape_
and_ cache_ turbo4k_ turbo3v - Write K/V to paged Turbo4K + Turbo3V cache.
- reshape_
and_ cache_ turbo4k_ turbo8v - Write K/V to paged Turbo4K + Turbo8V cache.
- residual_
add - BF16 residual add:
residual[i] += src[i](in-place). - residual_
add_ rms_ norm - Fused residual add + RMS norm + residual save.
- residual_
add_ rms_ norm_ gatef32 - Dual-output fused residual add + RMS norm (ATLAS_FP32_ROUTING).
- rms_
norm - rms_
norm_ residual - Fused RMS norm + residual save: normed = rms_norm(input), residual = input.
- rms_
norm_ short_ row_ eligible - Gate for
rms_norm_warp_row: short even rows, many of them. Disable withATLAS_RMS_NORM_WARP_ROW=0. - rms_
norm_ strided - RMS normalization: output = rms_norm(input) * weight.
- rms_
norm_ warp_ row - Warp-per-row RMS norm for SHORT rows — one warp per row instead of one
block, so the grid shrinks 8x and the reduction needs no shared memory or
barrier. Profitable exactly for the Qwen3 per-head
q_norm/k_normduring prefill (num_rows = heads * seq,hidden_size = head_dim), where the block-per-row kernel measured ~43x above its bandwidth floor. - rope
- rope_
mrope_ interleaved - MRoPE (interleaved multi-modal rotary) for Qwen3.6.
- rope_
mrope_ interleaved_ k_ only - MRoPE for K only. Used when Q was already rotated by a fused Q prefill kernel.
- rope_
proportional - Proportional RoPE (Gemma-4 full-attention layers).
- rope_
strided - RoPE: apply rotary position embeddings to Q and K in-place.
- rope_
yarn - RoPE with precomputed YaRN inv_freq table (Mistral Small 4). The kernel reads frequencies from the table instead of computing from theta.
- rope_
yarn_ scaled - YaRN RoPE for standard attention with explicit cosine/sine amplitude.
- scaled_
add - BF16 scaled accumulate:
output[i] += scale * src[i]. - set_
prefill_ varlen_ from_ cli - Publish the command line’s
--prefill-varlen-batchdecision. Returns the value IN FORCE, which differs fromenabledwhen something already resolved the cell (then the command line did NOT take effect — the caller warns, mirroringgdn_flags::set_from_cli). Absent flag ⇒ never called ⇒ the documentedATLAS_PREFILL_VARLENfallback stays reachable. - sigmoid_
blend - Sigmoid-gated blend: output = output + sigmoid_gate * src.
- sigmoid_
blend_ device - Sigmoid-gated blend reading gate scalar from device memory.
- sigmoid_
gate_ mul - Element-wise sigmoid gate:
output[i] = input[i] * sigmoid(gate[i]). - sigmoid_
gate_ mul_ batched - Batched sigmoid gate multiply across multiple tokens.
- sigmoid_
gate_ mul_ head_ broadcast - Per-head sigmoid gate multiply with broadcast over head_dim.
- silu_
mul - Fused SiLU activation: output = SiLU(gate) * up.
- silu_
mul_ quant_ fp8 - Fused SiLU·mul + per-token-group(128) FP8-E4M3 quantization — replaces the
silu_mul→per_token_group_quant_fp8pair on the W8A8 prefill down-path without materializing the BF16 intermediate. Bit-identical to the pair (product rounds through BF16 before the group max; same reduction order, scale floor, and SATFINITE encode). - softplus_
gate_ mul_ head_ broadcast - Per-head softplus gate multiply with broadcast over
head_dim. - ssd_
scan_ fits - Whether the SSD chunked scan physically fits for this
state_size. - ssd_
scan_ smem - Dynamic shared memory
mamba2_ssd_scanrequests for a given SSM state size. Grows ~linearly instate_size, so a checkpoint with a large SSM state can exceedMAX_DYNAMIC_SMEM. Kept next to the launch so the two cannot drift. - ssm_
h_ state_ f16_ to_ f32 - One-shot FP16 -> FP32 widening of one layer’s SSM h-state
(
ATLAS_SSM_H_FP16).nis the FP32 ELEMENT count of the destination. - ssm_
h_ state_ f32_ to_ f16 - One-shot FP32 -> FP16 conversion of one layer’s SSM h-state
(
ATLAS_SSM_H_FP16).nis the FP32 ELEMENT count, derived from the pool’s byte size — never a duplicated shape literal. - transpose_
block_ scale - Transpose block scales: [N/128, K/128] → [K/128, N/128].
- transpose_
fp8 - Transpose FP8 weight matrix on GPU:
B[N,K]→B_t[K,N]. Grid: (ceil(N*K/256), 1, 1) Block: (256, 1, 1) - transpose_
u8 - Batched per-expert uint8 transpose for MoE down_proj relayout.
- use_
gemv_ sw - SW kernel when the model lever is on and the handle resolved.
- w4a4_
gemm - W4A4 NVFP4 prefill GEMM (native FP4 tensor cores, sm_121a). Activation is
pre-quantized NVFP4 (
a_packed/a_scale, scale2=1.0); weight is the native NVFP4QuantizedWeight. Output BF16 [M, N]. See kernels/…/w4a4_gemm.cu. Grid: (ceil(N/128), ceil(M/128), 1) Block: (256, 1, 1). - w4a4_
gemm_ mfast - W4A16 GEMM with N_TILE=128: same kernel signature, wider N tile.
- w4a16_
decode_ gemv - Decode GEMV: software-pipelined single-warp when the lever and handle agree.
- w4a16_
gemm - W4A16 GEMM: C = A @ dequant(B).
- w4a16_
gemm_ n128 - w4a16_
gemm_ n128_ ldb - W4A16 GEMM with N_TILE=128: same kernel signature, wider N tile.
- w4a16_
gemm_ n128_ m128 - W4A16 GEMM: C = A @ B with 2-M-chunk CTA (M_TILE2=128).
- w4a16_
gemm_ n128_ m128_ bf16 - 8-arg launcher for
w4a16_gemm_t_m128_bf16(v1) ONLY. The_v2sibling’s compiled signature has a 9thldbparam — launching it through this helper makes cuLaunchKernel read one-past-the-end of the param array (observed as CUDA_ERROR_INVALID_VALUE or a host SIGSEGV depending on the neighboring heap word). Launch v2 viaw4a16_gemm_n128_m128_bf16_ldb(ldb = N when the transposed twin is unpadded). - w4a16_
gemm_ n128_ m128_ bf16_ ldb - W4A16 GEMM — LOSSLESS BF16 prefill variant of
w4a16_gemm_n128_m128. - w4a16_
gemm_ n128_ m128_ v2 - W4A16 GEMM v2: shadow of
w4a16_gemm_n128_m128(minimax, step3p7, and — since the 27B port — qwen3.6-27b). - w4a16_
gemm_ n128_ m128_ v3 - W4A16 GEMM v3: MiniMax-only shadow with K_STEP=64 (was 32 in v2). Halves K-iteration count; doubles per-iter MMA count. 1 CTA/SM (was 3 for v2) due to larger SMEM footprint.
- w4a16_
gemv - W4A16 GEMV (M=1): C = A @ dequant(B) for single-row activations.
- w4a16_
gemv_ batch2 - W4A16 double-GEMV (M=2): reads weights once, computes 2 outputs.
- w4a16_
gemv_ batch3 - W4A16 triple-GEMV (M=3): reads weights once, computes 3 outputs.
- w4a16_
gemv_ batchm - W4A16 batched GEMV (M<=MAX_M) — the NVFP4 sibling of
w8a16_gemv_batch4/16. - w4a16_
gemv_ dual - W4A16 dual GEMV: two projections sharing the same BF16 input, one launch.
- w4a16_
gemv_ dual_ batch2 - Dual-projection GEMV for 2 tokens (K+V or any 2 weight matrices).
- w4a16_
gemv_ dual_ batch3 - Dual-projection GEMV for 3 tokens (K+V or any 2 weight matrices).
- w4a16_
gemv_ dual_ sw - Single-warp-per-output variant of
w4a16_gemv_dual(8 outputs/block → N/8 grid). Bit-identical output (see w4a16_gemv_fused.cu). Default ON viaModelLevers::gemv_sw; kill withATLAS_NO_GEMV_SW=1. - w4a16_
gemv_ grid_ x - w4a16_
gemv_ qg - W4A16 GEMV with inline Q/Gate deinterleave on output write.
- w4a16_
gemv_ qg_ batch2 - Q+Gate GEMV for 2 tokens with inline deinterleave.
- w4a16_
gemv_ qg_ batch3 - W4A16 GEMV batch3 with inline Q/Gate deinterleave.
- w4a16_
gemv_ qkvz - W4A16 GEMV with inline QKVZ deinterleave on output write.
- w4a16_
gemv_ silu_ input - W4A16 GEMV with fused SiLU input: silu(gate)*up as activation, GEMV with down weights.
- w4a16_
gemv_ silu_ input_ sw - Single-warp-per-output variant of
w4a16_gemv_silu_input(N/8 grid). Bit-identical. Default ON viaModelLevers::gemv_sw. - w4a16_
gemv_ sw - Single-warp-per-output W4A16 GEMV (M=1). Grid:
(ceil(N/8), 1, 1). - w4a16_
gemv_ sw_ grid_ x - w4a16_
gemv_ sw_ raw - Same launch as
w4a16_gemv_swfor callers that hold the NVFP4 operand triple as loose pointers rather than aQuantizedWeight(GLM-5.3’sNvfp4Proj). - w8a16_
gemm - W8A16 GEMM (M>1):
C[M,N] = A[M,K] @ dequant(B[N,K])for prefill. - w8a16_
gemm_ n128_ m128 - W8A16 transposed M128 GEMM (kernel
w8a16_gemm_t_m128): FP8 E4M3 analog ofw4a16_gemm_n128_m128_v2. 128×128 (M×N) tile, two 64-row chunks, 8 warps, parallel-chunkm16n8k16.bf16.bf16MMA + two-level FP32 block-scale fold. Same transposed contract asw8a16_gemm_t(B_t[K,N]+ block_scale_t[K/128, N/128]); reuses the transpose_fp8 / transpose_block_scale output as-is. Grid: (ceil(N/128), ceil(M/128), 1) Block: (256, 1, 1) - w8a16_
gemm_ pipelined - W8A16 GEMM pipelined (M>1): bit-identical (cosine=1.0) faster rewrite of
w8a16_gemm— same args, same numerics, ~4.6× faster on GB10/sm_121. - w8a16_
gemm_ t - W8A16 Transposed GEMM:
C[M,N] = A[M,K] @ dequant(B_t[K,N])with coalesced reads. - w8a16_
gemm_ t_ pipelined - Pipelined transposed W8A16 GEMM (kernel
w8a16_gemm_t_pipelined): same transposed args asw8a16_gemm_t, ~4.2x via smem-LUT + K_STEP32 + K-contiguous smem_B + 128x32 occupancy tile. Grid: (ceil(N/32), ceil(M/128), 1) Block: (256, 1, 1) - w8a16_
gemv - W8A16 GEMV (M=1): C = A @ dequant_lut(B_fp8) * row_scale for FP8 E4M3 weights.
- w8a16_
gemv_ batch2 - Block-scaled FP8 dual-GEMV (batch=2).
inputis[2, K]BF16,outputis[2, N]BF16;weight/block_scaleare the raww8a16_gemvpointers. Grid: (ceil(N/4), 1, 1) Block: (256, 1, 1) - w8a16_
gemv_ batch4 - Block-scaled FP8 batched GEMV (M<=4).
inputis[M, K]BF16,outputis[M, N]BF16;weight/block_scaleare the raww8a16_gemvpointers (2D block-scaled FP8). One pass over the FP8 weight serves all M rows — the M=4 sibling ofw8a16_gemv, replacingw8a16_gemm_pipelinedfor n<=4 batched decode (which pads M to a 128-row MMA tile). Bit-identical per-row tow8a16_gemv. Grid: (ceil(N/4), 1, 1) Block: (256, 1, 1) - w8a16_
gemv_ dual - W8A16 (FP8 E4M3) dual GEMV: two projections sharing the same BF16 input,
one launch. blockIdx.z selects projection 0 (gate) vs 1 (up). Both N must be
equal. Mirrors
w4a16_gemv_dualbut takes RAW DevicePtrs (FP8 weights arefp8w.weight/fp8w.row_scale, no QuantizedWeight wrapper, no scale2 f32). - w8a16_
gemv_ silu_ input - W8A16 (FP8 E4M3) GEMV with fused SiLU input: silu(gate)*up as activation,
GEMV with FP8 down weights. Reads
gate_out[K]andup_out[K]BF16, computes silu(gate)*up per element inline, then multiplies by dequanted FP8 down weights. Eliminates the separate silu_mul kernel + down GEMV. Mirrorsw4a16_gemv_silu_inputbut with RAW DevicePtrs (no scale2 f32). - wide_
prefill_ kernel - The HDIM>256 prefill kernel: its module/entry name and the BR its grid must
be built for. ONE reader, because the name is chosen in
qwen3_attention::initand the grid here, and a mismatch is silent. - widen_
block_ scale_ f32 - Widen an FP8 block-scale tensor to FP32 on the GPU.