Architecture
~9 min readUpdated: December 2026

Causal MXFP8 Attention: Eliminating Future-Token Scale Leakage on Blackwell

Causal MXFP8 Attention Kernel Scale Folding on Blackwell B200 in Smoke Monkey

Sarvam AI's arXiv:2611.36044 exposes future-token leakage in NVIDIA Transformer Engine's stock MXFP8 attention caused by 32-token shared E8M0 value scales, and solves it on B200 GPUs via token-local scale folding—cutting 32K Qwen3-4B prefix disagreement from 0.416% to 0.021%.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

Causal MXFP8 Attention: Eliminating Future-Token Scale Leakage on Blackwell: Sarvam AI's arXiv:2611.36044 exposes future-token leakage in NVIDIA Transformer Engine's stock MXFP8 attention caused by 32-token shared E8M0 value scales, and solves it on B200 GPUs via token-local scale folding—cutting 32K Qwen3-4B prefix disagreement from 0.416% to 0.021%. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.

Key Architectural Takeaways
Quick Implementation Examplemxfp8-causal-benchmark-agent.ts
mxfp8-causal-benchmark-agent.tstypescript
import { createAgent } from '@smoke-monkey/harness';
const kernelAuditAgent = createAgent({
agentId: 'blackwell-mxfp8-verifier',
provider: 'anthropic',
model: 'claude-sonnet-4-5',
workspacePath: process.cwd(),
permissions: {
read_file: 'allow',
write_file: 'allow',
run_command: 'ask',
},
mcpServers: {
nsight: {
command: 'python3',
args: ['-m', 'cuda_kernel_audit_mcp', '--arch', 'sm_100a', '--dtype', 'mxfp8'],
},
},
});
async function verifyPrefixInvariance() {
const result = await kernelAuditAgent.run(
'Run fixed-shape suffix amplification (2^10 scaling on suffix V) and 32K prefix-vs-full comparison on Qwen3-4B-Base, verifying bitwise prefix invariance across all 32-token boundary blocks.'
);
console.log('Kernel Causality Audit:', result.summary);
}
verifyPrefixInvariance().catch(console.error);
Video Guides

Watch: Related Video Guides

FlashAttention-4: Algorithm and Kernel Pipelining for Blackwell GPUs

FlashAttention Explained: How GPU Kernels Make Attention Fast

Why Stock MXFP8 Attention Breaks Causality Across 32-Token Value Blocks

On NVIDIA Blackwell (SM100) GPUs, MXFP8 stores groups of 32 elements sharing a power-of-two E8M0 scale along a GEMM's reduction dimension. For value aggregation (O = PV), each 32-element group spans 32 consecutive token rows of V for a single feature column. In NVIDIA Transformer Engine's stock cuDNN MXFP8 attention recipe, the kernel computes each 32-token block's scale across all 32 rows—including masked future tokens where P_{i,j} = 0.

If a future value at position 55 increases the block maximum from 2^-20 to 1, the shared E8M0 scale jumps from 2^-28 to 2^-8. An earlier visible value V_{32,0} = 2^-20 now enters the E4M3 quantizer as 2^-12, which is less than half of E4M3's smallest normal/subnormal threshold (2^-9 minimum positive), rounding V_hat_{32,0} to zero. Even though P_{47,55} = 0, query 47's output collapses—violating autoregressive prefix invariance.

Token-Local Scale Folding Math & Qwen3-Base Benchmarks on B200

Sarvam AI's causal MXFP8 kernel (arXiv:2611.36044) partitions visible keys for query i into completed blocks (j < 32 * floor(i/32), computed via stock cuDNN SM100 MXFP8) and the boundary block (32 * floor(i/32) <= j <= i). Inside the boundary block, each token j computes a token-local scale s_j^V = 2^ceil(log2(max_r |V_{j,r}| / 256)) across its D features. To preserve native MXFP8 matrix multiplication, the kernel assigns all value payloads a constant 1/256 scale and folds 256 * s_j^V into the unnormalized softmax weights R_{i,j} = 256 * p_{i,j} * s_j^V, quantized using a visible-only scale s_i^R before merging via log-sum-exp (LSE).

