[Model Runner V2] Use MRV2 for all models by default (#53183)
Signed-off-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
@@ -591,6 +591,15 @@ def _support_torch_compile(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
# Tensors that enter the graph through the forward context rather than
|
||||
# model args (e.g. the MoE padding mask) need their batch dim marked
|
||||
# dynamic too, otherwise AOT-compiled artifacts bake a static guard
|
||||
# for the compile-time batch size.
|
||||
if is_forward_context_available():
|
||||
is_padding = get_forward_context().is_padding
|
||||
if is_padding is not None:
|
||||
torch._dynamo.mark_dynamic(is_padding, 0)
|
||||
|
||||
original_code_object = self.original_code_object()
|
||||
logger.debug("Start compiling function %s", original_code_object)
|
||||
|
||||
|
||||
+52
-85
@@ -66,19 +66,10 @@ else:
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
DEFAULT_V2_MODEL_RUNNER_ARCHITECTURES = frozenset(
|
||||
{
|
||||
"DeepseekV2ForCausalLM",
|
||||
"DeepseekV32ForCausalLM",
|
||||
"DeepseekV4ForCausalLM",
|
||||
"GlmMoeDsaForCausalLM",
|
||||
"GraniteMoeForCausalLM",
|
||||
"InklingForCausalLM",
|
||||
"InklingForConditionalGeneration",
|
||||
"KimiK3ForConditionalGeneration",
|
||||
"LongcatFlashNgramForCausalLM",
|
||||
"Qwen2MoeForCausalLM",
|
||||
}
|
||||
# TODO(rocm): These models are either unsupported by MRV2 or slower with
|
||||
# MRV2 on AMD GPUs.
|
||||
ROCM_DEFAULT_MRV1_ARCHITECTURES = frozenset(
|
||||
{"DeepseekV32ForCausalLM", "DeepseekV4ForCausalLM"}
|
||||
)
|
||||
|
||||
DEFAULT_BREAKABLE_CUDAGRAPH_ARCHITECTURES = frozenset(
|
||||
@@ -99,21 +90,6 @@ DEFAULT_BREAKABLE_CUDAGRAPH_ARCHITECTURES = frozenset(
|
||||
)
|
||||
|
||||
|
||||
@lru_cache
|
||||
def default_v2_model_runner_architectures() -> frozenset[str]:
|
||||
"""Architectures defaulting to the V2 model runner on this platform."""
|
||||
from vllm.platforms import current_platform
|
||||
|
||||
if current_platform.is_rocm():
|
||||
# TODO(rocm): These models are either unsupported by MRV2 or slower with
|
||||
# MRV2 on AMD GPUs.
|
||||
return DEFAULT_V2_MODEL_RUNNER_ARCHITECTURES - {
|
||||
"DeepseekV32ForCausalLM",
|
||||
"DeepseekV4ForCausalLM",
|
||||
}
|
||||
return DEFAULT_V2_MODEL_RUNNER_ARCHITECTURES
|
||||
|
||||
|
||||
@lru_cache
|
||||
def default_breakable_cudagraph_architectures() -> frozenset[str]:
|
||||
"""Architectures defaulting to breakable CUDA graphs on this platform."""
|
||||
@@ -646,36 +622,17 @@ class VllmConfig:
|
||||
if use_v2_model_runner is not None:
|
||||
return use_v2_model_runner
|
||||
|
||||
# PCP runtime support is implemented only by the V2 model runner.
|
||||
if self.parallel_config.prefill_context_parallel_size > 1:
|
||||
return True
|
||||
from vllm.platforms import current_platform
|
||||
|
||||
# DSpark is implemented only by the V2 GPU model runner, and DeepSeek-V4
|
||||
# is not otherwise a default-V2 architecture, so force V2 for it. If V2
|
||||
# is unsupported for the rest of the config, _validate_v2_model_runner
|
||||
# raises rather than silently falling back to V1 (which can't run dspark).
|
||||
if (
|
||||
self.speculative_config is not None
|
||||
and self.speculative_config.method == "dspark"
|
||||
):
|
||||
return True
|
||||
|
||||
# Mixed sliding/full DFlash drafts need multiple KV groups (V2 only);
|
||||
# force V2 as for dspark, since a hybrid target otherwise defaults to V1.
|
||||
if self._dflash_needs_multi_kv_group():
|
||||
return True
|
||||
|
||||
# The DFlash2 candidate selector exists only in the V2 speculator. On V1
|
||||
# the same checkpoint drafts through DFlashProposer, which never calls
|
||||
# it, so the draft degrades to DFlash1 silently. Force V2 as for dspark.
|
||||
if self._is_dflash2_draft():
|
||||
return True
|
||||
|
||||
if self.model_config is not None and self.model_config.is_diffusion:
|
||||
return True
|
||||
|
||||
if not self._is_default_v2_model_runner_model():
|
||||
return False
|
||||
model_config = self.model_config
|
||||
if model_config is not None and current_platform.is_rocm():
|
||||
architectures = getattr(model_config, "architectures", ())
|
||||
if any(arch in ROCM_DEFAULT_MRV1_ARCHITECTURES for arch in architectures):
|
||||
logger.warning_once(
|
||||
"Defaulting to V1 model runner on ROCm for model architectures: %s",
|
||||
", ".join(architectures),
|
||||
)
|
||||
return False
|
||||
|
||||
if not HAS_TRITON:
|
||||
logger.warning_once(
|
||||
@@ -717,26 +674,6 @@ class VllmConfig:
|
||||
num_sliding = sum(lt == "sliding_attention" for lt in layer_types)
|
||||
return 0 < num_sliding < len(layer_types)
|
||||
|
||||
def _is_default_v2_model_runner_model(self) -> bool:
|
||||
model_config = self.model_config
|
||||
if model_config is None:
|
||||
return False
|
||||
|
||||
architectures = getattr(model_config, "architectures", [])
|
||||
default_architectures = default_v2_model_runner_architectures()
|
||||
is_default_v2_architecture = any(
|
||||
arch in default_architectures for arch in architectures
|
||||
)
|
||||
|
||||
if getattr(model_config, "is_hybrid", False) and (
|
||||
not is_default_v2_architecture
|
||||
):
|
||||
return False
|
||||
|
||||
if getattr(model_config, "is_attention_free", False):
|
||||
return False
|
||||
return is_default_v2_architecture or not model_config.is_moe
|
||||
|
||||
def _uses_breakable_cudagraph_by_default(self) -> bool:
|
||||
model_config = self.model_config
|
||||
if model_config is None:
|
||||
@@ -1666,11 +1603,8 @@ class VllmConfig:
|
||||
|
||||
if self.use_v2_model_runner:
|
||||
self._validate_v2_model_runner()
|
||||
elif self.parallel_config.prefill_context_parallel_size > 1:
|
||||
raise ValueError(
|
||||
"Prefill context parallelism requires Model Runner V2. "
|
||||
"Remove VLLM_USE_V2_MODEL_RUNNER=0."
|
||||
)
|
||||
else:
|
||||
self._validate_v1_model_runner()
|
||||
|
||||
self._validate_batch_sharded_sampling()
|
||||
|
||||
@@ -2561,6 +2495,35 @@ class VllmConfig:
|
||||
|
||||
return unsupported
|
||||
|
||||
def _get_v1_model_runner_unsupported_features(self) -> list[str]:
|
||||
unsupported: list[str] = []
|
||||
|
||||
# PCP runtime support is implemented only by the V2 model runner.
|
||||
if self.parallel_config.prefill_context_parallel_size > 1:
|
||||
unsupported.append("prefill context parallel")
|
||||
|
||||
# DSpark is implemented only by the V2 GPU model runner.
|
||||
if self.speculative_config and self.speculative_config.method == "dspark":
|
||||
unsupported.append("dspark speculative decoding")
|
||||
|
||||
# Mixed sliding/full DFlash drafts need multiple KV groups (V2 only).
|
||||
if self._dflash_needs_multi_kv_group():
|
||||
unsupported.append("mixed sliding/full dflash drafts")
|
||||
|
||||
# The DFlash2 candidate selector exists only in the V2 speculator. On
|
||||
# V1 the same checkpoint drafts through DFlashProposer, which never
|
||||
# calls it, so the draft would degrade to DFlash1 silently.
|
||||
if self._is_dflash2_draft():
|
||||
unsupported.append("dflash2 drafts")
|
||||
|
||||
if self.model_config is not None and self.model_config.is_diffusion:
|
||||
unsupported.append("diffusion models")
|
||||
|
||||
if self.parallel_config.enable_batch_sharded_sampling:
|
||||
unsupported.append("batch-sharded sampling")
|
||||
|
||||
return unsupported
|
||||
|
||||
def _validate_batch_sharded_sampling(self) -> None:
|
||||
"""Validate `enable_batch_sharded_sampling` against the rest of the config."""
|
||||
if not self.parallel_config.enable_batch_sharded_sampling:
|
||||
@@ -2571,9 +2534,6 @@ class VllmConfig:
|
||||
blockers: list[str] = []
|
||||
tp_size = self.parallel_config.tensor_parallel_size
|
||||
|
||||
if not self.use_v2_model_runner:
|
||||
blockers.append("it is only implemented by Model Runner V2")
|
||||
|
||||
if tp_size <= 1:
|
||||
blockers.append("tensor_parallel_size is 1, so there is nothing to shard")
|
||||
elif self.scheduler_config.max_num_seqs < tp_size:
|
||||
@@ -2623,6 +2583,13 @@ class VllmConfig:
|
||||
f"Model Runner V2 does not yet support: {', '.join(unsupported)}"
|
||||
)
|
||||
|
||||
def _validate_v1_model_runner(self) -> None:
|
||||
unsupported = self._get_v1_model_runner_unsupported_features()
|
||||
if unsupported:
|
||||
raise ValueError(
|
||||
f"Model Runner V1 does not support: {', '.join(unsupported)}"
|
||||
)
|
||||
|
||||
def validate_block_size(self) -> None:
|
||||
"""Validate block_size against DCP and mamba constraints.
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ from typing_extensions import runtime_checkable
|
||||
|
||||
from vllm.config import CacheConfig, VllmConfig, get_layers_from_vllm_config
|
||||
from vllm.config.cache import _layout_from_name
|
||||
from vllm.utils.gpu_sync_debug import gpu_sync_allowed
|
||||
from vllm.utils.math_utils import cdiv
|
||||
from vllm.utils.torch_utils import PIN_MEMORY, async_tensor_h2d, np_to_pinned_tensor
|
||||
from vllm.v1.kv_cache_interface import KVCacheLayout, KVCacheSpec, MambaSpec
|
||||
@@ -475,7 +476,9 @@ def make_local_attention_virtual_batches(
|
||||
block_size: int = 0,
|
||||
) -> tuple[CommonAttentionMetadata, Callable[[torch.Tensor], torch.Tensor]]:
|
||||
query_start_loc_np = common_attn_metadata.query_start_loc_cpu.numpy()
|
||||
seq_lens_np = common_attn_metadata.seq_lens_cpu.numpy()
|
||||
with gpu_sync_allowed():
|
||||
# TODO see https://github.com/vllm-project/vllm/pull/31852
|
||||
seq_lens_np = common_attn_metadata.seq_lens_cpu.numpy()
|
||||
block_table = common_attn_metadata.block_table_tensor
|
||||
device = common_attn_metadata.query_start_loc.device
|
||||
|
||||
|
||||
Reference in New Issue
Block a user