← Back to Pull requests

feat(mla): fuse FP8 SM120 sparse prefill #8747

Closed
unknown closed this pull request without merging on Nov 16, 2026 01:48 UTC
View on GitHub
unknown unknown commented on Nov 05, 2026 02:44 UTC
Author

<!-- .github/pull_request_template.md -->

📌 Description

Fuses

  • Q RoPE

  • sparse MLA

  • inverse output RoPE

  • and FP8 output quantization

  • for FP8-cache SM120 prefill. Mega is not proper name in this context, we inherit the name from related project.

    CuTe separates K loading, V loading, QK and softmax/PV roles, with compile-time fused/unfused specialization.

    Native NVFP4 changes are in #9356.

    Benchmark method

  • RTX PRO 6000 Blackwell Server Edition, CUDA 13.4, SM120.

  • Baseline: main merge-base 18fb0bfcc6d7e8a0c25a7784af559cc1e58124cb;

  • PR: This branch.

  • Warm-L2 CUDA Graph replay, 100 ms warmup and 1000 ms measurement per shape.

  • GPU runs are serialized. All 176 original builtin rows are retained, with DSv4.1 Q=32 added (192 total). Values below are microseconds.
  • Attention-only compares the baseline default dispatcher against PR non-mega attention.

  • DSv4.1 PR measurements explicitly select prefill at every Q, including Q≤64; the baseline retains its default decode/prefill selection.

  • Mega compares against a complete baseline sequence: separate Q RoPE, original attention, then inverse-RoPE/FP8 quantization. The sequence is captured and timed as a whole. Only the benchmark/transform helpers are backported to the baseline checkout; its attention implementation is unchanged.
  • DSv4 uses D=512 and a 1,048,576-entry main pool. Its dual-cache secondary pool targets 256 MiB. DSv3.2 uses Q/K dim 576, V dim 512 and 1,048,576 cached entries. DSv4.1 uses D=512, a 1,048,576-entry main pool and a 524,288-entry secondary pool. Main pages have 64 entries. 128+fp4 selects 128 FP8 main candidates plus 512 FP4 compressed candidates. That mixed-cache path and H<32 retain the existing prefill implementation; the new CuTe FP8 path requires complete 32-head tiles and FP8 caches.

    NOTE for benchmark:

  • Benchmark --force-prefill forces non-mega prefill; benchmark --mega also explicitly forces prefill.

  • Normal run() and run_mega() retain the existing dispatcher: eligible Q ≤ 64 cases use decode by default. So the rows with Q <=64 shall be treated as decode baseline on old merge base vs prefill kernel
  • <details>
    <summary>DSv4 decode-dsv4</summary>

    | H | Q | Selected KV | Layout / scale format | Baseline attention | PR non-mega attention | Baseline / PR attention |
    |---:|---:|---|---|---:|---:|---:|
    | 16 | 1 | 128 | — | 11.40 | 11.60 | 0.983× |
    | 16 | 16 | 128 | — | 11.80 | 11.80 | 1.000× |
    | 16 | 16 | 192 | — | 12.00 | 12.20 | 0.984× |
    | 16 | 16 | 256 | — | 11.80 | 11.80 | 1.000× |
    | 16 | 16 | 512 | — | 12.20 | 12.20 | 1.000× |
    | 32 | 1 | 128 | — | 11.60 | 11.60 | 1.000× |
    | 32 | 16 | 128 | — | 12.00 | 12.00 | 1.000× |
    | 32 | 16 | 192 | — | 12.20 | 12.20 | 1.000× |
    | 32 | 16 | 256 | — | 12.20 | 12.20 | 1.000× |
    | 32 | 16 | 512 | — | 16.50 | 16.50 | 1.000× |
    | 64 | 1 | 128 | — | 11.60 | 11.80 | 0.983× |
    | 64 | 16 | 128 | — | 12.20 | 12.20 | 1.000× |
    | 64 | 16 | 192 | — | 16.50 | 16.50 | 1.000× |
    | 64 | 16 | 256 | — | 20.50 | 20.40 | 1.005× |
    | 64 | 16 | 512 | — | 30.20 | 30.30 | 0.997× |
    | 64 | 16 | 1024 | — | 42.60 | 42.60 | 1.000× |
    | 128 | 1 | 128 | — | 11.80 | 11.80 | 1.000× |
    | 128 | 16 | 128 | — | 17.00 | 17.00 | 1.000× |
    | 128 | 16 | 192 | — | 21.20 | 21.20 | 1.000× |
    | 128 | 16 | 256 | — | 30.30 | 30.30 | 1.000× |
    | 128 | 16 | 512 | — | 42.50 | 42.50 | 1.000× |
    | 128 | 16 | 1024 | — | 78.80 | 78.80 | 1.000× |
    | 128 | 32 | 128 | — | 31.30 | 31.50 | 0.994× |
    | 128 | 32 | 192 | — | 38.90 | 39.10 | 0.995× |
    | 128 | 32 | 256 | — | 46.40 | 46.60 | 0.996× |
    | 128 | 32 | 512 | — | 71.70 | 71.80 | 0.999× |

    </details>

    <details>
    <summary>DSv4 prefill</summary>

    | H | Q | Selected KV | Layout / scale format | Baseline attention | PR non-mega attention | Baseline / PR attention |
    |---:|---:|---|---|---:|---:|---:|
    | 8 | 128 | 128 | — | 14.00 | 14.30 | 0.979× |
    | 16 | 128 | 128 | — | 14.30 | 14.50 | 0.986× |
    | 8 | 128 | 192 | — | 18.20 | 18.60 | 0.978× |
    | 16 | 128 | 192 | — | 18.40 | 18.60 | 0.989× |
    | 8 | 128 | 256 | — | 22.30 | 22.80 | 0.978× |
    | 16 | 128 | 256 | — | 22.30 | 22.30 | 1.000× |
    | 8 | 128 | 512 | — | 35.60 | 35.60 | 1.000× |
    | 16 | 128 | 512 | — | 35.50 | 35.50 | 1.000× |
    | 64 | 128 | 128 | — | 38.40 | 38.90 | 0.987× |
    | 64 | 128 | 192 | — | 49.30 | 49.70 | 0.992× |
    | 64 | 128 | 256 | — | 60.20 | 60.60 | 0.993× |
    | 64 | 128 | 512 | — | 96.50 | 96.60 | 0.999× |
    | 128 | 128 | 128 | — | 57.30 | 58.10 | 0.986× |
    | 128 | 128 | 192 | — | 73.70 | 74.50 | 0.989× |
    | 128 | 128 | 256 | — | 90.10 | 90.90 | 0.991× |
    | 128 | 128 | 512 | — | 142.70 | 143.80 | 0.992× |
    | 8 | 512 | 192 | — | 52.80 | 53.80 | 0.981× |
    | 16 | 512 | 192 | — | 53.00 | 53.00 | 1.000× |
    | 8 | 512 | 256 | — | 64.50 | 65.60 | 0.983× |
    | 16 | 512 | 256 | — | 64.90 | 64.90 | 1.000× |
    | 64 | 512 | 128 | — | 111.70 | 113.50 | 0.984× |
    | 64 | 512 | 192 | — | 145.80 | 147.40 | 0.989× |
    | 64 | 512 | 256 | — | 181.10 | 182.50 | 0.992× |
    | 64 | 512 | 512 | — | 293.20 | 297.10 | 0.987× |
    | 128 | 512 | 128 | — | 296.20 | 298.50 | 0.992× |
    | 128 | 512 | 192 | — | 358.60 | 360.60 | 0.994× |
    | 128 | 512 | 256 | — | 418.20 | 420.20 | 0.995× |
    | 128 | 512 | 512 | — | 570.80 | 571.40 | 0.999× |
    | 128 | 1024 | 128 | — | 605.00 | 609.30 | 0.993× |
    | 128 | 1024 | 192 | — | 718.00 | 722.40 | 0.994× |
    | 128 | 1024 | 256 | — | 831.00 | 835.30 | 0.995× |
    | 128 | 1024 | 512 | — | 1142.60 | 1133.20 | 1.008× |

    </details>

    <details>
    <summary>DSv4 dual</summary>

    | H | Q | Selected KV | Layout / scale format | Baseline attention | PR non-mega attention | Baseline / PR attention |
    |---:|---:|---|---|---:|---:|---:|
    | 8 | 256 | 128+512 | page64 | 90.10 | 90.00 | 1.001× |
    | 16 | 256 | 128+512 | page64 | 90.40 | 90.30 | 1.001× |
    | 8 | 256 | 128+512 | page2 | 90.30 | 90.20 | 1.001× |
    | 16 | 256 | 128+512 | page2 | 90.80 | 90.90 | 0.999× |
    | 64 | 256 | 128+512 | page64 | 189.70 | 189.90 | 0.999× |
    | 128 | 512 | 128+512 | page64 | 775.70 | 775.00 | 1.001× |
    | 128 | 512 | 128+512 | page2 | 777.90 | 781.10 | 0.996× |
    | 128 | 512 | 128+768 | page2 | 1016.90 | 1020.20 | 0.997× |
    | 128 | 512 | 128+1536 | page2 | 1730.50 | 1736.30 | 0.997× |
    | 128 | 512 | 128+1664 | page2 | 1849.30 | 1855.30 | 0.997× |

    </details>

    <details>
    <summary>DSv3.2 decode-dsv3_2</summary>

    | H | Q | Selected KV | Layout / scale format | Baseline attention | PR non-mega attention | Baseline / PR attention |
    |---:|---:|---|---|---:|---:|---:|
    | 8 | 1 | 2048 | — | 12.20 | 12.20 | 1.000× |
    | 8 | 16 | 2048 | — | 20.40 | 20.40 | 1.000× |
    | 8 | 32 | 2048 | — | 37.20 | 37.30 | 0.997× |
    | 8 | 64 | 2048 | — | 69.60 | 69.60 | 1.000× |
    | 16 | 1 | 2048 | — | 13.00 | 13.00 | 1.000× |
    | 16 | 16 | 2048 | — | 21.90 | 21.90 | 1.000× |
    | 16 | 32 | 2048 | — | 39.70 | 39.80 | 0.997× |
    | 16 | 64 | 2048 | — | 73.30 | 73.30 | 1.000× |
    | 32 | 1 | 2048 | — | 13.00 | 13.00 | 1.000× |
    | 32 | 16 | 2048 | — | 39.70 | 39.70 | 1.000× |
    | 32 | 32 | 2048 | — | 71.40 | 71.40 | 1.000× |
    | 32 | 64 | 2048 | — | 153.30 | 153.30 | 1.000× |
    | 64 | 1 | 2048 | — | 13.30 | 13.30 | 1.000× |
    | 64 | 16 | 2048 | — | 71.40 | 71.40 | 1.000× |
    | 64 | 32 | 2048 | — | 152.60 | 152.80 | 0.999× |
    | 64 | 64 | 2048 | — | 294.80 | 295.20 | 0.999× |
    | 128 | 1 | 2048 | — | 17.20 | 17.40 | 0.989× |
    | 128 | 16 | 2048 | — | 152.60 | 152.70 | 0.999× |
    | 128 | 32 | 2048 | — | 292.50 | 292.70 | 0.999× |
    | 128 | 64 | 2048 | — | 455.40 | 455.80 | 0.999× |

    </details>

    <details>
    <summary>DSv3.2 prefill</summary>

    | H | Q | Selected KV | Layout / scale format | Baseline attention | PR non-mega attention | Baseline / PR attention |
    |---:|---:|---|---|---:|---:|---:|
    | 64 | 128 | 2048 | auto | 141.50 | 141.30 | 1.001× |
    | 128 | 128 | 2048 | auto | 240.90 | 240.80 | 1.000× |
    | 64 | 512 | 2048 | auto | 533.00 | 534.90 | 0.996× |
    | 128 | 512 | 2048 | auto | 785.60 | 786.00 | 0.999× |
    | 64 | 128 | 2048 | arbitrary_fp32 | 162.00 | 162.40 | 0.998× |
    | 128 | 128 | 2048 | arbitrary_fp32 | 326.70 | 326.60 | 1.000× |
    | 64 | 512 | 2048 | arbitrary_fp32 | 565.00 | 566.50 | 0.997× |
    | 128 | 512 | 2048 | arbitrary_fp32 | 1034.50 | 1035.10 | 0.999× |

    </details>

    <details>
    <summary>DSv4.1</summary>

    | H | Q | Selected KV | Layout / scale format | Baseline attention | PR non-mega attention | Baseline / PR attention |
    |---:|---:|---|---|---:|---:|---:|
    | 8 | 1 | 512 | footer | 9.60 | 37.60 | 0.255× |
    | 8 | 1 | 512 | inline | 8.80 | 37.20 | 0.237× |
    | 16 | 1 | 512 | footer | 10.00 | 38.60 | 0.259× |
    | 16 | 1 | 512 | inline | 9.20 | 37.80 | 0.243× |
    | 32 | 1 | 512 | footer | 10.00 | 36.40 | 0.275× |
    | 32 | 1 | 512 | inline | 9.40 | 30.90 | 0.304× |
    | 64 | 1 | 512 | footer | 10.20 | 36.60 | 0.279× |
    | 64 | 1 | 512 | inline | 9.40 | 31.20 | 0.301× |
    | 8 | 4 | 512 | footer | 9.80 | 38.10 | 0.257× |
    | 8 | 4 | 512 | inline | 9.00 | 37.40 | 0.241× |
    | 16 | 4 | 512 | footer | 10.20 | 38.80 | 0.263× |
    | 16 | 4 | 512 | inline | 9.40 | 38.10 | 0.247× |
    | 32 | 4 | 512 | footer | 10.20 | 36.40 | 0.280× |
    | 32 | 4 | 512 | inline | 9.40 | 30.90 | 0.304× |
    | 64 | 4 | 512 | footer | 10.40 | 36.40 | 0.286× |
    | 64 | 4 | 512 | inline | 9.60 | 30.90 | 0.311× |
    | 8 | 16 | 512 | footer | 9.80 | 39.30 | 0.249× |
    | 8 | 16 | 512 | inline | 9.00 | 38.50 | 0.234× |
    | 16 | 16 | 512 | footer | 10.40 | 39.70 | 0.262× |
    | 16 | 16 | 512 | inline | 9.60 | 39.30 | 0.244× |
    | 32 | 16 | 512 | footer | 14.30 | 36.60 | 0.391× |
    | 32 | 16 | 512 | inline | 13.30 | 31.00 | 0.429× |
    | 64 | 16 | 512 | footer | 25.60 | 36.60 | 0.699× |
    | 64 | 16 | 512 | inline | 23.30 | 31.10 | 0.749× |
    | 8 | 32 | 512 | footer | 13.70 | 40.30 | 0.340× |
    | 8 | 32 | 512 | inline | 12.40 | 39.10 | 0.317× |
    | 16 | 32 | 512 | footer | 14.30 | 40.10 | 0.357× |
    | 16 | 32 | 512 | inline | 13.30 | 39.70 | 0.335× |
    | 32 | 32 | 512 | footer | 25.60 | 36.60 | 0.699× |
    | 32 | 32 | 512 | inline | 23.30 | 31.10 | 0.749× |
    | 64 | 32 | 512 | footer | 37.20 | 36.60 | 1.016× |
    | 64 | 32 | 512 | inline | 34.50 | 31.10 | 1.109× |
    | 8 | 64 | 512 | footer | 23.90 | 41.50 | 0.576× |
    | 8 | 64 | 512 | inline | 21.30 | 39.70 | 0.537× |
    | 16 | 64 | 512 | footer | 25.50 | 40.50 | 0.630× |
    | 16 | 64 | 512 | inline | 23.30 | 40.10 | 0.581× |
    | 32 | 64 | 512 | footer | 37.20 | 36.60 | 1.016× |
    | 32 | 64 | 512 | inline | 34.40 | 31.10 | 1.106× |
    | 64 | 64 | 512 | footer | 64.70 | 36.90 | 1.753× |
    | 64 | 64 | 512 | inline | 61.80 | 31.70 | 1.950× |
    | 8 | 1024 | 512 | footer | 258.60 | 258.30 | 1.001× |
    | 8 | 1024 | 512 | inline | 252.90 | 252.20 | 1.003× |
    | 16 | 1024 | 512 | footer | 259.80 | 258.30 | 1.006× |
    | 16 | 1024 | 512 | inline | 254.00 | 253.60 | 1.002× |
    | 32 | 1024 | 512 | footer | 466.30 | 248.90 | 1.873× |
    | 32 | 1024 | 512 | inline | 446.40 | 241.90 | 1.845× |
    | 64 | 1024 | 512 | footer | 1011.40 | 432.90 | 2.336× |
    | 64 | 1024 | 512 | inline | 936.60 | 406.20 | 2.306× |
    | 8 | 1 | 128+fp4 | footer | 11.20 | 48.90 | 0.229× |
    | 8 | 1 | 128+fp4 | inline | 10.40 | 48.90 | 0.213× |
    | 16 | 1 | 128+fp4 | footer | 12.00 | 49.70 | 0.241× |
    | 16 | 1 | 128+fp4 | inline | 11.20 | 49.70 | 0.225× |
    | 32 | 1 | 128+fp4 | footer | 12.00 | 50.10 | 0.240× |
    | 32 | 1 | 128+fp4 | inline | 11.20 | 49.90 | 0.224× |
    | 64 | 1 | 128+fp4 | footer | 12.20 | 50.10 | 0.244× |
    | 64 | 1 | 128+fp4 | inline | 11.40 | 49.90 | 0.228× |
    | 8 | 4 | 128+fp4 | footer | 11.40 | 49.30 | 0.231× |
    | 8 | 4 | 128+fp4 | inline | 10.60 | 49.00 | 0.216× |
    | 16 | 4 | 128+fp4 | footer | 12.20 | 49.90 | 0.244× |
    | 16 | 4 | 128+fp4 | inline | 11.40 | 49.70 | 0.229× |
    | 32 | 4 | 128+fp4 | footer | 12.20 | 50.10 | 0.244× |
    | 32 | 4 | 128+fp4 | inline | 11.40 | 49.90 | 0.228× |
    | 64 | 4 | 128+fp4 | footer | 12.50 | 50.30 | 0.249× |
    | 64 | 4 | 128+fp4 | inline | 11.80 | 49.90 | 0.236× |
    | 8 | 16 | 128+fp4 | footer | 11.40 | 50.10 | 0.228× |
    | 8 | 16 | 128+fp4 | inline | 10.60 | 49.30 | 0.215× |
    | 16 | 16 | 128+fp4 | footer | 12.50 | 50.50 | 0.248× |
    | 16 | 16 | 128+fp4 | inline | 11.80 | 50.10 | 0.236× |
    | 32 | 16 | 128+fp4 | footer | 17.20 | 50.70 | 0.339× |
    | 32 | 16 | 128+fp4 | inline | 16.40 | 50.10 | 0.327× |
    | 64 | 16 | 128+fp4 | footer | 30.90 | 50.50 | 0.612× |
    | 64 | 16 | 128+fp4 | inline | 29.20 | 50.10 | 0.583× |
    | 8 | 32 | 128+fp4 | footer | 16.10 | 50.70 | 0.318× |
    | 8 | 32 | 128+fp4 | inline | 15.30 | 49.70 | 0.308× |
    | 16 | 32 | 128+fp4 | footer | 17.10 | 50.80 | 0.337× |
    | 16 | 32 | 128+fp4 | inline | 16.50 | 50.10 | 0.329× |
    | 32 | 32 | 128+fp4 | footer | 30.90 | 51.10 | 0.605× |
    | 32 | 32 | 128+fp4 | inline | 29.30 | 50.30 | 0.583× |
    | 64 | 32 | 128+fp4 | footer | 57.10 | 51.30 | 1.113× |
    | 64 | 32 | 128+fp4 | inline | 55.50 | 50.30 | 1.103× |
    | 8 | 64 | 128+fp4 | footer | 29.00 | 52.00 | 0.558× |
    | 8 | 64 | 128+fp4 | inline | 27.40 | 50.10 | 0.547× |
    | 16 | 64 | 128+fp4 | footer | 30.90 | 51.80 | 0.597× |
    | 16 | 64 | 128+fp4 | inline | 29.30 | 50.30 | 0.583× |
    | 32 | 64 | 128+fp4 | footer | 57.10 | 52.00 | 1.098× |
    | 32 | 64 | 128+fp4 | inline | 55.50 | 50.50 | 1.099× |
    | 64 | 64 | 128+fp4 | footer | 96.20 | 103.10 | 0.933× |
    | 64 | 64 | 128+fp4 | inline | 96.30 | 99.90 | 0.964× |
    | 8 | 1024 | 128+fp4 | footer | 328.50 | 330.50 | 0.994× |
    | 8 | 1024 | 128+fp4 | inline | 304.50 | 304.00 | 1.002× |
    | 16 | 1024 | 128+fp4 | footer | 324.50 | 327.50 | 0.991× |
    | 16 | 1024 | 128+fp4 | inline | 306.00 | 306.30 | 0.999× |
    | 32 | 1024 | 128+fp4 | footer | 603.40 | 603.00 | 1.001× |
    | 32 | 1024 | 128+fp4 | inline | 547.00 | 548.30 | 0.998× |
    | 64 | 1024 | 128+fp4 | footer | 1339.90 | 1359.20 | 0.986× |
    | 64 | 1024 | 128+fp4 | inline | 1135.60 | 1144.90 | 0.992× |

    Equal-work full-pipeline comparison:

    | H | Q | Selected KV | Layout | Baseline separate kernels | PR mega | Baseline / mega |
    |---:|---:|---|---|---:|---:|---:|
    | 8 | 1 | 512 | footer | 11.60 | 39.10 | 0.297× |
    | 8 | 1 | 512 | inline | 10.80 | 38.30 | 0.282× |
    | 16 | 1 | 512 | footer | 12.00 | 40.50 | 0.296× |
    | 16 | 1 | 512 | inline | 11.40 | 39.70 | 0.287× |
    | 32 | 1 | 512 | footer | 12.00 | 38.20 | 0.314× |
    | 32 | 1 | 512 | inline | 11.40 | 32.50 | 0.351× |
    | 64 | 1 | 512 | footer | 12.20 | 38.20 | 0.319× |
    | 64 | 1 | 512 | inline | 11.60 | 32.70 | 0.355× |
    | 8 | 4 | 512 | footer | 11.80 | 39.40 | 0.299× |
    | 8 | 4 | 512 | inline | 10.80 | 38.70 | 0.279× |
    | 16 | 4 | 512 | footer | 12.00 | 40.70 | 0.295× |
    | 16 | 4 | 512 | inline | 11.40 | 40.10 | 0.284× |
    | 32 | 4 | 512 | footer | 12.20 | 38.50 | 0.317× |
    | 32 | 4 | 512 | inline | 11.60 | 32.70 | 0.355× |
    | 64 | 4 | 512 | footer | 12.60 | 38.50 | 0.327× |
    | 64 | 4 | 512 | inline | 11.80 | 32.90 | 0.359× |
    | 8 | 16 | 512 | footer | 11.80 | 39.60 | 0.298× |
    | 8 | 16 | 512 | inline | 11.00 | 38.70 | 0.284× |
    | 16 | 16 | 512 | footer | 12.70 | 41.10 | 0.309× |
    | 16 | 16 | 512 | inline | 11.80 | 40.30 | 0.293× |
    | 32 | 16 | 512 | footer | 16.80 | 38.70 | 0.434× |
    | 32 | 16 | 512 | inline | 15.70 | 33.00 | 0.476× |
    | 64 | 16 | 512 | footer | 28.20 | 38.90 | 0.725× |
    | 64 | 16 | 512 | inline | 26.20 | 33.10 | 0.792× |
    | 8 | 32 | 512 | footer | 15.90 | 40.10 | 0.397× |
    | 8 | 32 | 512 | inline | 14.70 | 38.80 | 0.379× |
    | 16 | 32 | 512 | footer | 16.80 | 41.30 | 0.407× |
    | 16 | 32 | 512 | inline | 15.90 | 40.30 | 0.395× |
    | 32 | 32 | 512 | footer | 28.40 | 38.90 | 0.730× |
    | 32 | 32 | 512 | inline | 26.20 | 33.10 | 0.792× |
    | 64 | 32 | 512 | footer | 40.90 | 38.70 | 1.057× |
    | 64 | 32 | 512 | inline | 38.30 | 32.90 | 1.164× |
    | 8 | 64 | 512 | footer | 26.40 | 41.20 | 0.641× |
    | 8 | 64 | 512 | inline | 23.90 | 39.70 | 0.602× |
    | 16 | 64 | 512 | footer | 28.60 | 42.10 | 0.679× |
    | 16 | 64 | 512 | inline | 26.40 | 41.30 | 0.639× |
    | 32 | 64 | 512 | footer | 40.90 | 38.70 | 1.057× |
    | 32 | 64 | 512 | inline | 38.30 | 33.10 | 1.157× |
    | 64 | 64 | 512 | footer | 70.60 | 38.60 | 1.829× |
    | 64 | 64 | 512 | inline | 67.80 | 33.70 | 2.012× |
    | 8 | 1024 | 512 | footer | 269.00 | 263.60 | 1.020× |
    | 8 | 1024 | 512 | inline | 263.60 | 255.90 | 1.030× |
    | 16 | 1024 | 512 | footer | 278.80 | 268.50 | 1.038× |
    | 16 | 1024 | 512 | inline | 273.90 | 264.40 | 1.036× |
    | 32 | 1024 | 512 | footer | 566.60 | 252.60 | 2.243× |
    | 32 | 1024 | 512 | inline | 505.30 | 241.30 | 2.094× |
    | 64 | 1024 | 512 | footer | 1169.20 | 441.70 | 2.647× |
    | 64 | 1024 | 512 | inline | 1070.80 | 415.50 | 2.577× |
    | 8 | 1 | 128+fp4 | footer | 13.30 | 50.30 | 0.264× |
    | 8 | 1 | 128+fp4 | inline | 12.50 | 50.10 | 0.250× |
    | 16 | 1 | 128+fp4 | footer | 14.00 | 51.90 | 0.270× |
    | 16 | 1 | 128+fp4 | inline | 13.30 | 51.60 | 0.258× |
    | 32 | 1 | 128+fp4 | footer | 14.30 | 52.00 | 0.275× |
    | 32 | 1 | 128+fp4 | inline | 13.50 | 51.80 | 0.261× |
    | 64 | 1 | 128+fp4 | footer | 14.30 | 52.10 | 0.274× |
    | 64 | 1 | 128+fp4 | inline | 13.50 | 51.80 | 0.261× |
    | 8 | 4 | 128+fp4 | footer | 13.50 | 50.50 | 0.267× |
    | 8 | 4 | 128+fp4 | inline | 12.70 | 50.30 | 0.252× |
    | 16 | 4 | 128+fp4 | footer | 14.30 | 51.90 | 0.276× |
    | 16 | 4 | 128+fp4 | inline | 13.50 | 51.80 | 0.261× |
    | 32 | 4 | 128+fp4 | footer | 14.50 | 52.30 | 0.277× |
    | 32 | 4 | 128+fp4 | inline | 13.70 | 51.90 | 0.264× |
    | 64 | 4 | 128+fp4 | footer | 14.70 | 52.40 | 0.281× |
    | 64 | 4 | 128+fp4 | inline | 14.10 | 51.90 | 0.272× |
    | 8 | 16 | 128+fp4 | footer | 13.50 | 50.70 | 0.266× |
    | 8 | 16 | 128+fp4 | inline | 12.90 | 50.20 | 0.257× |
    | 16 | 16 | 128+fp4 | footer | 14.70 | 52.00 | 0.283× |
    | 16 | 16 | 128+fp4 | inline | 13.90 | 51.80 | 0.268× |
    | 32 | 16 | 128+fp4 | footer | 19.60 | 52.40 | 0.374× |
    | 32 | 16 | 128+fp4 | inline | 18.80 | 52.00 | 0.362× |
    | 64 | 16 | 128+fp4 | footer | 33.80 | 52.60 | 0.643× |
    | 64 | 16 | 128+fp4 | inline | 32.10 | 52.20 | 0.615× |
    | 8 | 32 | 128+fp4 | footer | 18.40 | 50.80 | 0.362× |
    | 8 | 32 | 128+fp4 | inline | 17.60 | 50.30 | 0.350× |
    | 16 | 32 | 128+fp4 | footer | 19.60 | 52.20 | 0.375× |
    | 16 | 32 | 128+fp4 | inline | 19.00 | 52.00 | 0.365× |
    | 32 | 32 | 128+fp4 | footer | 33.80 | 52.50 | 0.644× |
    | 32 | 32 | 128+fp4 | inline | 32.10 | 52.10 | 0.616× |
    | 64 | 32 | 128+fp4 | footer | 61.20 | 52.60 | 1.163× |
    | 64 | 32 | 128+fp4 | inline | 59.40 | 52.20 | 1.138× |
    | 8 | 64 | 128+fp4 | footer | 31.70 | 50.80 | 0.624× |
    | 8 | 64 | 128+fp4 | inline | 30.10 | 50.50 | 0.596× |
    | 16 | 64 | 128+fp4 | footer | 34.00 | 52.40 | 0.649× |
    | 16 | 64 | 128+fp4 | inline | 32.50 | 52.00 | 0.625× |
    | 32 | 64 | 128+fp4 | footer | 61.20 | 52.60 | 1.163× |
    | 32 | 64 | 128+fp4 | inline | 59.40 | 52.20 | 1.138× |
    | 64 | 64 | 128+fp4 | footer | 102.50 | 104.40 | 0.982× |
    | 64 | 64 | 128+fp4 | inline | 102.40 | 103.50 | 0.989× |
    | 8 | 1024 | 128+fp4 | footer | 339.00 | 328.40 | 1.032× |
    | 8 | 1024 | 128+fp4 | inline | 315.00 | 307.60 | 1.024× |
    | 16 | 1024 | 128+fp4 | footer | 347.70 | 326.00 | 1.067× |
    | 16 | 1024 | 128+fp4 | inline | 325.00 | 315.20 | 1.031× |
    | 32 | 1024 | 128+fp4 | footer | 714.20 | 617.80 | 1.156× |
    | 32 | 1024 | 128+fp4 | inline | 600.10 | 568.00 | 1.057× |
    | 64 | 1024 | 128+fp4 | footer | 1476.60 | 1258.00 | 1.174× |
    | 64 | 1024 | 128+fp4 | inline | 1266.40 | 1130.50 | 1.120× |

    </details>

    Customer prefill and Q/KV sweep

    B=1, H=64, D=512, local Q as listed, gathered KV=4×Q. CP=4 partitions Q (interleaved rank 0); each device retains all heads and the full gathered KV. Each query selects up to 128 causal SWA entries and 512 causal sparse entries from the KV/2 compressed pool. Attention sinks are enabled. All columns include Q RoPE, attention, inverse output RoPE and FP8 quantization. Q=4096, KV=16384 is the customer case. Values are milliseconds.

    | Local Q | Gathered KV | Layout | Baseline separate kernels | PR separate kernels | PR mega | Baseline / mega | Baseline / PR separate |
    |---:|---:|---|---:|---:|---:|---:|---:|
    | 256 | 1024 | footer | 0.2073 | 0.1249 | 0.1095 | 1.893× | 1.660× |
    | 256 | 1024 | inline | 0.2051 | 0.1138 | 0.0966 | 2.122× | 1.802× |
    | 512 | 2048 | footer | 0.4704 | 0.2677 | 0.2387 | 1.971× | 1.757× |
    | 512 | 2048 | inline | 0.4655 | 0.2423 | 0.2122 | 2.193× | 1.921× |
    | 1024 | 4096 | footer | 1.1154 | 0.5928 | 0.4667 | 2.390× | 1.882× |
    | 1024 | 4096 | inline | 1.1086 | 0.5461 | 0.4243 | 2.613× | 2.030× |
    | 2048 | 8192 | footer | 2.3721 | 1.2711 | 0.9879 | 2.401× | 1.866× |
    | 2048 | 8192 | inline | 2.3590 | 1.1794 | 0.9202 | 2.563× | 2.000× |
    | 4096 | 16384 | footer | 4.8092 | 2.5546 | 2.0119 | 2.390× | 1.883× |
    | 4096 | 16384 | inline | 4.7634 | 2.3834 | 1.8730 | 2.543× | 1.999× |
    | 8192 | 32768 | footer | 9.7652 | 5.1068 | 4.0554 | 2.408× | 1.912× |
    | 8192 | 32768 | inline | 9.6623 | 4.7985 | 3.7703 | 2.563× | 2.014× |

    Reproduce

    # Backport this PR’s benchmark and sparse_mla_prefill_utils.py to merge-base:
    python -m benchmarks.bench_sparse_mla_sm120 --cuda-graph
    python -m benchmarks.bench_sparse_mla_sm120 --cuda-graph --full-pipeline
    # PR checkout:
    python -m benchmarks.bench_sparse_mla_sm120 --cuda-graph --force-prefill
    python -m benchmarks.bench_sparse_mla_sm120 --cuda-graph --mega
    # Both checkouts; add --mega for the PR fused measurement:
    python -m benchmarks.bench_sparse_mla_sm120 --cuda-graph --customer-q 256 512 1024 2048 4096 8192
    

    🔍 Related Issues

    Stack: main ← this PR ← #9356.

    🚀 Pull Request Checklist

    Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.

    ✅ Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit (or used your preferred method).

  • I have installed the hooks with pre-commit install.

  • I have run the hooks manually with pre-commit run --all-files and fixed any reported issues.
  • If you are unsure about how to set up pre-commit, see the pre-commit documentation.

    🧪 Tests

  • Tests have been added or updated as needed.

  • All related local tests pass: 1237 sparse MLA tests on SM120. Full multi-architecture CI is separate.

  • This PR requires full-scope CI, not targeted tests (expensive; justify below).

  • Reason: <!-- e.g. cross-cutting change to shared infrastructure -->

    Suggested CI test targets (optional; paths under tests/, whitespace-separated — a starting
    point for @flashinfer-bot run <targets> / /bot run <targets>, reviewers may adjust): tests/attention/test_sparse_mla_sm120.py tests/attention/test_sparse_mla_sm120_binding_guards.py tests/attention/test_sparse_mla_sm120_cache_contracts.py tests/attention/test_sparse_mla_sm120_calibration.py tests/attention/test_sparse_mla_sm120_cute_prefill_integration.py tests/attention/test_sparse_mla_sm120_dsv41_inline.py tests/attention/test_sparse_mla_sm120_dsv4_nvfp4.py tests/attention/test_sparse_mla_sm120_execution.py tests/attention/test_sparse_mla_sm120_lse_base.py tests/attention/test_sparse_mla_sm120_policy.py tests/attention/test_sparse_mla_sm120_precision.py tests/attention/test_sparse_mla_sm120_prefill_mega_contract.py

    🔬 Experimental Track

    <!-- Only for PRs submitted under the experimental policy (CONTRIBUTING.md → "Experimental APIs and Backends").
    Leave this section untouched for normal PRs. -->

  • This PR is experimental: it adds or changes code under flashinfer/experimental/ and/or an @flashinfer_experimental_api. Tracking issue: #

  • - [ ] The tracking issue names an owner, the reason for the experimental path, and a graduation plan with a target release.
    - [ ] Core changes are limited to a thin entry point (signature, shared validation, feature-gate check, backend selection, handoff).
    - [ ] Tests live in tests/experimental/ and were validated on the intended hardware; a runnable example is included.
    - [ ] Nothing is registered in flashinfer/aot.py, and no experimental backend is reachable from backend="auto" without FLASHINFER_ALLOW_EXPERIMENTAL_AUTO_BACKENDS=1. (Calling an @flashinfer_experimental_api or naming a backend explicitly is itself the opt-in and needs no environment variable.)
    - [ ] Test scope declared below. The experimental CI lane runs exactly these targets, so keep them as narrow as the change allows.

    <!-- Required for experimental PRs. Replace the commented lines below with your targets.
    Do not delete the fence or change its experimental-tests tag — the experimental-track
    watcher reads it verbatim to decide which targets to ask CI for. -->

    ``experimental-tests

    One target per line: a directory or a file. (A pytest ::selector is not


    supported -- the sharding runner cannot consume one.) Must be under


    tests/experimental/ and must exist. Delete these comment lines and add yours, e.g.


    # tests/experimental/test_my_backend.py


    tests/experimental/my_backend/


    # Declaring the whole tree (tests/experimental/) is allowed but means every


    experimental PR pays for every other feature's tests, in every matrix cell.


    ``

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Added an experimental sparse-attention option that combines RoPE, attention, and FP8 output generation in one operation.
    Added an optimized FP8 prefill path for supported cache layouts and configurations.
    Expanded benchmark options for eager or CUDA Graph timing, prefill selection, and fused or full-pipeline measurements. Some benchmark modes skip unsupported rows or report unavailable timings.
    Documentation
    Added guidance on the experimental fused operation, its input requirements, and CUDA Graph warm-up.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: qsang-nv Review duration: 15784m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #8747"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%