From 2815eed49c94dbc3266fb5dc4b01c61fc8eb73ca Mon Sep 17 00:00:00 2001 From: amote-i <49533125+amote-i@users.noreply.github.com> Date: Wed, 21 Oct 2026 19:44:30 +0800 Subject: [PATCH] [Fix] [NPU] pre_warm_nccl: init npu backend before the parallel runtime touches a device (#43039) --- python/sglang/srt/distributed/bootstrap.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/sglang/srt/distributed/bootstrap.py b/python/sglang/srt/distributed/bootstrap.py index 6b3932995d..f2c6d205cf 100644 --- a/python/sglang/srt/distributed/bootstrap.py +++ b/python/sglang/srt/distributed/bootstrap.py @@ -114,6 +114,12 @@ def init_parallel_runtime( tic = time.perf_counter() logger.info("Init parallel begin.") + # NPU: install transfer_to_npu to route torch.cuda.* to torch.npu.* + if is_npu(): + from sglang.srt.hardware_backend.npu.utils import init_npu_backend + + init_npu_backend() + backend = _resolve_backend(device=device) if not get_parallel().enable_p2p_check: monkey_patch_p2p_access_check()