Skip to content

Conversation

youkaichao
Copy link
Member

Users only need to use with graph_capture() to manage the context when they capture the graph, before the graph can be replayed.

Inside the capture, we need to turn on graph mode. Outside the capture, there is no need to call graph mode.

Therefore, these two functions can be merged into one.

ensure_model_parallel_initialized(2, 2)
tensor = torch.ones(16, 1024, 1024, dtype=torch.float32, device=device)
with graph_mode():
with graph_capture():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here, how do we make sure it's not using custom all reduce?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, even before this PR, we cannot make sure it's not using custom all reduce. It is true in CI because our CI does not have custom allreduce.

To solve this problem, another refactor is needed. We need to expose a new function to create tp groups with different communicators. That's my next PR to come!

@youkaichao youkaichao requested a review from WoosukKwon May 14, 2024 23:54
@youkaichao youkaichao requested a review from WoosukKwon May 15, 2024 05:51
Comment on lines +17 to +19
@dataclass
class GraphCaptureContext:
stream: torch.cuda.Stream
Copy link
Collaborator

Choose a reason for hiding this comment

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

How does this work for non-CUDA backends?

Copy link
Member Author

Choose a reason for hiding this comment

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

For XPU, this will be torch.xpu.Stream .

Copy link
Collaborator

@WoosukKwon WoosukKwon left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for addressing my comments!

@youkaichao youkaichao merged commit e081880 into vllm-project:main May 16, 2024
@youkaichao youkaichao deleted the graph branch May 17, 2024 00:48
robertgshaw2-redhat pushed a commit to neuralmagic/nm-vllm that referenced this pull request May 19, 2024
dtrifiro pushed a commit to dtrifiro/vllm that referenced this pull request May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants