Fix device context during NIXL backend initialization (#38774)
Co-authored-by: Aurick Qiao <6137920+aurickq@users.noreply.github.com>
This commit is contained in:
co-authored by
Aurick Qiao
parent
a3bf25dc62
commit
7b7620774c
@@ -12,6 +12,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple
|
||||
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
import torch
|
||||
import zmq
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -48,7 +49,7 @@ from sglang.srt.disaggregation.utils import (
|
||||
slice_dsa_tail_dst_ptrs_for_pp,
|
||||
)
|
||||
from sglang.srt.environ import envs
|
||||
from sglang.srt.runtime_context import get_parallel, get_schedule
|
||||
from sglang.srt.runtime_context import get_device, get_parallel, get_schedule
|
||||
from sglang.srt.server_args import ServerArgs
|
||||
from sglang.srt.utils.common import run_with_deadline
|
||||
|
||||
@@ -472,8 +473,13 @@ class NixlKVManager(StagingManagerMixin, CommonKVManager):
|
||||
backend_params.setdefault("thread_count", str(num_threads))
|
||||
elif backend == "UCCL":
|
||||
backend_params.setdefault("num_cpus", str(num_threads))
|
||||
|
||||
def create_backend():
|
||||
torch.get_device_module(get_device().device).set_device(self.kv_args.gpu_id)
|
||||
return self.agent.create_backend(backend, backend_params)
|
||||
|
||||
run_with_deadline(
|
||||
lambda: self.agent.create_backend(backend, backend_params),
|
||||
create_backend,
|
||||
timeout_s=envs.SGLANG_DISAGGREGATION_ENGINE_INIT_TIMEOUT.get(),
|
||||
what=f"NIXL create_backend({backend!r}, {backend_params})",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user