Support piecewise cuda graph for deepseek v3 (#12996)
This commit is contained in:
@@ -922,3 +922,27 @@ def select_experts(
|
|||||||
get_global_expert_distribution_recorder().on_select_experts(topk_ids=topk_ids)
|
get_global_expert_distribution_recorder().on_select_experts(topk_ids=topk_ids)
|
||||||
|
|
||||||
return StandardTopKOutput(topk_weights, topk_ids, router_logits)
|
return StandardTopKOutput(topk_weights, topk_ids, router_logits)
|
||||||
|
|
||||||
|
|
||||||
|
# Register fake implementations for torch.compile support
|
||||||
|
if _is_cuda:
|
||||||
|
|
||||||
|
@torch.library.register_fake("sgl_kernel::moe_fused_gate")
|
||||||
|
def _(
|
||||||
|
input_tensor,
|
||||||
|
bias,
|
||||||
|
num_expert_group,
|
||||||
|
topk_group,
|
||||||
|
topk,
|
||||||
|
num_fused_shared_experts=0,
|
||||||
|
routed_scaling_factor=0,
|
||||||
|
apply_routed_scaling_factor_on_output=False,
|
||||||
|
):
|
||||||
|
num_rows = input_tensor.shape[0]
|
||||||
|
topk_weights = torch.empty(
|
||||||
|
(num_rows, topk), dtype=torch.float32, device=input_tensor.device
|
||||||
|
)
|
||||||
|
topk_ids = torch.empty(
|
||||||
|
(num_rows, topk), dtype=torch.int32, device=input_tensor.device
|
||||||
|
)
|
||||||
|
return topk_weights, topk_ids
|
||||||
|
|||||||
@@ -819,6 +819,10 @@ class ServerArgs:
|
|||||||
# eagle draft models and cuda graphs
|
# eagle draft models and cuda graphs
|
||||||
reserved_mem += 2 * 1024
|
reserved_mem += 2 * 1024
|
||||||
|
|
||||||
|
# For piecewise cuda graphs
|
||||||
|
if self.enable_piecewise_cuda_graph:
|
||||||
|
reserved_mem += self.piecewise_cuda_graph_max_tokens // 4
|
||||||
|
|
||||||
self.mem_fraction_static = (
|
self.mem_fraction_static = (
|
||||||
round((gpu_mem - reserved_mem) / gpu_mem, 3)
|
round((gpu_mem - reserved_mem) / gpu_mem, 3)
|
||||||
if gpu_mem is not None
|
if gpu_mem is not None
|
||||||
@@ -900,6 +904,9 @@ class ServerArgs:
|
|||||||
hf_config = self.get_hf_config()
|
hf_config = self.get_hf_config()
|
||||||
model_arch = hf_config.architectures[0]
|
model_arch = hf_config.architectures[0]
|
||||||
if model_arch in ["DeepseekV3ForCausalLM"] and not is_deepseek_nsa(hf_config):
|
if model_arch in ["DeepseekV3ForCausalLM"] and not is_deepseek_nsa(hf_config):
|
||||||
|
if self.enable_piecewise_cuda_graph:
|
||||||
|
logger.info("Piecewise CUDA graph is enabled, use MLA for prefill.")
|
||||||
|
|
||||||
if is_cuda() and is_sm100_supported():
|
if is_cuda() and is_sm100_supported():
|
||||||
if (
|
if (
|
||||||
self.attention_backend is None
|
self.attention_backend is None
|
||||||
|
|||||||
Reference in New Issue
Block a user