Skip to content

[data/llm] Fix PrepareMultimodalStage GPU detection on CPU-only nodes - #64048

Closed
Vedika-Sd wants to merge 2 commits into
ray-project:masterfrom
Vedika-Sd:fix/cpu-gpu-detection
Closed

[data/llm] Fix PrepareMultimodalStage GPU detection on CPU-only nodes#64048
Vedika-Sd wants to merge 2 commits into
ray-project:masterfrom
Vedika-Sd:fix/cpu-gpu-detection

Conversation

@Vedika-Sd

Copy link
Copy Markdown

Description

This PR fixes the PrepareMultimodalStage crash on CPU-only nodes by checking GPU availability before creating vLLM's ModelConfig.

Changes

  • Check if GPU is available using torch.cuda.is_available() before creating ModelConfig
  • On CPU-only nodes, set gpu_memory_utilization=0.0 to prevent GPU detection crash
  • This allows multimodal processing to work seamlessly on CPU-only deployments

Fixes

Fixes #64004

- Check if GPU is available before creating vLLM ModelConfig
- On CPU-only nodes, set gpu_memory_utilization=0.0 to prevent GPU detection crash
- Fixes ray-project#64004

Signed-off-by: Vedika Sardeshmukh <vedikasardeshmukh7@gmail.com>
@Vedika-Sd
Vedika-Sd requested a review from a team as a code owner June 12, 2026 05:09

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

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.

Code Review

This pull request aims to prevent GPU detection crashes on CPU-only nodes during the multimodal preparation stage by setting gpu_memory_utilization to 0.0 when no GPU is detected. The reviewer suggested a simplification: since this stage is CPU-only and does not run the actual engine, we can safely default gpu_memory_utilization to 0.0 if not specified, completely avoiding the need to import torch and check for GPU availability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread python/ray/llm/_internal/batch/stages/prepare_multimodal_stage.py Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Vedika Sardeshmukh <vedikasardeshmukh7@gmail.com>
@ray-gardener ray-gardener Bot added data Ray Data-related issues llm community-contribution Contributed by the community labels Jun 12, 2026
@kouroshHakha

Copy link
Copy Markdown
Contributor

Hi @Vedika-Sd , Is the problem that when you instantiate ModelConfig object from vllm on cpu machine it fails? If so, shouldn't the fix live on vllm side?

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jul 3, 2026
@Vedika-Sd

Copy link
Copy Markdown
Author

Thanks @kouroshHakha

You’re right that the immediate failure is tied to vLLM initialization. In this path, though Ray is the caller during multimodal stage preparation and Ray can hit that path on CPU-only nodes even when GPU execution is not required.
So this PR keeps Ray-side behavior safe by guarding/defering GPU-specific detection in PrepareMultimodalStage, so CPU-only nodes don’t fail early, while preserving behavior on GPU nodes.

I agree there may also be a complementary upstream improvement in vLLM, but Ray should still handle this integration path defensively for heterogeneous clusters.

@github-actions github-actions Bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Jul 5, 2026
Comment on lines +41 to +45
if "gpu_memory_utilization" not in model_config_kwargs:
model_config_kwargs = {
**model_config_kwargs,
"gpu_memory_utilization": 0.0,
}

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.

Agree with @kouroshHakha -- this seems like a band-aid fix to me. Let's fix it more fundamentally in vLLM or seek for a different approach here.

@jeffreywang88

Copy link
Copy Markdown
Contributor

Closing this PR as #64015 addresses the same issue. Thanks for taking a stab anyways!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community data Ray Data-related issues llm unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[data/llm] PrepareMultimodalStage crashes on CPU-only nodes due to vllm.config.ModelConfig GPU detection

3 participants