Support updating expert locations dynamically (#6388)

This commit is contained in:
fzyzcjy
2025-05-22 12:59:33 +08:00
committed by GitHub
parent 121f92c583
commit fc992a09f9
5 changed files with 723 additions and 0 deletions

View File

@@ -22,6 +22,7 @@ import torch.distributed
import torch.nn.functional as F
from sglang.srt.configs.model_config import ModelConfig
from sglang.srt.managers import deepseek_eplb
from sglang.srt.model_loader import get_model_architecture
from sglang.srt.server_args import ServerArgs
@@ -207,6 +208,26 @@ class ExpertLocationMetadata:
),
)
# -------------------------------- mutation ------------------------------------
def update(
self,
other: "ExpertLocationMetadata",
):
for field in [
"ep_size",
]:
assert getattr(self, field) == getattr(other, field)
for field in [
"physical_to_logical_map",
"logical_to_all_physical_map",
"logical_to_all_physical_map_num_valid",
"logical_to_rank_dispatch_physical_map",
]:
dst = getattr(self, field)
dst[...] = getattr(other, field)
# -------------------------------- usage ------------------------------------
def logical_to_all_physical(