Skip to content

[ROCm][CI] Fix cuda graph mem profile issue - #48764

Merged
AndreasKaratzas merged 2 commits into
vllm-project:mainfrom
charlifu:amd/fix_cuda_graph_issue
Jul 16, 2026
Merged

AndreasKaratzas merged 2 commits into
vllm-project:mainfrom
charlifu:amd/fix_cuda_graph_issue

Conversation

@charlifu

Copy link
Copy Markdown
Contributor

Root cause

During determine_available_memoryprofile_cudagraph_memory, capture runs inside torch.cuda.graph(). PyTorch requires a non-default stream (cuda_stream != 0).

On ROCm, the profiling path was using:

GraphCaptureContext(torch.cuda.current_stream(self.device))
Before vLLM initializes its dedicated compute stream, torch.cuda.current_stream() is the per-thread default stream (cuda_stream=0). That object is not torch.cuda.default_stream() by identity, but PyTorch still rejects it for graph capture — which matches your error:

RuntimeError: CUDA graphs must be captured on a non-default stream.

Fix

Use vLLM's current_stream() instead. It creates a dedicated non-default compute stream (the same one used for normal inference), which:

Satisfies PyTorch's cudagraph capture requirement
Preserves the ROCm intent of profiling on the compute stream, not a throwaway side stream from graph_capture()

Signed-off-by: charlifu <charlifu@amd.com>
@charlifu
charlifu requested a review from njhill as a code owner July 15, 2026 18:13

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added nvidia rocm Related to AMD ROCm v1 labels Jul 15, 2026
@github-project-automation github-project-automation Bot moved this to Todo in AMD Jul 15, 2026
@AndreasKaratzas AndreasKaratzas added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 15, 2026

@AndreasKaratzas AndreasKaratzas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Thanks for fixing this.

@github-project-automation github-project-automation Bot moved this to Ready in NVIDIA Jul 15, 2026
@AndreasKaratzas
AndreasKaratzas enabled auto-merge (squash) July 15, 2026 22:19
@AndreasKaratzas
AndreasKaratzas merged commit 6a9f24a into vllm-project:main Jul 16, 2026
88 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in NVIDIA Jul 16, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in AMD Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants