Repository navigation
[Refactor] Replace hardcoded CUDA device selection with platform-agnostic API - #4496
Merged
hsliuustc0106 merged 2 commits intoJun 23, 2026
Merged
Conversation
…stic API
Replace all `torch.device("cuda" if torch.cuda.is_available() else "cpu")`
and similar patterns with `current_omni_platform.get_torch_device()`
This enables the same code to work on non-CUDA platforms (XPU, NPU) without
per-model changes, using the existing platform abstraction layer.
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Nick Cao <ncao@redhat.com>
NickCao
requested review from
ZeldaHuang,
gcanlin,
linyueqian,
princepride,
tzhouam and
yuanheng-zhao
as code owners
June 16, 2026 19:39
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
| @@ -198,7 +199,7 @@ def _ensure_s3_model(cls): | |||
| ) from e | |||
|
|
|||
Collaborator
There was a problem hiding this comment.
Good move to use platform-agnostic device selection
| @@ -57,7 +58,7 @@ def init_device(self): | |||
| f"be less than or equal to the number of visible devices " | |||
Collaborator
There was a problem hiding this comment.
Consistent platform-agnostic device selection - good
Collaborator
hsliuustc0106
left a comment
Collaborator
There was a problem hiding this comment.
Posting one inline finding from review.
Collaborator
|
cc @gcanlin |
hsliuustc0106
enabled auto-merge (squash)
June 22, 2026 14:50
Fall back to torch.device("cpu") instead of raising
NotImplementedError, so helper paths that used to run on
CPU keep working when no accelerator platform is resolved.
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Nick Cao <ncao@redhat.com>
auto-merge was automatically disabled
June 22, 2026 14:56
Head branch was pushed to by a user without write access
Joshna-Medisetty
added a commit
to Joshna-Medisetty/vllm-omni
that referenced
this pull request
Jul 29, 2026
Replace hardcoded torch.cuda.* calls in the async output builder with the torch.accelerator.* / generic torch.Event / torch.Stream equivalents that the repo already mandates (pyproject banned-api; PRs vllm-project#3365, vllm-project#4496). This unblocks the AR model-runner warm-up path on XPU (and other non-CUDA accelerators) without relying on the XPU torch.cuda shim. Signed-off-by: Joshna Medisetty <joshna.medisetty@intel.com>
khairulkabir1661
pushed a commit
to khairulkabir1661/vllm-omni
that referenced
this pull request
Sep 25, 2026
…stic API (vllm-project#4496) Signed-off-by: Nick Cao <ncao@redhat.com>
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
Replace all
torch.device("cuda" if torch.cuda.is_available() else "cpu")and similar patterns withcurrent_omni_platform.get_torch_device()This enables the same code to work on non-CUDA platforms (XPU, NPU) without per-model changes, using the existing platform abstraction layer.
Test Plan
N/A, behavior remains the same as long as
torch.cuda.is_available()returns true (since we don't support cpu platform, it's supposed to be always true)vLLM Version:
vLLM-Omni Commit:
Test Result
BEFORE SUBMITTING: read CONTRIBUTING.md and run the precheck-pr skill with the code agent for a self-check against project conventions.
(anything written below this line will be removed by GitHub Actions)