[dsv4] support eplb (#25948)
Co-authored-by: xutizhou <xutingz@nvidia.com>
This commit is contained in:
@@ -7,6 +7,9 @@ import torch
|
|||||||
from torch import nn
|
from torch import nn
|
||||||
|
|
||||||
from sglang.srt.environ import envs
|
from sglang.srt.environ import envs
|
||||||
|
from sglang.srt.eplb.expert_distribution import (
|
||||||
|
get_global_expert_distribution_recorder,
|
||||||
|
)
|
||||||
from sglang.srt.eplb.expert_location_dispatch import (
|
from sglang.srt.eplb.expert_location_dispatch import (
|
||||||
ExpertLocationDispatchInfo,
|
ExpertLocationDispatchInfo,
|
||||||
topk_ids_logical_to_physical,
|
topk_ids_logical_to_physical,
|
||||||
@@ -145,6 +148,7 @@ class HashTopK(nn.Module):
|
|||||||
|
|
||||||
topk_ids = topk_ids_logical_to_physical(topk_ids, expert_location_dispatch_info)
|
topk_ids = topk_ids_logical_to_physical(topk_ids, expert_location_dispatch_info)
|
||||||
_mask_topk_ids_padded_region(topk_ids, num_token_non_padded)
|
_mask_topk_ids_padded_region(topk_ids, num_token_non_padded)
|
||||||
|
get_global_expert_distribution_recorder().on_select_experts(topk_ids=topk_ids)
|
||||||
topk_output = StandardTopKOutput(
|
topk_output = StandardTopKOutput(
|
||||||
topk_weights=topk_weights, topk_ids=topk_ids, router_logits=router_logits
|
topk_weights=topk_weights, topk_ids=topk_ids, router_logits=router_logits
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
from contextlib import nullcontext
|
||||||
from typing import (
|
from typing import (
|
||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
Iterable,
|
Iterable,
|
||||||
@@ -33,6 +34,7 @@ from sglang.srt.distributed import (
|
|||||||
get_tp_group,
|
get_tp_group,
|
||||||
)
|
)
|
||||||
from sglang.srt.environ import envs
|
from sglang.srt.environ import envs
|
||||||
|
from sglang.srt.eplb.expert_distribution import get_global_expert_distribution_recorder
|
||||||
from sglang.srt.eplb.expert_location import ModelConfigForExpertLocation
|
from sglang.srt.eplb.expert_location import ModelConfigForExpertLocation
|
||||||
from sglang.srt.layers.attention.dsa.utils import (
|
from sglang.srt.layers.attention.dsa.utils import (
|
||||||
can_dsa_cp_split,
|
can_dsa_cp_split,
|
||||||
@@ -1269,6 +1271,12 @@ class DeepseekV4Model(nn.Module):
|
|||||||
|
|
||||||
for i in range(self.start_layer, self.end_layer):
|
for i in range(self.start_layer, self.end_layer):
|
||||||
layer = self.layers[i]
|
layer = self.layers[i]
|
||||||
|
ctx = (
|
||||||
|
nullcontext()
|
||||||
|
if not get_global_server_args().disable_piecewise_cuda_graph
|
||||||
|
else get_global_expert_distribution_recorder().with_current_layer(i)
|
||||||
|
)
|
||||||
|
with ctx:
|
||||||
hidden_states = layer(
|
hidden_states = layer(
|
||||||
positions=positions,
|
positions=positions,
|
||||||
hidden_states=hidden_states,
|
hidden_states=hidden_states,
|
||||||
|
|||||||
Reference in New Issue
Block a user