-
-
Notifications
You must be signed in to change notification settings - Fork 20.4k
[TurboQuant] enable FA3/FA4 for prefill paths #40092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
839d499
7b3b90f
13d9523
e65bf3a
a74b840
fefea99
dce084e
4ea1078
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ | |
| MultipleOf, | ||
| ) | ||
| from vllm.v1.attention.backends.fa_utils import ( | ||
| get_flash_attn_version, | ||
| is_flash_attn_varlen_func_available, | ||
| ) | ||
| from vllm.v1.attention.backends.utils import split_decodes_and_prefills | ||
|
|
@@ -271,6 +272,9 @@ | |
| self._val_data_bytes = math.ceil(head_size * cfg.effective_value_quant_bits / 8) | ||
| self._n_centroids = cfg.n_centroids if not cfg.key_fp8 else 1 | ||
|
|
||
| # Detect flash-attn version (FA2/3/4) for prefill paths. | ||
| self.fa_version = get_flash_attn_version(head_size=head_size) | ||
|
Comment on lines
+275
to
+276
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This new FA-version selection path only calls Useful? React with 👍 / 👎. |
||
|
|
||
| # Fixed NUM_KV_SPLITS (grid dims must be constant for cudagraph, | ||
| # and benchmarks show no regression vs dynamic in eager mode). | ||
| vllm_config = get_current_vllm_config() | ||
|
|
@@ -513,6 +517,7 @@ | |
| max_seqlen_k=attn_metadata.max_query_len, | ||
| softmax_scale=self.scale, | ||
| causal=True, | ||
| fa_version=self.fa_version, | ||
|
Check failure on line 520 in vllm/v1/attention/backends/turboquant_attn.py
|
||
| ) | ||
|
|
||
| # Continuation or no flash_attn: per-request attention. | ||
|
|
@@ -562,6 +567,7 @@ | |
| max_seqlen_k=q_len, | ||
| softmax_scale=self.scale, | ||
| causal=True, | ||
| fa_version=self.fa_version, | ||
|
Check failure on line 570 in vllm/v1/attention/backends/turboquant_attn.py
|
||
| ) | ||
| else: | ||
| q_t = q_seq.transpose(0, 1).contiguous() | ||
|
|
@@ -736,6 +742,7 @@ | |
| max_seqlen_k=seq_len, | ||
| softmax_scale=self.scale, | ||
| causal=True, | ||
| fa_version=self.fa_version, | ||
|
Check failure on line 745 in vllm/v1/attention/backends/turboquant_attn.py
|
||
| ) | ||
| else: | ||
| # SDPA fallback: expand KV for GQA, build causal mask | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to
get_flash_attn_versionshould include therequires_alibiargument. Passingrequires_alibi=alibi_slopes is not Noneensures that the backend correctly falls back to FlashAttention 2 if ALiBi slopes are present, as FA3 and FA4 do not currently support them. This maintains consistency with the version detection logic used inFlashAttentionImpl.