Repository navigation
Conversation
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
jhaotingc
force-pushed
the
gemma4-fa4-all-layers-sm90-fp8
branch
2 times, most recently
from
October 23, 2026 23:58
397f59d to
81f81b6
Compare
jhaotingc
force-pushed
the
gemma4-fa4-all-layers-sm90-fp8
branch
from
October 25, 2026 05:27
81f81b6 to
dd3c7f6
Compare
jhaotingc
marked this pull request as ready for review
October 25, 2026 06:49
jhaotingc
requested review from
LucasWilkinson and
MatthewBonanni
as code owners
October 25, 2026 06:49
jhaotingc
force-pushed
the
gemma4-fa4-all-layers-sm90-fp8
branch
from
October 31, 2026 12:03
dd3c7f6 to
7877731
Compare
jhaotingc
requested review from
TheEpicDolphin,
WoosukKwon,
njhill and
yewentao256
as code owners
November 3, 2026 06:35
jhaotingc
force-pushed
the
gemma4-fa4-all-layers-sm90-fp8
branch
2 times, most recently
from
November 3, 2026 08:01
0276d1e to
1feacf8
Compare
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
FA4's SM90 native FP8 forward (vllm-project/flash-attention#206) runs attention on E4M3 Q/K/V with FP8 WGMMA. Use it for FP8 KV cache on SM90. - get_flash_attn_version upgrades FA3 to FA4 on SM90 when the KV cache is FP8 E4M3 and FA4 supports the head size (64, 96, 128, 192 or 256, same for V), without softcap or batch invariance. An explicitly requested flash_attn_version is kept. The FlashAttention metadata builder and impl pass fp8_kv_cache. - Gemma4Config uses FA4 for all layers by default, including SM90 with FP8 KV cache, so its d256 sliding-window layers no longer run on FA3. - SM90 FA4 supports FP8 KV for equal head sizes 64, 96, 128, 192, 256 and 512. - Only d512 keeps BF16/FP16 Q for the FP8-KV dequant path. Smaller heads quantize Q, as FA3 does, and run the native FP8 forward. The FA4 wrapper applies its d512 FP8-KV checks only to BF16/FP16 Q. - The FlashAttention FP8 KV checks use KVQuantMode.FP8_PER_TENSOR instead of matching the cache dtype string, as the metadata builder only has the KV cache spec. - test_flash_attn_sm90_fp8_mma_selection now expects FA4 for d256 with an FP8 KV cache, and no longer expects the FA4 wrapper to reject FP8 Q. The FlashAttention pin is updated once vllm-project/flash-attention#206 is merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jhao-Ting Chen <jhaotingc@nvidia.com>
vLLM passes per-tensor FP8 scales to FlashAttention as scale.expand(num_reqs, num_kv_heads), whose strides are 0, and the FA4 wrapper copies every such descale to a contiguous tensor. vllm-project#63232 passes no descale for a unit scale, but calibrated scales are still copied. FA4's SM90 native FP8 forward takes broadcast descales as they are, so on that path the copies only add one small kernel per descale to every attention call. Skip the copies when FA4 runs SM90 native FP8 (FP8 Q). The FP8-KV dequant path (BF16/FP16 Q, head size 512) and other architectures still copy. Before vllm-project#63232, Gemma4-12B with a DSpark drafter on H200 launched 120 copy kernels per target verify step for its 40 sliding-window layers, about 138 us; calibrated scales still cost the same. FA4 outputs are bit-identical with broadcast and contiguous descales, and gemma-4-31B-it-FP8 GSM8k is unchanged at 94.54. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jhao-Ting Chen <jhaotingc@nvidia.com>
jhaotingc
force-pushed
the
gemma4-fa4-all-layers-sm90-fp8
branch
from
November 6, 2026 05:19
1feacf8 to
90e466a
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
On SM90 with an FP8 KV cache, this PR runs attention on FA4's native FP8 forward from vllm-project/flash-attention#206, which computes attention on E4M3 Q/K/V with FP8 WGMMA:
get_flash_attn_versionupgrades FA3 to FA4 on SM90 when the KV cache is FP8 E4M3 and FA4 supports the head size: 64, 96, 128, 192 or 256, with the same V head size, no softcap and no batch invariance. An explicitly setflash_attn_versionis kept.mainruns Gemma4's sliding-window layers on FA3 and its full-attention layers on FA4. This PR uses FA4 for all layers, as Gemma4 already does in other configurations:main's FA4 FP8-KV path with BF16 Q.The FlashAttention pin is bumped once vllm-project/flash-attention#206 merges.
Claims
mainon the8k-in-1k-outbenchmark ofgemma_4_31b_it_h200. This PR runs with [Cute,Fwd,Sm90] Native FP8 (E4M3 Q/K/V) forward for Hopper flash-attention#206, which is based on FlashAttentionmain. There the head-dim-512 FP8-KV kernel that bothmainand this PR use for the full-attention layers is about 40% slower than at vLLM's current pin, so this PR's number includes that slowdown andmain's does not.mainand BF16 within noise.Validation
Serving. The
8k-in-1k-outbenchmark ofgemma_4_31b_it_h200on one H200 at TP=1. Each row is the median of 3 runs on the same GPU; no request failed.mainAccuracy. gemma-4-31B-it-FP8 on 4x H200 at TP=1/DP=4. Sampling is temperature 1.0 and top_p 0.95, with thinking on.
mainAfter rebasing on
mainwith #60372, this PR's GSM8k is 94.54 ± 0.63.Reproduce
Accuracy server. The evals call it directly:
simple_evals. The GPQA answer regex also acceptsAnswer: $X. AIME is graded by an LLM judge.simple_evalswith one pass.lm-evalgsm8k_cot_zeroshotover chat completions, scored by flexible-extract. The system prompt asks for a final line ofThe answer is X.Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.