매일 아침, 어제의 AI를 한 통으로 정리해 보내드립니다메일로 받아보기

METAL LAB

FlashPrefill V2: Block-Sparse Prefill Attention for Long-Context LLM Serving

arXiv:2608.197582026-08-21

논문 속 시연이 아니라 실제 서비스에 넣을 수 있는 희소 어텐션 만들기

FlashPrefill V2는 긴 문맥을 가진 LLM이 답변을 시작하기 전 프롬프트 전체를 처리하는 무거운 단계에서, 덜 중요한 계산 블록을 건너뛰어 속도를 높이면서도 정확도 손실을 억제하는 보정을 추가했다. 최신 Hopper GPU 최적화 기법과 FP8 저정밀 연산으로 커널 자체를 다시 짰고, SGLang의 페이지 단위 메모리 관리와 배치 처리 방식에 바로 꽂아 쓸 수 있게 만들었다. H20 GPU에서 128K 길이 문맥 기준 FlashAttention-2 대비 최대 47.26배 빨라졌고, 정확도 손실은 미미했다.

무엇을 했나

  1. 문제: 어텐션 연산량은 문맥 길이의 제곱에 비례해 늘어나고, 그중에서도 답변 생성 전 프롬프트 전체를 미리 처리하는 프리필 단계가 연산량이 가장 크다. 이전 연구 FlashPrefill은 중요하지 않은 블록을 건너뛰어 속도를 높였지만, 희소하게(적게) 계산할수록 정확도가 크게 떨어지고 실제 서빙 시스템과 맞지 않았다.
  2. 해결 1(정확도): 건너뛴 블록을 그냥 버리는 대신, 각 블록의 키·값을 평균으로 요약한 값을 소프트맥스 계산에 다시 더해주는 평균 보정을 도입해, 추가 연산 부담 없이 손실된 확률 질량 대부분을 복구한다.
  3. 해결 2(속도): FlashAttention-3/4에서 쓰인 기법인 PackGQA 메모리 접근, 워프 특화, 핑퐁 파이프라이닝을 Hopper GPU에 맞춰 커널을 새로 설계했고, 8비트 저정밀 연산인 FP8 추론도 지원한다.
  4. 해결 3(배포 적합성): vLLM에서 쓰이는 방식인 페이지 단위 KV 캐시와 여러 요청을 섞어 처리하는 연속 배칭을 기본적으로 지원해, 모델을 바꾸지 않고도 SGLang 같은 서빙 프레임워크에 어텐션 백엔드로 바로 통합할 수 있다.
  5. 결과: NVIDIA H20 GPU에서 128K 문맥 기준 FlashAttention-2 대비 FP8은 최대 47.26배, BF16은 27.19배 빨라졌고, 최신 FA3/4 정렬 밀집 베이스라인 대비로도 30.49배 빨랐다. 실제 SGLang 서빙에서는 첫 토큰 생성 시간이 최대 4.8배 줄었고, RULER와 LongBench 평가에서 전체 어텐션 대비 정확도 손실은 약 1~2점 수준에 그쳤다.
