Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@
from vllm.attention.backends.abstract import AttentionBackend
from vllm.attention.selector import (backend_name_to_enum,
get_global_forced_attn_backend)
from vllm.platforms import _Backend, current_platform
from vllm.platforms import current_platform

from vllm_ascend.utils import vllm_version_is

if vllm_version_is("0.11.0"):
from vllm.platforms import _Backend
else:
from vllm.attention.backends.registry import _Backend
Comment on lines +29 to +34
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The use of vllm_version_is with an exact version match is brittle for ensuring compatibility across different vllm versions. This logic implies that only version 0.11.0 uses the old import path, while all other versions (both older and newer) use the new one, which is an unlikely scenario for an API migration.

A more robust and idiomatic Python pattern for handling moved imports is to use a try...except ImportError block. This approach is independent of version string formats (which can be inconsistent, especially for development builds) and directly verifies the import's availability.

Suggested change
from vllm_ascend.utils import vllm_version_is
if vllm_version_is("0.11.0"):
from vllm.platforms import _Backend
else:
from vllm.attention.backends.registry import _Backend
try:
# In recent vLLM versions, _Backend was moved to the backends registry.
from vllm.attention.backends.registry import _Backend
except ImportError:
# Fallback to the old location for older vLLM versions.
from vllm.platforms import _Backend


from vllm.utils import resolve_obj_by_qualname


Expand Down
Loading