diff --git a/vllm_ascend/worker.py b/vllm_ascend/worker.py index d1e0765a..bcb6bdeb 100644 --- a/vllm_ascend/worker.py +++ b/vllm_ascend/worker.py @@ -22,7 +22,6 @@ import torch import torch.distributed -import torch_npu from torch import nn from vllm import envs from vllm.config import ParallelConfig, VllmConfig @@ -124,6 +123,8 @@ def __init__( # Torch profiler. Enabled and configured through env vars: # VLLM_TORCH_PROFILER_DIR=/path/to/save/trace if envs.VLLM_TORCH_PROFILER_DIR: + # lazy import so that torch_npu is not required for normal use. + import torch_npu torch_profiler_trace_dir = envs.VLLM_TORCH_PROFILER_DIR logger.info("Profiling enabled. Traces will be saved to: %s", torch_profiler_trace_dir)