Figure 1: FlashPrefill V2 evolves FlashPrefill [8] from an algorithmic prototype toward practical long-context serving along three dimensions: (1) a mean correction term that preserves model accuracy under extreme sparsity; (2) an FA3/4-aligned sparse attention kernel with PackGQA memory access, warp specialization, pingpong pipelining, and FP8 support; and (3) native compatibility with paged KV cache and continuous batching for integration as an attention backend in modern serving frameworks such as SGLang [42].
Figure 1: FlashPrefill V2 evolves FlashPrefill [8] from an algorithmic prototype toward practical long-context serving along three dimensions: (1) a mean correction term that preserves model accuracy under extreme sparsity; (2) an FA3/4-aligned sparse attention kernel with PackGQA memory access, warp specialization, pingpong pipelining, and FP8 support; and (3) native compatibility with paged KV cache and continuous batching for integration as an attention backend in modern serving frameworks such as SGLang [42].
Table 1: RULER scores (left) and attention operator speedups over FlashAttention-2 (right) at sequence lengths from 4K to 128K. The speedups are measured end-to-end on needle-in-a-haystack inputs, including pattern discovery, thresholding, and mean correction. Results marked with ∗ (in gray) are measured with direct online FP8 quantization without corrected weights.
MethodRULER ScoreOperator Speedup over FA2
4K8K16K32K64K128KAvg.4K8K16K32K64K128K
Llama-3.1-8B-Instruct
Full95.9894.7493.0789.0686.2773.8288.821.00×1.00×1.00×1.00×1.00×1.00×
MInference95.0694.2392.1887.6883.0171.6187.300.12×0.18×0.46×0.83×1.34×2.45×
FlexPrefill95.1894.0992.3586.7984.0872.0187.420.12×0.33×0.98×2.21×4.16×5.18×
XAttention95.2494.3791.6187.0383.6572.3387.370.79×1.29×1.83×2.34×3.19×3.48×
FlashPrefill95.1694.2992.1187.4984.1870.9187.361.21×2.38×4.31×7.46×13.62×22.67×
FlashPrefill V295.5294.6592.9588.4883.0772.0887.791.66×2.62×4.28×7.63×14.39×27.21×
FlashPrefill V2-FP8∗95.2894.4892.7888.8080.2867.7886.572.67×4.56×7.79×13.89×25.76×47.33×
Qwen3-4B-Instruct-2507
Full94.8292.9891.6888.8682.8171.2287.061.00×1.00×1.00×1.00×1.00×1.00×
MInference94.0692.1891.0988.0782.0868.0185.920.11×0.15×0.42×0.83×1.32×2.53×
FlexPrefill93.8190.9691.4187.6281.3767.2485.400.12×0.33×0.99×2.28×4.01×5.27×
XAttention94.4291.4991.4287.3181.5668.2485.740.81×1.35×1.92×2.38×3.07×3.43×
FlashPrefill94.7192.0491.2887.2981.0869.0285.901.21×2.40×4.36×6.91×11.54×19.26×
FlashPrefill V294.4992.4291.5687.4881.6769.7686.231.72×2.82×4.63×7.92×13.93×27.45×
FlashPrefill V2-FP894.1392.3791.3687.4780.5968.9785.822.75×4.87×8.40×14.44×25.06×47.59×
Qwen3-30B-A3B-Instruct-2507
Full95.7895.2394.3692.7290.1184.1292.051.00×1.00×1.00×1.00×1.00×1.00×
MInference95.7194.3393.8192.0189.0282.0991.160.11×0.17×0.46×0.83×1.43×2.76×
FlexPrefill95.3294.7193.5291.8188.0983.1191.090.12×0.34×0.98×2.31×3.92×5.43×
XAttention95.4394.1292.7891.0688.3982.2390.670.86×1.44×2.01×2.42×2.95×3.42×
FlashPrefill95.6294.4793.2892.1788.1482.9691.111.22×2.43×4.36×6.92×11.45×18.67×
FlashPrefill V295.3594.8594.1992.4889.8883.8391.761.75×2.95×4.62×8.21×14.11×27.19×
FlashPrefill V2-FP895.2894.5394.1292.3489.5482.5591.392.78×5.12×8.41×14.93×25.36×47.26×
Figure 2: Speedup of various attention operators relative to FlashAttention-2 [5] on NVIDIA H20 GPUs, including an FA3/4-aligned dense baseline [22, 38]. All results are measured with a batch size of 4. FlashPrefill V2 exhibits a dominant advantage, particularly in long-context scenarios, and its FP8 variant further amplifies the gains.
Figure 2: Speedup of various attention operators relative to FlashAttention-2 [5] on NVIDIA H20 GPUs, including an FA3/4-aligned dense baseline [22, 38]. All results are measured with a batch size of 4. FlashPrefill V2 exhibits a dominant advantage, particularly in long-context scenarios, and its FP8 variant further amplifies the gains.
Table 2: Performance comparison on all 21 tasks of LongBench [2], grouped by task category. Results marked with ∗ (in gray) are measured with direct online FP8 quantization without corrected weights.
MethodSingle-Document QAMulti-Document QASummarizationFew-shot LearningSyntheticCodeAvg.
NarrQAQasperMF-enMF-zhHotpot2WikiMuSiQueDuReadGovRepQMSumMNewsVCSumTRECTQASAMSumLSHTCountPR-enPR-zhLCC
Llama-3.1-8B-Instruct
Full29.3944.6156.3463.6357.4848.0832.2834.4334.5125.2926.8017.3772.5091.4843.5946.5011.10100.0090.45
MInference28.1342.3653.6762.0856.2846.7232.0133.4133.2825.1627.0216.8469.5090.8342.8743.006.0096.0084.00
FlexPrefill27.6242.6752.9862.3457.1445.3230.9733.7233.8724.5826.3417.0267.5090.3644.7243.006.0094.0083.33
XAttention28.5243.1254.0160.1956.7345.9832.1733.1534.5525.3727.2117.4171.0091.3744.0544.006.8895.5085.68
FlashPrefill28.3142.8954.2361.9757.0145.7631.9633.6034.0224.8326.4717.1371.0091.1244.2146.507.0095.5083.45
FlashPrefill V230.2144.5655.9762.3758.0248.8432.5733.7834.9025.2427.1317.3772.5091.4544.7645.507.3997.0089.47
FlashPrefill V2-FP8∗29.0845.5154.7062.5955.4146.4032.0332.9734.7024.8826.9717.6170.0091.1644.8045.006.8896.5085.68
Qwen3-4B-Instruct-2507
Full27.9744.9851.1264.5959.3944.1824.8526.1730.6822.6223.9311.7374.0087.7445.5544.000.75100.0098.04
MInference25.8941.6948.2662.1654.1742.7622.1624.8929.1221.9823.1511.2872.0087.6244.3242.500.0091.0094.67
FlexPrefill25.2641.4848.0261.9854.9643.2122.7125.4330.9422.1524.4711.4770.5086.1845.8741.000.5094.0094.20
XAttention24.3142.6749.0163.0254.1443.1422.5625.1229.6322.4123.6811.5672.5086.4745.1341.500.0096.0093.89
FlashPrefill25.0642.7849.2262.3155.0742.9723.4225.6629.8022.0923.3211.6272.0087.9545.4242.000.0092.0094.00
FlashPrefill V227.5643.7351.0763.7256.3943.1123.1826.3630.4822.6723.8811.7674.0087.7445.7841.250.5096.0097.17
FlashPrefill V2-FP826.5542.7050.2861.7155.2141.9524.5026.0330.7422.4724.0711.4873.5088.1645.8941.250.5093.0094.67
Qwen3-30B-A3B-Instruct-2507
Full31.2944.0954.7966.4863.8656.5632.2924.6431.1021.9023.4811.0976.5091.0145.7951.0016.50100.00100.00
MInference28.6241.0853.0664.2861.2151.0131.7123.5230.5321.0722.7910.7275.0090.1644.9646.005.0095.0097.67
FlexPrefill28.0740.9652.4164.0760.7250.9131.6523.9730.0221.6223.8610.8875.5089.3746.3848.504.5097.0096.00
XAttention27.9842.8652.8363.8260.9353.1633.0123.8131.3121.2822.9310.9773.0091.1445.9247.503.0097.0099.00
FlashPrefill28.3541.1153.3464.8161.2751.0930.0824.1130.5521.7423.2111.0277.0090.6846.1246.505.0096.5099.00
FlashPrefill V229.7441.5853.8266.8063.6652.6234.1124.9431.0022.0423.4511.1377.0090.9946.5949.006.5099.5099.50
FlashPrefill V2-FP830.0341.3755.2866.3161.4051.8330.6324.5831.1921.6223.5610.9677.5089.6146.0847.508.5098.0099.00
Figure 3: The FlashPrefill V2 prefill pipeline. Stage 1 packs queries with PackGQA, pools block-mean statistics, and produces a CSR index of selected blocks in a single fused pass; Stage 2 runs the warp-specialized sparse attention kernel over the selected blocks (exact path) while the unselected blocks are compensated through the mean correction path (Sec. 3.2), and the two streams merge inside the online softmax.
Figure 3: The FlashPrefill V2 prefill pipeline. Stage 1 packs queries with PackGQA, pools block-mean statistics, and produces a CSR index of selected blocks in a single fused pass; Stage 2 runs the warp-specialized sparse attention kernel over the selected blocks (exact path) while the unselected blocks are compensated through the mean correction path (Sec. 3.2), and the two streams merge inside the online softmax.
Table 3: Attention density of FlashPrefill V2 measured on needle-in-a-haystack inputs at each sequence length.
Model4K8K16K32K64K128K
Llama-3.1-8B76.0%54.2%33.6%18.7%9.0%4.6%
Qwen3-4B72.0%48.5%29.8%17.6%9.2%4.9%
Qwen3-30B-A3B70.4%46.0%29.6%16.2%9.4%4.9%
Figure 4: Mean correction. Selected blocks (red) are computed exactly, while each pruned block is pooled into its mean statistics (k¯J,v¯J) and contributes a surrogate term |ℬJ|​es¯J​(v¯J,1) to the softmax numerator and denominator, recovering the discarded probability mass without per-token computation.
Figure 4: Mean correction. Selected blocks (red) are computed exactly, while each pruned block is pooled into its mean statistics (k¯J,v¯J) and contributes a surrogate term |ℬJ|​es¯J​(v¯J,1) to the softmax numerator and denominator, recovering the discarded probability mass without per-token computation.
Table 4: End-to-end time-to-first-token (TTFT, seconds) of Llama-3.1-8B-Instruct, Qwen3-4B-Instruct-2507, and Qwen3-30B-A3B-Instruct-2507 served by SGLang on the needle-in-a-haystack workload. Each entry is averaged over 30 repeated measurements. Parenthesized numbers are speedups over the FA3/4 backend.
BSZFA3/4FlashPrefill V2FlashPrefill V2-FP8
4K8K16K32K64K128K4K8K16K32K64K128K4K8K16K32K64K128K
Llama-3.1-8B-Instruct
10.150.290.631.493.9511.810.15 (1.02×)0.29 (1.02×)0.58 (1.09×)1.17 (1.28×)2.46 (1.60×)5.49 (2.15×)0.10 (1.53×)0.18 (1.63×)0.35 (1.81×)0.71 (2.09×)1.48 (2.66×)3.23 (3.66×)
40.581.172.545.9412.3032.940.57 (1.01×)1.14 (1.03×)2.32 (1.09×)4.79 (1.24×)7.69 (1.60×)15.39 (2.14×)0.35 (1.66×)0.68 (1.73×)1.36 (1.87×)2.80 (2.12×)4.49 (2.74×)8.84 (3.73×)
81.072.214.879.8321.2356.671.06 (1.01×)2.14 (1.03×)4.39 (1.11×)7.77 (1.27×)13.18 (1.61×)26.13 (2.17×)0.67 (1.58×)1.39 (1.59×)2.81 (1.73×)4.51 (2.18×)7.66 (2.77×)14.93 (3.80×)
162.603.858.1416.1037.12102.842.58 (1.01×)3.59 (1.07×)7.31 (1.11×)12.56 (1.28×)22.93 (1.62×)46.96 (2.19×)1.44 (1.80×)2.97 (1.30×)4.62 (1.76×)7.28 (2.21×)13.25 (2.80×)26.82 (3.83×)
Qwen3-4B-Instruct-2507
10.090.190.431.133.3511.100.09 (1.02×)0.18 (1.07×)0.36 (1.19×)0.77 (1.47×)1.71 (1.96×)4.12 (2.70×)0.07 (1.42×)0.12 (1.61×)0.23 (1.87×)0.49 (2.33×)1.08 (3.09×)2.44 (4.55×)
40.350.741.694.3510.6131.470.35 (1.01×)0.69 (1.06×)1.43 (1.18×)3.06 (1.42×)5.38 (1.97×)11.55 (2.72×)0.22 (1.59×)0.43 (1.72×)0.88 (1.93×)1.86 (2.34×)3.26 (3.25×)6.73 (4.67×)
80.641.383.257.4018.2553.840.63 (1.02×)1.29 (1.07×)2.70 (1.20×)5.05 (1.47×)9.19 (1.99×)19.35 (2.78×)0.43 (1.49×)0.87 (1.59×)1.78 (1.82×)3.06 (2.42×)5.51 (3.31×)11.28 (4.77×)
161.072.315.5312.2031.7397.261.05 (1.02×)2.15 (1.08×)4.56 (1.21×)8.18 (1.49×)15.84 (2.00×)34.48 (2.82×)0.90 (1.18×)1.83 (1.26×)2.95 (1.87×)4.92 (2.48×)9.43 (3.37×)20.13 (4.83×)
Qwen3-30B-A3B-Instruct-2507
10.100.190.451.264.0013.780.09 (1.02×)0.18 (1.09×)0.36 (1.26×)0.78 (1.61×)1.75 (2.29×)4.17 (3.30×)0.09 (1.06×)0.15 (1.24×)0.30 (1.50×)0.61 (2.07×)1.32 (3.03×)3.00 (4.59×)
40.260.731.764.8613.0540.440.24 (1.09×)0.67 (1.10×)1.42 (1.24×)3.11 (1.56×)5.70 (2.29×)12.16 (3.33×)0.22 (1.18×)0.57 (1.29×)1.15 (1.53×)2.41 (2.01×)4.21 (3.10×)8.59 (4.71×)
80.641.353.368.4722.3768.560.62 (1.03×)1.22 (1.11×)2.65 (1.27×)5.25 (1.61×)9.69 (2.31×)20.35 (3.37×)0.55 (1.15×)1.02 (1.32×)2.11 (1.59×)4.03 (2.10×)7.13 (3.14×)14.35 (4.78×)
161.163.145.9013.9838.50123.231.15 (1.01×)2.92 (1.08×)4.60 (1.28×)8.49 (1.65×)16.55 (2.33×)36.21 (3.40×)1.04 (1.12×)1.73 (1.81×)3.66 (1.61×)6.47 (2.16×)12.16 (3.17×)25.51 (4.83×)
Figure 5: Block-sparse attention latency at 64K sequence length in FP8. HPC-BSA does not support BF16, so only FP8 is compared. Both sparse operators track the theoretical bound; FlashPrefill V2 is 6 to 7% faster than HPC-BSA at every sparsity level.
Figure 5: Block-sparse attention latency at 64K sequence length in FP8. HPC-BSA does not support BF16, so only FP8 is compared. Both sparse operators track the theoretical bound; FlashPrefill V2 is 6 to 7% faster than HPC-BSA at every sparsity level.
Table 5: Open-loop serving results on Qwen3-4B-Instruct-2507 and Qwen3-30B-A3B-Instruct-2507 under Poisson arrivals with mixed prompt lengths (4K–128K RULER needle-in-a-haystack, 100 requests per cell, 64 output tokens each). Parenthesized numbers are speedups over the FA3/4 backend.
Rate (req/s)BackendTTFT (s)TPOT (ms)Throughput
P50P99P50P99(tok/s)(req/s)
Qwen3-4B-Instruct-2507
1FA3/476.73154.64419117024.00.37
FlashPrefill V217.23 (4.45x)48.73 (3.17x)258 (1.62x)601 (1.94x)45.5 (1.90x)0.71
FlashPrefill V2-FP82.79 (27.47x)17.27 (8.95x)47 (8.84x)487 (2.40x)58.4 (2.44x)0.91
4FA3/479.05161.54513110223.80.37
FlashPrefill V242.28 (1.87x)80.34 (2.01x)258 (1.99x)509 (2.16x)47.3 (1.99x)0.74
FlashPrefill V2-FP824.47 (3.23x)46.05 (3.51x)165 (3.10x)331 (3.33x)82.3 (3.46x)1.29
8FA3/479.55161.01463111023.90.37
FlashPrefill V243.83 (1.81x)80.12 (2.01x)236 (1.96x)523 (2.12x)48.3 (2.03x)0.76
FlashPrefill V2-FP825.83 (3.08x)46.24 (3.48x)152 (3.05x)302 (3.68x)82.2 (3.45x)1.28
16FA3/481.91160.99481111023.80.37
FlashPrefill V243.22 (1.90x)78.68 (2.05x)263 (1.83x)501 (2.21x)48.9 (2.05x)0.76
FlashPrefill V2-FP825.14 (3.26x)45.16 (3.56x)152 (3.17x)285 (3.89x)85.5 (3.59x)1.34
Qwen3-30B-A3B-Instruct-2507
1FA3/490.69195.43582133519.90.31
FlashPrefill V217.63 (5.14x)52.15 (3.75x)241 (2.42x)604 (2.21x)44.5 (2.24x)0.70
FlashPrefill V2-FP87.93 (11.44x)21.92 (8.91x)102 (5.69x)637 (2.10x)56.1 (2.82x)0.88
4FA3/4101.44195.33462131219.90.31
FlashPrefill V246.26 (2.19x)85.57 (2.28x)255 (1.81x)520 (2.52x)45.5 (2.29x)0.71
FlashPrefill V2-FP830.62 (3.31x)57.43 (3.40x)198 (2.33x)407 (3.22x)64.6 (3.25x)1.01
8FA3/4105.52195.34481133319.90.31
FlashPrefill V245.73 (2.31x)83.04 (2.35x)234 (2.05x)529 (2.52x)47.0 (2.36x)0.73
FlashPrefill V2-FP833.17 (3.18x)58.46 (3.34x)165 (2.92x)369 (3.62x)66.9 (3.36x)1.05
16FA3/499.68195.20547134719.90.31
FlashPrefill V245.20 (2.21x)81.95 (2.38x)266 (2.06x)514 (2.62x)47.4 (2.38x)0.74
FlashPrefill V2-FP832.47 (3.07x)57.33 (3.40x)185 (2.95x)359 (3.75x)67.7 (3.41x)1.06
Figure 6: Overhead of mean correction at 64K sequence length. The corrected variants (dashed) stay close to the uncorrected ones (solid) in both BF16 and FP8, and the absolute overhead shrinks as sparsity increases.
Figure 6: Overhead of mean correction at 64K sequence length. The corrected variants (dashed) stay close to the uncorrected ones (solid) in both BF16 and FP8, and the absolute overhead shrinks as sparsity increases.
Table 6: Open-loop serving at 16 req/s with chunked prefill at chunk sizes of 8K and 16K (same workload as Tab. 5, where chunking is disabled). Parenthesized numbers are speedups over the FA3/4 backend at the same chunk size.
Chunk sizeBackendTTFT (s)TPOT (ms)Throughput
P50P99P50P99(tok/s)(req/s)
Qwen3-4B-Instruct-2507
8KFA3/480.98165.14597122822.50.35
FlashPrefill V250.15 (1.61x)95.23 (1.73x)360 (1.66x)684 (1.80x)38.7 (1.72x)0.60
FlashPrefill V2-FP833.47 (2.42x)61.20 (2.70x)259 (2.30x)529 (2.32x)60.7 (2.70x)0.95
16KFA3/479.42161.96580120322.90.36
FlashPrefill V245.09 (1.76x)85.47 (1.89x)315 (1.84x)615 (1.96x)43.9 (1.91x)0.69
FlashPrefill V2-FP826.80 (2.96x)50.34 (3.22x)193 (3.00x)382 (3.15x)73.3 (3.20x)1.15
Qwen3-30B-A3B-Instruct-2507
8KFA3/496.61199.39693149418.70.29
FlashPrefill V279.81 (1.21x)149.52 (1.33x)574 (1.21x)1200 (1.24x)24.6 (1.32x)0.38
FlashPrefill V2-FP863.23 (1.53x)121.53 (1.64x)505 (1.37x)1009 (1.48x)29.2 (1.56x)0.46
16KFA3/494.78195.84672146619.00.30
FlashPrefill V246.47 (2.04x)88.15 (2.22x)323 (2.08x)652 (2.25x)42.1 (2.21x)0.66
FlashPrefill V2-FP833.72 (2.81x)62.19 (3.15x)250 (2.69x)464 (3.16x)57.1 (3.00x)0.89
Table 7: Design comparison with the HPC-Ops block-sparse attention kernel. Index memory is evaluated at batch size 1 with 32 query heads and 4 KV heads: the dense mask stores one byte per (query head, 128-token Q tile, 128-token KV tile) regardless of density, whereas the CSR index stores only the selected 64-token tiles as int32 at the measured needle-in-a-haystack densities (Tab. 3), is organized per KV head under PackGQA, and matches the SGLang index format. The fused correction path has no counterpart in HPC-Ops BSA.
HPC-Ops BSAFlashPrefill V2
Sparse index formatdense mask, padded, per Q headCSR of selected blocks, per KV head
Index memory @ 64K / 128K8 MB / 32 MB (any density)3 MB / 6 MB (9% / 5% density)
GEMM–softmax overlapserialintra-warpgroup pingpong
Paged KV addressingper-page TMA (page size ∣ 128)cp.async, arbitrary page size
KV splittingnonecount-balanced CSR splits
Mean correctionnonefused into the mainloop
PrecisionFP8 onlyBF16 + FP8
Table 8: Ablation of the mean correction term on RULER with Qwen3-4B-Instruct-2507, in both BF16 and FP8. Discarding unselected blocks without compensation degrades accuracy increasingly toward longer contexts, while the zero-order correction stays close to full attention at all lengths in both precisions.
Method4K8K16K32K64K128KAvg.
Full Attention94.8292.9891.6888.8682.8171.2287.06
V2 w/o correction94.3892.0691.1887.2180.9268.8685.77
FlashPrefill V294.4992.4291.5687.4881.6769.7686.23
V2-FP8 w/o correction93.7891.8290.6885.0476.8662.7883.49
FlashPrefill V2-FP894.1392.3791.3687.4780.5968.9785.82
Table 9: Ablation of the selection threshold α on RULER at 64K with Qwen3-4B-Instruct-2507 in FP8. Density is the fraction of selected attention blocks. Red numbers are the score drops of the uncorrected variant relative to the corrected pipeline at the same α. Full attention scores 82.81.
α0.20.10.050.0250.0125
Density (%)5.29.214.119.823.6
V2-FP8 w/o correction74.68(−5.44)76.86(−3.73)77.16(−3.51)77.41(−3.31)78.02(−2.73)
FlashPrefill V2-FP880.1280.5980.6780.7280.75

