Files
xc-llm-ascend/vllm_ascend/worker/v2/utils.py

21 lines
615 B
Python
Raw Normal View History

from contextlib import contextmanager
import torch
@contextmanager
def torch_cuda_wrapper():
try:
torch.cuda.Event = torch.npu.Event
torch.cuda.Stream = torch.npu.Stream
torch.cuda.stream = torch.npu.stream
torch.cuda.default_stream = torch.npu.default_stream
torch.cuda.current_stream = torch.npu.current_stream
torch.cuda.graph_pool_handle = torch.npu.graph_pool_handle
torch.cuda.CUDAGraph = torch.npu.NPUGraph
torch.cuda.graph = torch.npu.graph
torch.cuda.synchronize = torch.npu.synchronize
yield
finally:
pass