Skip to content

[Refactor] Replace hardcoded CUDA device selection with platform-agnostic API - #4496

Merged
hsliuustc0106 merged 2 commits into
vllm-project:mainfrom
NickCao:worktree-remove-cuda-hardcodes
Jun 23, 2026
Merged

hsliuustc0106 merged 2 commits into
vllm-project:mainfrom
NickCao:worktree-remove-cuda-hardcodes

Conversation

@NickCao

@NickCao NickCao commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Purpose

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.

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)

…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>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@@ -198,7 +199,7 @@ def _ensure_s3_model(cls):
) from e

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.

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 "

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.

Consistent platform-agnostic device selection - good

@hsliuustc0106

Copy link
Copy Markdown
Collaborator

@gcanlin

@hsliuustc0106 hsliuustc0106 left a comment

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.

Posting one inline finding from review.

Comment thread vllm_omni/model_executor/models/fish_speech/dac_encoder.py
@hsliuustc0106 hsliuustc0106 added the Hardware Plugin support different hardware beyond cuda label Jun 19, 2026
@hsliuustc0106

Copy link
Copy Markdown
Collaborator

cc @gcanlin

@hsliuustc0106 hsliuustc0106 added the ready label to trigger buildkite CI label Jun 22, 2026

@hsliuustc0106 hsliuustc0106 left a comment

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.

lgtm,

@hsliuustc0106
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

@NickCao
NickCao requested a review from hsliuustc0106 June 22, 2026 14:57
@hsliuustc0106
hsliuustc0106 merged commit 67d14b5 into vllm-project:main Jun 23, 2026
2 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hardware Plugin support different hardware beyond cuda ready label to trigger buildkite CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants