Skip to content

Commit

Permalink
lazy import torch_npu
Browse files Browse the repository at this point in the history
Signed-off-by: wangli <wangli858794774@gmail.com>
  • Loading branch information
Potabk committed Feb 27, 2025
1 parent 9448377 commit 7283f4c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion vllm_ascend/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7283f4c

Please sign in to comment.