[cuda graph] Enable prefill piecewise CUDA graph for Cohere2Vision (text path) (#28686)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
zijiexia
2026-06-22 19:20:14 +00:00
committed by GitHub
co-authored by Claude Opus 4.8
parent adc203dfee
commit 669be5448b
3 changed files with 78 additions and 1 deletions
+24
View File
@@ -381,6 +381,14 @@ class ModelConfig:
self.is_piecewise_cuda_graph_disabled_model = (
is_piecewise_cuda_graph_disabled_model(self.hf_config.architectures)
)
# Multimodal archs whose language-model prefill is verified safe to capture
# under piecewise CUDA graph. ServerArgs otherwise disables prefill piecewise
# CG for every multimodal model; this opt-in re-enables it for listed archs
# (the vision encoder still runs eagerly via general_mm_embed_routine, only the
# LM forward is captured).
self.is_multimodal_piecewise_cuda_graph_supported = enable_multimodal and (
is_multimodal_piecewise_cuda_graph_supported(self.hf_config.architectures)
)
self.dtype = _get_and_verify_dtype(self.hf_text_config, dtype)
# Derive context length and model shapes
@@ -1651,6 +1659,14 @@ piecewise_cuda_graph_disabled_model_archs = [
"LLaDAModelLM",
]
# Multimodal archs allowed to keep prefill piecewise CUDA graph enabled. The
# generic "multimodal model" rule in ServerArgs disables prefill piecewise CG for
# all multimodal models; archs here opt back in because their LM prefill captures
# cleanly (vision encoder runs eagerly outside the graph via general_mm_embed_routine).
multimodal_piecewise_cuda_graph_supported_model_archs = [
"Cohere2VisionForConditionalGeneration",
]
if external_mm_model_arch := envs.SGLANG_EXTERNAL_MM_MODEL_ARCH.get():
multimodal_model_archs.append(external_mm_model_arch)
@@ -1709,6 +1725,14 @@ def is_piecewise_cuda_graph_disabled_model(model_architectures: List[str]):
)
def is_multimodal_piecewise_cuda_graph_supported(model_architectures: List[str]):
"""Whether a multimodal arch may keep prefill piecewise CUDA graph enabled."""
return any(
arch in multimodal_piecewise_cuda_graph_supported_model_archs
for arch in model_architectures
)
# SequenceClassification models that use CrossEncodingPooler
_cross_encoding_pooler_archs = [
"BertForSequenceClassification",
+5 -1
View File
@@ -3008,7 +3008,11 @@ class ServerArgs:
),
("MoE A2A backend", lambda: self.moe_a2a_backend != "none"),
("LoRA", lambda: bool(self.lora_paths) or self.enable_lora),
("multimodal model", lambda: self.get_model_config().is_multimodal),
(
"multimodal model",
lambda: self.get_model_config().is_multimodal
and not self.get_model_config().is_multimodal_piecewise_cuda_graph_supported,
),
(
"GGUF quantization",
lambda: self.load_format == "gguf"