Article
dsa-op
On this page 7
Analyzing DSA Operators
After the prerequisite study of DSA and FlashAttention, it is time to analyze existing DSA operators.
For now, the analysis is based entirely on implementations in the SGLang inference engine.
Because the GPUs available to me are H-series cards, the discussion is primarily based on the Hopper architecture.
SGLang nsa backend
The NSA prefill/decode attention operator options include:
flashmla_sparse: theflash_mla_sparse_fwdoperator fromflash_mla. It runs on Hopper and Blackwell GPUs and requires bf16 Q and KV inputs.flashmla_kv: theflash_mla_with_kvcacheoperator fromflash_mla. It runs on Hopper and Blackwell GPUs and requires bf16 Q and an fp8 K cache.fa3: theflash_attn_with_kvcacheoperator fromflash_attn. It runs only on Hopper GPUs and requires bf16 Q and KV inputs.tilelang: atilelangimplementation that runs on GPUs, HPUs, and NPUs.aiter: the Aiter operator for AMD hardware. It can be used only for decoding.
Based on benchmarks, the default configurations for H200 and B200 are:
- H200:
flashmla_sparsefor prefill attention—short-sequence prefill uses MHA through FlashAttention varlen—andfa3for decode attention. - B200:
flashmla_autofor prefill attention—short-sequence prefill uses MHA through TRT-LLM ragged—andflashmla_kvfor decode attention.
flashmla-sparse
Quick QA
Q: Why not use FA3?
A: Although fa3 supports KV pages and paged addressing naturally permits random access, it cannot handle different queries using different KV addresses unless execution degenerates to one query per SM, which is extremely inefficient.
Q: Why not use MHA mode?
A:
- Dense prefill, MHA vs. MQA: MHA requires less computation and prefill is compute-bound, so choose MHA.
- Sparse prefill, MHA vs. MQA:
- Top-k greatly reduces the number of KV entries, weakening the compute-bound assumption.
- MQA does not need to expand K/V, avoiding a huge intermediate tensor; MQA’s I/O advantage therefore becomes more significant.