Evaluation Metric (NVIDIA B200)Stock MXFP8 (TE)Causal MXFP8 (Scale Folding)BF16 Reference
Qwen3-4B 32K Suffix Perturbation (2^10)15,872 / 15,872 leaked (`Δlogit= 1.29`)0 / 15,872 (bitwise identical)0 / 15,872
Qwen3-14B 32K Suffix Perturbation (2^10)15,872 / 15,872 leaked (`Δlogit= 1.41`)0 / 15,872 (bitwise identical)0 / 15,872
Qwen3-4B 32K Full vs Prefix Disagreement0.416%0.021%0.015%
Qwen3-4B 32K Backward Grad L2 Error (dQ / dK / dV)6.63% / 6.58% / 4.99%5.23% / 5.21% / 3.37%0.00%
End-to-End Qwen3-4B 32K TrainingBaseline MXFP8+4.9% throughput, -5.2% memory vs BF161.00x
Single-Request Decode vs vLLM FP8 (4K–32K)N/A+3.8% to +9.9% faster (Qwen3-4B)—

Backward Pass Also Leaks Without Dequantized Operands

Stock MXFP8 backward recomputes shared scales across sequence positions for `K` in `dQ` and `Q` in `dK`. Storing only quantized `Q/K`, token-local `V`, BF16 `O`, and FP32 LSE—then decoding to BF16 for FlashAttention-4 backward—keeps prefix gradient leakage within `6.60e-5` relative L2 without storing full BF16 `Q/K/V`.

Reproducing Fixed-Shape Suffix Leakage Checks in PyTorch

Before shipping custom FP8/MXFP8 attention kernels into production agent serving stacks, run a fixed-shape suffix amplification probe at cut offset c inside each 32-token value block.

python
import torch

def test_prefix_invariance(attn_fn, q, k, v, cut=48):
    # Perturb only future value rows >= cut while keeping Q, K, and tensor shapes identical
    v_perturbed = v.clone()
    v_perturbed[:, :, cut:, :] *= 1024.0  # 2^10 scale shift trigger

    out_clean = attn_fn(q, k, v, causal=True)
    out_pert = attn_fn(q, k, v_perturbed, causal=True)

    prefix_diff = (out_clean[:, :, :cut, :] - out_pert[:, :, :cut, :]).abs().max().item()
    assert prefix_diff == 0.0, f"Causal leakage detected at boundary block: max diff={prefix_diff}"

Why Prefix Invariance Matters for Long-Horizon Agent Caching

Autonomous coding agents rely heavily on prompt-prefix KV caching across multi-turn tool calls. If an inference backend leaks future quantization scales into cached prefix blocks—or alters KV blocks as new tokens arrive—agent tool trajectories diverge between batched prefill and incremental decode. Integrating causal MXFP8 kernels and paged incremental MXFP8 KV caches guarantees deterministic tool-call outputs on Blackwell clusters inside Smoke Monkey Harness.

Google Search Questions & Answers

Frequently Asked Questions

Q:Why do shared MXFP8 value scales cause leakage when future tokens are masked?

In `O = PV`, MXFP8 computes one `E8M0` scale across 32 consecutive tokens per feature. If a masked future token raises that block's maximum magnitude, earlier visible values can underflow below E4M3's smallest positive value (`2^-9`) and round to zero.

Q:Does token-local scale folding drop back to BF16 for the boundary matrix multiply?

No. Unlike MatX's BF16-boundary approach, folding `256 * s_j^V` into the softmax weights `R_{i,j}` with a fixed `1/256` value payload scale keeps both `QK^T` and `WU` in native MXFP8 Tensor Core instructions.

Q:What are the current kernel implementation constraints reported in arXiv:2611.36044?

The paper's SM100 kernel supports head dimension `128`, zero dropout, and sequence lengths divisible by `128`, packing 4 query heads sharing a KV head across 32 query positions into 128 matrix rows.

Q:How much faster is causal MXFP8 in vLLM decode compared to standard FP8?

With a paged MXFP8 KV cache whose scales depend only on observed tokens, single-request Qwen3-4B decode throughput improves by 3.8%–9.9% over vLLM FP8 attention + FP8 KV cache across 4K–32K contexts.

Related Alternatives & Comparisons

Related Architecture Guides

View all guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness