Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions python/sglang/srt/layers/moe/token_dispatcher/moriep.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
from dataclasses import dataclass
from typing import TYPE_CHECKING, List, NamedTuple, Optional, Tuple

from sglang.srt.eplb.expert_distribution import get_global_expert_distribution_recorder
from sglang.srt.eplb.expert_distribution import (
_ExpertDistributionRecorderNoop,
get_global_expert_distribution_recorder,
)
from sglang.srt.layers.dp_attention import get_is_extend_in_batch
from sglang.srt.layers.moe.token_dispatcher.base import (
BaseDispatcher,
Expand Down Expand Up @@ -53,7 +56,15 @@

def _should_record_expert_distribution() -> bool:
recorder = get_global_expert_distribution_recorder()
return recorder.recording or torch.get_device_module().is_current_stream_capturing()
if recorder.recording:
return True
# While capturing, only bake in the count kernel if a recorder is actually
# configured (non-Noop); otherwise it would replay as dead work every decode
# step. Configured recorders still bake it in, so start_record() works after
# capture.
if torch.get_device_module().is_current_stream_capturing():
return not isinstance(recorder, _ExpertDistributionRecorderNoop)
return False


class MoriEPPDispatchHooks(DeepEPPDispatchHooks):
Expand Down
Loading