왜 중요한가

긴 문맥 LLM 서비스는 프롬프트 처리 단계의 어텐션 비용이 병목인데, 정확도 손실을 거의 없이 이 비용을 수십 배 줄이는 커널은 긴 문서나 긴 대화를 다루는 LLM 서비스의 지연 시간과 비용을 직접적으로 낮춘다. 페이지 단위 KV 캐시와 연속 배칭 같은 실제 서빙 인프라에 그대로 통합되므로, 연구용 벤치마크에 그치지 않고 엔지니어가 실제로 가져다 쓸 수 있는 수준에 가깝다.

이 논문의 용어

  • 프리필(Prefill) · 모델이 첫 출력 토큰을 만들기 전 입력 프롬프트 전체를 처리하는 단계로, 긴 입력일수록 연산 부담이 크다.
  • FlashAttention-2/3/4 · GPU에서 어텐션 연산을 빠르게 처리하도록 세대별로 최적화된 커널 시리즈.
  • FP8 · 8비트로 표현하는 부동소수점 형식으로, 정확도를 약간 희생하는 대신 연산 속도와 메모리 사용량을 줄인다.
  • 페이지 단위 KV 캐시 · vLLM에서 대중화된 방식으로, 어텐션에 쓰이는 키·값을 하나의 연속된 덩어리가 아니라 고정 크기 페이지 단위로 나눠 관리하는 메모리 기법.
  • 연속 배칭(continuous batching) · 여러 사용자의 요청 처리 단계를 섞어서 GPU를 계속 바쁘게 돌리는 서빙 기법.
  • 첫 토큰 생성 시간(TTFT) · 사용자가 요청을 보낸 뒤 모델이 첫 글자를 내놓기까지 걸리는 시간.

