move topk capturers to srt/state_capturer/ (#24450)

Co-authored-by: Yueming Yuan <yym022502@gmail.com>
Co-authored-by: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com>
Co-authored-by: Ziang Li <ziangli@umich.edu>
This commit is contained in:
Liangsheng Yin
2026-05-05 15:54:01 -07:00
committed by GitHub
co-authored by Yueming Yuan fzyzcjy Ziang Li
parent 47a416fc62
commit 08d4c2072b
13 changed files with 28 additions and 28 deletions
@@ -5,8 +5,8 @@ from sgl_kernel_npu.norm.l1_norm import l1_norm
from sglang.srt.eplb.expert_distribution import get_global_expert_distribution_recorder
from sglang.srt.eplb.expert_location_dispatch import topk_ids_logical_to_physical
from sglang.srt.layers.moe.routed_experts_capturer import get_global_experts_capturer
from sglang.srt.layers.moe.topk import StandardTopKOutput, select_experts
from sglang.srt.state_capturer.routed_experts import get_global_experts_capturer
if TYPE_CHECKING:
from sglang.srt.eplb.expert_location_dispatch import ExpertLocationDispatchInfo
@@ -12,13 +12,13 @@ from sglang.jit_kernel.fused_store_index_cache import (
fused_store_index_k_cache,
)
from sglang.srt.environ import envs
from sglang.srt.layers.attention.indexer_topk_capturer import (
maybe_capture_indexer_topk,
)
from sglang.srt.layers.dp_attention import attn_tp_all_gather_into_tensor
from sglang.srt.layers.layernorm import LayerNorm
from sglang.srt.layers.quantization.fp8_kernel import fp8_dtype, is_fp8_fnuz
from sglang.srt.layers.utils import MultiPlatformOp
from sglang.srt.state_capturer.indexer_topk import (
maybe_capture_indexer_topk,
)
from sglang.srt.utils import (
add_prefix,
ceil_align,
+1 -1
View File
@@ -52,9 +52,9 @@ from sglang.srt.eplb.expert_location_dispatch import (
)
from sglang.srt.layers.dp_attention import is_allocation_symmetric
from sglang.srt.layers.moe import get_moe_runner_backend
from sglang.srt.layers.moe.routed_experts_capturer import get_global_experts_capturer
from sglang.srt.layers.moe.utils import is_deepep_class_backend
from sglang.srt.layers.utils import MultiPlatformOp
from sglang.srt.state_capturer.routed_experts import get_global_experts_capturer
from sglang.srt.utils import (
cpu_has_amx_support,
get_bool_env_var,
@@ -7,11 +7,7 @@ import torch
from sglang.srt.disaggregation.utils import DisaggregationMode
from sglang.srt.environ import envs
from sglang.srt.layers.attention.indexer_topk_capturer import (
get_global_indexer_capturer,
)
from sglang.srt.layers.logits_processor import LogitsProcessorOutput
from sglang.srt.layers.moe.routed_experts_capturer import get_global_experts_capturer
from sglang.srt.managers.io_struct import (
AbortReq,
BatchEmbeddingOutput,
@@ -25,6 +21,10 @@ from sglang.srt.managers.schedule_batch import (
)
from sglang.srt.mem_cache.common import maybe_cache_unfinished_req, release_kv_cache
from sglang.srt.server_args import MIS_DELIMITER_TOKEN_ID, get_global_server_args
from sglang.srt.state_capturer.indexer_topk import (
get_global_indexer_capturer,
)
from sglang.srt.state_capturer.routed_experts import get_global_experts_capturer
if TYPE_CHECKING:
from sglang.srt.managers.scheduler import (
+1 -1
View File
@@ -8,11 +8,11 @@ import torch
from sglang.srt.eplb.expert_distribution import ExpertDistributionMetrics
from sglang.srt.layers.logits_processor import LogitsProcessorOutput
from sglang.srt.layers.topk_capturer_base import TopkCaptureOutput
from sglang.srt.managers.overlap_utils import FutureIndices
from sglang.srt.managers.schedule_batch import Req
from sglang.srt.model_executor.forward_batch_info import PPProxyTensors
from sglang.srt.server_args import ServerArgs
from sglang.srt.state_capturer.base import TopkCaptureOutput
if TYPE_CHECKING:
from sglang.srt.managers.scheduler import GenerationBatchResult
@@ -110,11 +110,6 @@ from sglang.srt.layers.attention.attention_registry import (
ATTENTION_BACKENDS,
attn_backend_wrapper,
)
from sglang.srt.layers.attention.indexer_topk_capturer import (
create_indexer_capturer,
get_global_indexer_capturer,
set_global_indexer_capturer,
)
from sglang.srt.layers.attention.nsa.utils import is_nsa_enable_prefill_cp
from sglang.srt.layers.attention.tbo_backend import TboAttnBackend
from sglang.srt.layers.dp_attention import (
@@ -126,15 +121,9 @@ from sglang.srt.layers.dp_attention import (
set_is_extend_in_batch,
)
from sglang.srt.layers.logits_processor import LogitsProcessorOutput
from sglang.srt.layers.moe.routed_experts_capturer import (
RoutedExpertsCapturer,
get_global_experts_capturer,
set_global_experts_capturer,
)
from sglang.srt.layers.pooler import EmbeddingPoolerOutput
from sglang.srt.layers.quantization.fp8_kernel import fp8_dtype
from sglang.srt.layers.sampler import create_sampler
from sglang.srt.layers.topk_capturer_base import TopkCaptureOutput
from sglang.srt.layers.torchao_utils import apply_torchao_config_to_model
from sglang.srt.lora.lora_manager import LoRAManager
from sglang.srt.lora.lora_registry import LoRARef
@@ -180,6 +169,17 @@ from sglang.srt.server_args import (
set_global_server_args_for_scheduler,
)
from sglang.srt.speculative.spec_info import SpeculativeAlgorithm
from sglang.srt.state_capturer.base import TopkCaptureOutput
from sglang.srt.state_capturer.indexer_topk import (
create_indexer_capturer,
get_global_indexer_capturer,
set_global_indexer_capturer,
)
from sglang.srt.state_capturer.routed_experts import (
RoutedExpertsCapturer,
get_global_experts_capturer,
set_global_experts_capturer,
)
from sglang.srt.utils import (
MultiprocessingSerializer,
broadcast_pyobj,
@@ -6,9 +6,6 @@ import torch
from sglang.srt.compilation.piecewise_context_manager import is_in_piecewise_cuda_graph
from sglang.srt.layers import deep_gemm_wrapper
from sglang.srt.layers.attention.indexer_topk_capturer import (
maybe_capture_indexer_topk,
)
from sglang.srt.layers.attention.nsa.utils import nsa_use_prefill_cp
from sglang.srt.layers.communicator import get_attn_tp_context
from sglang.srt.layers.quantization.fp8_kernel import (
@@ -29,6 +26,9 @@ from sglang.srt.models.deepseek_common.utils import (
_use_aiter_gfx95,
)
from sglang.srt.server_args import get_global_server_args
from sglang.srt.state_capturer.indexer_topk import (
maybe_capture_indexer_topk,
)
from sglang.srt.utils import BumpAllocator
if TYPE_CHECKING:
@@ -6,7 +6,7 @@ import pybase64
import torch
from sglang.srt.layers.dp_attention import get_attention_tp_size
from sglang.srt.layers.topk_capturer_base import BaseTopkCapturer
from sglang.srt.state_capturer.base import BaseTopkCapturer
logger = logging.getLogger(__name__)
@@ -10,9 +10,9 @@ from sglang.srt.layers.dp_attention import (
get_dp_local_info,
is_dp_attention_enabled,
)
from sglang.srt.layers.topk_capturer_base import BaseTopkCapturer
from sglang.srt.model_executor.forward_batch_info import ForwardBatch
from sglang.srt.server_args import get_global_server_args
from sglang.srt.state_capturer.base import BaseTopkCapturer
class RoutedExpertsCapturer(BaseTopkCapturer):