From 7283f4ca0e2f80a03a73429680e2cc0a70dbd233 Mon Sep 17 00:00:00 2001 From: wangli Date: Thu, 27 Feb 2025 01:48:18 +0000 Subject: [PATCH] lazy import torch_npu Signed-off-by: wangli --- vllm_ascend/worker.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)