논문 원문 초록 (영문)

Long-context modeling is a pivotal capability for Large Language Models, yet the quadratic complexity of attention remains a critical bottleneck, particularly during the compute-intensive prefilling phase. Our previous work, FlashPrefill, mitigates this cost through instantaneous pattern discovery and max-based dynamic thresholding; however, it remains an algorithmic prototype that is still distant from production deployment. In this paper, we present FlashPrefill V2, which evolves FlashPrefill from a prototype toward practical long-context serving along three dimensions. First, we introduce a mean correction term that effectively suppresses the approximation error, keeping performance degradation manageable even at extreme sparsity levels. Second, we redesign the sparse attention operator with PackGQA memory access, warp specialization, and pingpong pipelining, fully aligning with the latest FlashAttention-3/4 implementations and supporting FP8 inference to meet practical quantization requirements. Third, FlashPrefill V2 natively supports paged KV cache and continuous batching, allowing integration as an attention backend in modern inference frameworks such as SGLang. Extensive evaluations on NVIDIA H20 GPUs---among the most widely deployed inference accelerators---demonstrate that FlashPrefill V2 delivers up to 47.26x and 27.19x speedups over FlashAttention-2 at 128K context length under FP8 and BF16 precision, respectively, and, in FP8, still achieves a 30.49x speedup against an FA3/4-aligned dense baseline.

저자 · Qihang Fan, Huaibo Huang, Zhiying Wu, Bingning Wang, Ran He

arXiv에서 원문 보기

최신 논문

논문 전체 보기 →

METAL LAB 최신 기사

그림 출처: Qihang Fan et al., arXiv:2608.19758, arxiv-nonexclusive