Repository navigation
[rl] Restore the get_cuda_flash_attention_impl import in the vLLM attention backend - #5908
Conversation
…ention backend The attn-gym MLA decode change removed get_cuda_flash_attention_impl from the torchtitan.tools.utils import, but _FA4PageSize.get_supported_kernel_block_sizes still calls it. Every vLLM generator then fails at engine init with NameError: name 'get_cuda_flash_attention_impl' is not defined.
|
Reply from claude: @claude review |
|
Claude finished @felipemello1's task in 52s —— View job Approve: the PR restores an import that |
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging -- the PR restores an import that _FA4PageSize.get_supported_kernel_block_sizes still needs. Without it, every varlen vLLM generator fails with NameError.
What this PR does. It adds get_cuda_flash_attention_impl back to the torchtitan.tools.utils import in torchtitan/rl/generator/vllm/attention/attention.py. The function is defined at torchtitan/tools/utils.py:40. Its only use in this module is attention.py:69. The CPU tests in tests/rl/unit_tests/cpu/test_vllm_attention.py (lines 39, 60, 80) patch it as vllm_attention.get_cuda_flash_attention_impl, so they need it as a module-level name.
Must fix
- PR description -- the "Summary (human-written)" section is empty. The author fills this in before merge (
CONTRIBUTING.md, "AI-assisted contributions").
Details
- Gate: the problem exists on
main. The name is called atattention.py:69but not imported, so vLLM raises aNameErrorwhen it asks the backend for KV page sizes. The fix is in the right layer and is as small as it can be.mla.py:49imports onlyactivate_cuda_flash_attention_impland does not call the getter, so it is fine. - No new test needed:
test_vllm_attention.pyalready patches this name, so it fails if the import is removed again. The break got through because the branch that removed the import did not yet have the call. - Overlapping work: the only other open PR in this area is #4866 (ROCm paged KV gather). It does not cover this fix.
Not verified: GPU behavior (FA4 returning [128] on SM100). That comes from the author's GB300 run and RL GPU CI.
Summary (human-written)
Agent details
Written with Claude Code.
TLDR: On main, every RL test that starts a vLLM generator with TorchTitan's varlen attention fails with
NameError.c50b0aeae(use attn-gym mla decode kernel) removedget_cuda_flash_attention_implfrom an import, but_FA4PageSize.get_supported_kernel_block_sizesstill calls it. This PR restores the import.Problem
bcab6e87d(128-token KV pages when FA4 runs attention) added the call in_FA4PageSize.get_supported_kernel_block_sizes.c50b0aeaemoved the file's only other call intoactivate_cuda_flash_attention_impl. On its branch the import looked unused, so it was removed.c50b0aeae, four RL workflows fail on every main commit because of the missing import:NameError.test_vllm_attention.pyfail withAttributeError: they patch a name the module no longer has.Solution: restore the import. Nothing else changes.
NOTE: RL Integration Tests (A10G) stays red for a second reason. The 2026-11-06 PyTorch nightly changed the losses that its loss check expects. The PR stacked on this one updates the saved losses (
tests/assets/losses/rl_grpo_cuda.txt).Test plan
pytest tests/rl/unit_tests/cpu/test_vllm_attention.py: 11 failed on main (AttributeError: noget_cuda_flash_attention_implto patch). 11 passed with this PR.pytest tests/rl/unit_tests/cpu --ignore=tests/rl/unit_tests/cpu/test_vllm_wrapper.py: 546 passed, 8 skipped. The ignored file needsattn_gym.mla, which my attention-gym does not have.TorchTitanVarlenInnerAttentionBackend.get_supported_kernel_block_sizes()returns[128](FA4).c50b0aeae. Expected: RL CPU Unit, RL GPU Unit and RL H100 Integration pass. RL Integration Tests (A10G) stays red until the stacked PR lands.