Skip to content

[ROCm] Fix broken import in platform attention backend dispatching#30432

Merged
gshtras merged 2 commits intovllm-project:mainfrom
ROCm:fix/rocm-attn-dispatching
Dec 11, 2025
Merged

[ROCm] Fix broken import in platform attention backend dispatching#30432
gshtras merged 2 commits intovllm-project:mainfrom
ROCm:fix/rocm-attn-dispatching

Conversation

@AndreasKaratzas
Copy link
Copy Markdown
Collaborator

@AndreasKaratzas AndreasKaratzas commented Dec 10, 2025

Summary

Removes broken dependency on get_env_variable_attn_backend from vllm.attention.selector in ROCm platform configuration.

Problem

The import from vllm.attention.selector import get_env_variable_attn_backend was causing failures on ROCm. This was used to check for ROCM_AITER_UNIFIED_ATTN backend selection when setting KV cache block size.

Fix

Deprecate the get_env_variable_attn_backend check and rely on environment variables (VLLM_ROCM_USE_AITER_UNIFIED_ATTENTION, VLLM_ROCM_USE_AITER) directly for block size configuration.

Tracking upstream PR #30396 for the proper way to handle attention backend selection going forward.

Testing

Verified ROCm platform initializes correctly without import errors.

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
@mergify mergify bot added the rocm Related to AMD ROCm label Dec 10, 2025
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a broken import in the ROCm platform configuration by replacing a call to get_env_variable_attn_backend with direct environment variable checks. While this resolves the import issue, the new implementation for checking environment variables is inconsistent with how boolean flags are handled elsewhere in the codebase, which could lead to incorrect behavior. I've provided a suggestion to align the implementation with the project's standards.

Comment on lines +407 to +408
os.environ.get("VLLM_ROCM_USE_AITER_UNIFIED_ATTENTION")
and os.environ.get("VLLM_ROCM_USE_AITER")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The direct use of os.environ.get() to check for these boolean environment variables is inconsistent with the established pattern in vllm.envs. This can lead to incorrect behavior. For instance, if a user sets VLLM_ROCM_USE_AITER=0 to disable it, os.environ.get() will return the string "0", which is truthy, causing the block size to be incorrectly set to 64.

To ensure consistent and correct behavior, you should use the vllm.envs module, which is already imported in this file. This module correctly parses these environment variables as booleans.

Suggested change
os.environ.get("VLLM_ROCM_USE_AITER_UNIFIED_ATTENTION")
and os.environ.get("VLLM_ROCM_USE_AITER")
envs.VLLM_ROCM_USE_AITER_UNIFIED_ATTENTION
and envs.VLLM_ROCM_USE_AITER

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is out of the scope of this PR. We can address it in a future PR. For now the purpose of this PR is to resolve an import error and deprecate get_env_variable_attn_backend

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the bot is right, don't use os.environ

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

Comment on lines +407 to +408
os.environ.get("VLLM_ROCM_USE_AITER_UNIFIED_ATTENTION")
and os.environ.get("VLLM_ROCM_USE_AITER")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the bot is right, don't use os.environ

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
@gshtras gshtras enabled auto-merge (squash) December 10, 2025 22:53
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Dec 10, 2025
@gshtras gshtras merged commit b51255f into vllm-project:main Dec 11, 2025
46 of 47 checks passed
@AndreasKaratzas AndreasKaratzas deleted the fix/rocm-attn-dispatching branch December 11, 2025 01:14
Majid-Taheri pushed a commit to Majid-Taheri/vllm that referenced this pull request Dec 23, 2025
…llm-project#30432)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Signed-off-by: Ubuntu <mjtaheri68@gmail.com>
dsuhinin pushed a commit to dsuhinin/vllm that referenced this pull request Jan 21, 2026
…llm-project#30432)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Signed-off-by: dsuhinin <suhinin.dmitriy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed rocm Related to AMD ROCm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants