[fix] Skip routed expert capture for draft model under spec v2 (#26980)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
7e63feee6f
commit
e4bf0043fe
@@ -192,6 +192,7 @@ from sglang.srt.state_capturer.indexer_topk import (
|
||||
)
|
||||
from sglang.srt.state_capturer.routed_experts import (
|
||||
RoutedExpertsCapturer,
|
||||
disable_routed_experts_capture_for_draft,
|
||||
get_global_experts_capturer,
|
||||
set_global_experts_capturer,
|
||||
)
|
||||
@@ -699,6 +700,11 @@ class ModelRunner(ModelRunnerKVCacheMixin):
|
||||
self.load_model()
|
||||
self._prepare_moe_topk()
|
||||
|
||||
# Must run before backend/graph init so no draft graph records a
|
||||
# routed-experts capture-write kernel.
|
||||
if self.is_draft_worker:
|
||||
disable_routed_experts_capture_for_draft(self.model)
|
||||
|
||||
# Load the expert backup client
|
||||
self.expert_backup_client = (
|
||||
ExpertBackupClient(self.server_args, self)
|
||||
@@ -960,6 +966,12 @@ class ModelRunner(ModelRunnerKVCacheMixin):
|
||||
self.model_config.full_attention_layer_ids = full_attention_layer_ids
|
||||
|
||||
def init_routed_experts_capturer(self):
|
||||
if self.is_draft_worker:
|
||||
# Capture is target-only. The draft worker runs in the same process
|
||||
# as its target and inits after it, so installing a capturer here
|
||||
# would overwrite the target's process-global one.
|
||||
return
|
||||
|
||||
if not self.server_args.disable_shared_experts_fusion and hasattr(
|
||||
self.model, "num_fused_shared_experts"
|
||||
):
|
||||
@@ -2960,7 +2972,10 @@ class ModelRunner(ModelRunnerKVCacheMixin):
|
||||
output.expert_distribution_metrics = recorder_outputs.get("metrics")
|
||||
|
||||
no_copy_to_cpu = not self.server_args.disable_overlap_schedule
|
||||
if (experts_capturer := get_global_experts_capturer()) is not None:
|
||||
if (
|
||||
not self.is_draft_worker
|
||||
and (experts_capturer := get_global_experts_capturer()) is not None
|
||||
):
|
||||
output.routed_experts_output = experts_capturer.on_forward_end(
|
||||
forward_batch=forward_batch,
|
||||
can_run_graph=output.can_run_graph,
|
||||
|
||||
Reference in New Issue
Block a user