[ROCm][CI] Fix order-dependent failure in test_flash_attn_accepts_handled_fp8_variants (MI355) - #49329
Merged
AndreasKaratzas merged 2 commits intoJul 21, 2026
Conversation
…dled_fp8_variants test_flash_attn_accepts_handled_fp8_variants[fp8|fp8_e4m3] passed in isolation but failed when the full test_attention_selector.py ran on the Kernels (B200-MI355) group. The fp8 accept/reject decision is made in fa_utils.flash_attn_supports_kv_cache_dtype, which reads fa_utils' own module-level current_platform binding. The test patched is_xpu on flash_attn's binding instead; earlier tests that patch vllm.platforms.current_platform can leave the two module bindings pointing at different platform objects depending on import order, so the patch had no effect and is_xpu() stayed False. Patch is_xpu on the fa_utils binding (the actual decision site) to be order-robust. Test-only change; monkeypatch is function-scoped and auto-reverts. Surfaced by vllm-project#46080 (routed the full file into the MI355 group and enabled an earlier ROCm test under a patched platform); fragile patch target dates to vllm-project#42685. Signed-off-by: Stefan Koncarevic <Stefan.Koncarevic@amd.com>
stefankoncarevic
requested review from
AndreasKaratzas,
WoosukKwon,
mgoin,
tlrmchlsmth,
yewentao256 and
zyongye
as code owners
July 21, 2026 12:57
4 tasks
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.
Purpose
tests/kernels/attention/test_attention_selector.py::test_flash_attn_accepts_handled_fp8_variants[fp8|fp8_e4m3]fails on the
Kernels (B200-MI355)CI group when the file is run in full, whilepassing when the two cases are run in isolation:
This is a test-ordering bug, not a production regression.
Root cause
The test verifies that
FlashAttentionBackendacceptsfp8/fp8_e4m3onplatforms that support them. On ROCm these dtypes are genuinely unsupported
(
get_flash_attn_version()returnsNone), so the test simulates XPU bypatching
is_xputo returnTrue.The accept/reject decision is made in
vllm/v1/attention/backends/fa_utils.py::flash_attn_supports_kv_cache_dtype:Because a Python function resolves globals from its own defining module,
this reads
fa_utils.current_platform— regardless of who calls it.FlashAttentionBackend.supports_kv_cache_dtypesimply delegates to that helperand never reads
is_xpuitself.The original test patched
is_xpuonflash_attn.current_platform(a differentmodule's binding).
current_platformis a lazily-resolved singleton exposed viavllm.platforms.__getattr__, and each module captures its own reference atimport time (
from vllm.platforms import current_platform). Earlier tests in thefile run
with patch("vllm.platforms.current_platform", RocmPlatform())andtrigger backend imports inside that context, which can leave
fa_utilsandflash_attnbound to different platform objects depending on import order. Whenthey diverge, patching
flash_attn's binding has no effect on the objectfa_utilsactually checks, sois_xpu()staysFalseand the assertion fails.In isolation the two bindings are the same object, so the original patch happens
to work — hence the isolated-pass / full-file-fail behavior.
Why it started failing now
Introduced by #46080 ("[Hardware][AMD][CI] Fix Kernels Attention test groups"),
which (a) routed the full
test_attention_selector.pyinto theKernels (B200-MI355)group, and (b) madetest_non_causal_backend_selectionrun on ROCm (previously skipped when
CudaPlatform is None) underpatch("vllm.platforms.current_platform", RocmPlatform()). That exposed thepre-existing fragile patch target added in #42685.
Fix
Patch
is_xpuon the binding the decision actually uses (fa_utils), which isorder-robust:
This is a test-only change; no kernel or runtime code is modified. The
monkeypatchfixture is function-scoped and auto-reverts, so no state leaks toother tests or groups.
Test Plan
On a gfx950 (MI355) host inside the ROCm test image:
Test Result
Before: full-file run fails the two
fp8/fp8_e4m3cases (isolated run passes).After:
Notes
flash_attn/fa_utilsat the top ofthe test module before any
patch("vllm.platforms.current_platform", ...)soall bindings point at the real singleton. That addresses the broader
contamination class but is more invasive and relies on import-ordering
guarantees; the targeted patch above is the minimal correct change.
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.