weight cache: key daemon paths by GPU UUID (#36101)

Co-authored-by: siyu <liusy58@linux.alibaba.com>
Co-authored-by: Alex Nails <alex.nails@radixark.ai>
This commit is contained in:
Tarang Khanna
2026-08-31 01:44:45 -07:00
committed by GitHub
co-authored by siyu Alex Nails
parent 3865efc9f7
commit 6580d5cd9a
11 changed files with 176 additions and 135 deletions
@@ -1145,13 +1145,8 @@ class ModelRunner:
weight_cache_socket=get_model().weight_cache_socket,
)
# If the weight cache is enabled, override the load format to IPC_CACHE
# and derive the per-rank daemon socket. Idempotent across reloads.
maybe_enable_ipc_weight_cache(
load_config=self.load_config,
tp_size=self.ps.tp_size,
pp_rank=self.ps.pp_rank,
tp_rank=self.ps.tp_rank,
)
if self.device == "cpu":
self.model_config = adjust_config_with_unaligned_cpu_tp(
@@ -236,16 +236,13 @@ def build_load_config(
def maybe_enable_ipc_weight_cache(
*,
load_config: LoadConfig,
tp_size: int,
pp_rank: int,
tp_rank: int,
) -> None:
"""Switch ``load_config`` onto the IPC weight-cache path, in place.
Overrides the load format to ``IPC_CACHE`` (remembering the original as the
disk fallback) and derives the per-rank daemon socket if unset. Idempotent:
the format swap is guarded on ``!= IPC_CACHE`` so a second call (e.g. a
weight reload) can't overwrite the captured fallback format.
disk fallback). Idempotent: the format swap is guarded on ``!= IPC_CACHE``
so a second call (e.g. a weight reload) can't overwrite the captured
fallback format.
"""
if get_model().weight_cache_mode == "off":
return
@@ -254,17 +251,6 @@ def maybe_enable_ipc_weight_cache(
load_config.fallback_load_format = load_config.load_format
load_config.load_format = LoadFormat.IPC_CACHE
# Compute socket path using global rank (tp_size * pp_rank + tp_rank) so
# each daemon has a unique socket even across PP stages and nodes.
if load_config.weight_cache_socket is None:
from sglang.srt.weight_cache.protocol import (
compute_global_rank,
get_socket_path,
)
global_rank = compute_global_rank(tp_size, pp_rank, tp_rank)
load_config.weight_cache_socket = get_socket_path(global_rank=global_rank)
def load_model_with_memory_saver(
*,