Skip to content

Commit

Permalink
[ROCm] Avoid using the default stream on ROCm (#13238)
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Shtrasberg <[email protected]>
  • Loading branch information
gshtras authored Feb 14, 2025
1 parent e38be64 commit 4108869
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion vllm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,11 +942,16 @@ def current_stream() -> torch.cuda.Stream:
the underlying hypothesis is that we do not call `torch._C._cuda_setStream`
from C/C++ code.
"""
from vllm.platforms import current_platform
global _current_stream
if _current_stream is None:
# when this function is called before any stream is set,
# we return the default stream.
_current_stream = torch.cuda.current_stream()
# On ROCm using the default 0 stream in combination with RCCL
# is hurting performance. Therefore creating a dedicated stream
# per process
_current_stream = torch.cuda.Stream() if current_platform.is_rocm(
) else torch.cuda.current_stream()
return _current_stream


Expand Down

0 comments on commit 4108869

Please sign in to comment.