Merge remote-tracking branch 'upstream/main' into patches
Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -42,15 +42,6 @@ class ECTransferConfig:
|
||||
"""Whether this vLLM instance produces, consumes EC cache, or both. Choices
|
||||
are 'ec_producer', 'ec_consumer', 'ec_both'."""
|
||||
|
||||
ec_rank: int | None = None
|
||||
"""The rank of this vLLM instance in the EC cache transfer. Typical value:
|
||||
0 for encoder, 1 for pd instance.
|
||||
Currently only 1P1D is supported."""
|
||||
|
||||
ec_parallel_size: int = 1
|
||||
"""The number of parallel instances for EC cache transfer. For
|
||||
PyNcclConnector, this should be 2."""
|
||||
|
||||
ec_ip: str = "127.0.0.1"
|
||||
"""The EC connector ip, used to build distributed connection."""
|
||||
|
||||
|
||||
+68
-20
@@ -3,7 +3,7 @@
|
||||
import contextlib
|
||||
from collections.abc import Callable, Iterable
|
||||
from dataclasses import asdict, fields
|
||||
from typing import TYPE_CHECKING, Any, Literal
|
||||
from typing import TYPE_CHECKING, Any, Final, Literal
|
||||
|
||||
from pydantic import Field, field_validator
|
||||
|
||||
@@ -12,6 +12,7 @@ from vllm.logger import init_logger
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from vllm.config import VllmConfig
|
||||
from vllm.config.parallel import ParallelConfig
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
@@ -128,10 +129,10 @@ MoEBackend = Literal[
|
||||
"flashinfer_trtllm",
|
||||
"flashinfer_cutlass",
|
||||
"flashinfer_cutedsl",
|
||||
"flashinfer_moe_ep_cutedsl",
|
||||
"flashinfer_b12x",
|
||||
"b12x",
|
||||
"flashinfer_moe_ep_mega_deep_gemm",
|
||||
"flashinfer_moe_ep_mega_cutedsl",
|
||||
"marlin",
|
||||
"humming",
|
||||
"triton_unfused",
|
||||
@@ -143,21 +144,28 @@ MoEBackend = Literal[
|
||||
"rdna3",
|
||||
]
|
||||
|
||||
# Backends that run the mega-MoE model path through the flashinfer moe_ep
|
||||
# runtime. Only architectures in FLASHINFER_MOE_EP_ARCHITECTURES wire up
|
||||
# these experts.
|
||||
FLASHINFER_MOE_EP_CUTEDSL = "flashinfer_moe_ep_cutedsl"
|
||||
FLASHINFER_MOE_EP_DEEP_GEMM = "flashinfer_moe_ep_mega_deep_gemm"
|
||||
|
||||
# Backends implemented by the shared FlashInfer MoE-EP adapter.
|
||||
FLASHINFER_MOE_EP_BACKENDS = frozenset(
|
||||
{
|
||||
"flashinfer_moe_ep_mega_deep_gemm",
|
||||
"flashinfer_moe_ep_mega_cutedsl",
|
||||
FLASHINFER_MOE_EP_CUTEDSL,
|
||||
FLASHINFER_MOE_EP_DEEP_GEMM,
|
||||
}
|
||||
)
|
||||
# Those backends dispatch and combine themselves, so the framework must not
|
||||
# run a separate all2all around them.
|
||||
PASSTHROUGH_ALL2ALL_BACKEND: Final = "passthrough"
|
||||
|
||||
# Backends that run a mega-MoE model path (fused expert module plus
|
||||
# prepare_megamoe routing): vLLM's native deep_gemm path, which any model
|
||||
# with a mega-MoE module may use (DeepSeek-V4, Kimi K3), plus the flashinfer
|
||||
# moe_ep variants.
|
||||
MEGA_MOE_BACKENDS = frozenset({"deep_gemm_mega_moe"}) | FLASHINFER_MOE_EP_BACKENDS
|
||||
# "Native" here meaning that the backend does not use the fused MoE path.
|
||||
# Currently only relevant for the vLLM provided DeepGEMM MegaMoE.,
|
||||
# TODO: migrate to the fused MoE path ultimately.
|
||||
NATIVE_MEGA_MOE_BACKENDS = frozenset({"deep_gemm_mega_moe"})
|
||||
|
||||
# Every megakernel backend. The FlashInfer variants run through the standard
|
||||
# fused-MoE model path; the quantization method binds the kernel.
|
||||
MEGA_MOE_BACKENDS = NATIVE_MEGA_MOE_BACKENDS | FLASHINFER_MOE_EP_BACKENDS
|
||||
|
||||
SparseIndexerTopkBackend = Literal[
|
||||
"auto",
|
||||
@@ -167,10 +175,11 @@ SparseIndexerTopkBackend = Literal[
|
||||
"per_row",
|
||||
"flashinfer",
|
||||
"torch",
|
||||
"aiter",
|
||||
]
|
||||
|
||||
# Architectures whose model code wires up the flashinfer moe_ep experts. MTP
|
||||
# and DSpark draft variants inherit the setting from these target models.
|
||||
# DeepGEMM consumes the DeepSeek-V4 MXFP4 checkpoint recipe. CuTeDSL is
|
||||
# selected by quantization methods and is not architecture-specific.
|
||||
FLASHINFER_MOE_EP_ARCHITECTURES = frozenset(
|
||||
{
|
||||
"DeepseekV4ForCausalLM",
|
||||
@@ -180,11 +189,48 @@ FLASHINFER_MOE_EP_ARCHITECTURES = frozenset(
|
||||
)
|
||||
|
||||
|
||||
def bind_passthrough_all2all_backend(
|
||||
moe_backend: str, parallel_config: "ParallelConfig"
|
||||
) -> None:
|
||||
"""Bind ``all2all_backend="passthrough"`` to MoE backends that own their
|
||||
expert-parallel communication (currently the FlashInfer MoE-EP megakernels).
|
||||
|
||||
Such a deployment gets ``passthrough`` when the all2all backend is left at
|
||||
its default and rejects any other explicit choice; the value is meaningless
|
||||
with a MoE backend that relies on the framework to communicate. The CLI does
|
||||
not offer the value; the early return keeps repeated
|
||||
``set_platform_defaults`` calls idempotent.
|
||||
"""
|
||||
a2a = parallel_config.all2all_backend
|
||||
if moe_backend in FLASHINFER_MOE_EP_BACKENDS:
|
||||
if a2a == PASSTHROUGH_ALL2ALL_BACKEND:
|
||||
return
|
||||
if a2a != "allgather_reducescatter":
|
||||
raise ValueError(
|
||||
f"moe_backend={moe_backend!r} dispatches and combines itself and "
|
||||
f"cannot be paired with all2all_backend={a2a!r}; leave "
|
||||
f"--all2all-backend unset."
|
||||
)
|
||||
logger.info_once(
|
||||
"moe_backend=%r: using all2all_backend=%r (dispatch and combine run "
|
||||
"inside the MoE backend).",
|
||||
moe_backend,
|
||||
PASSTHROUGH_ALL2ALL_BACKEND,
|
||||
)
|
||||
parallel_config.all2all_backend = PASSTHROUGH_ALL2ALL_BACKEND
|
||||
elif a2a == PASSTHROUGH_ALL2ALL_BACKEND:
|
||||
raise ValueError(
|
||||
f"all2all_backend={a2a!r} is only valid with a moe_backend that "
|
||||
f"dispatches and combines itself ({sorted(FLASHINFER_MOE_EP_BACKENDS)}),"
|
||||
f" got moe_backend={moe_backend!r}."
|
||||
)
|
||||
|
||||
|
||||
def validate_flashinfer_moe_ep_model(
|
||||
moe_backend: str, architectures: Iterable[str]
|
||||
) -> None:
|
||||
"""Reject flashinfer moe_ep backends for models that lack the FI path."""
|
||||
if moe_backend not in FLASHINFER_MOE_EP_BACKENDS:
|
||||
"""Reject model-specific FlashInfer MoE-EP backends."""
|
||||
if moe_backend != FLASHINFER_MOE_EP_DEEP_GEMM:
|
||||
return
|
||||
if not any(arch in FLASHINFER_MOE_EP_ARCHITECTURES for arch in architectures):
|
||||
raise ValueError(
|
||||
@@ -254,6 +300,9 @@ class KernelConfig:
|
||||
- "flashinfer_trtllm": Use FlashInfer with TRTLLM-GEN kernels
|
||||
- "flashinfer_cutlass": Use FlashInfer with CUTLASS kernels
|
||||
- "flashinfer_cutedsl": Use FlashInfer with CuteDSL kernels (FP4 only)
|
||||
- "flashinfer_moe_ep_cutedsl": Use FlashInfer's CuTeDSL MoE-EP
|
||||
mega-kernel with NVFP4 weights (MXFP4 checkpoints are requantized at
|
||||
load); requires Blackwell, expert parallelism, and NVSHMEM
|
||||
- "flashinfer_b12x": Use FlashInfer CuteDSL fused MoE for SM12x
|
||||
(RTX Pro 6000 / DGX Spark)
|
||||
- "b12x": Use b12x FP4 MoE kernels on SM12x
|
||||
@@ -261,10 +310,6 @@ class KernelConfig:
|
||||
expert-parallel mega-MoE with the DeepGEMM megakernel, which consumes an
|
||||
MXFP4 checkpoint verbatim (Blackwell, requires expert parallel;
|
||||
DeepSeek-V4 only)
|
||||
- "flashinfer_moe_ep_mega_cutedsl": Same, with the CuteDSL megakernel
|
||||
(additionally requires NVSHMEM). The checkpoint selects the weight path:
|
||||
an NVFP4 checkpoint is consumed prequantized, MXFP4 weights are
|
||||
requantized at load
|
||||
- "marlin": Use Marlin kernels (weight-only quantization)
|
||||
- "humming": Use Humming Mixed Precision kernels
|
||||
- "triton_unfused": Use Triton unfused MoE kernels
|
||||
@@ -289,6 +334,8 @@ class KernelConfig:
|
||||
- "per_row": Use vLLM's top_k_per_row_decode kernel
|
||||
- "flashinfer": Use FlashInfer's top_k_ragged_transform kernel
|
||||
- "torch": Use a plain torch.topk implementation (debug reference)
|
||||
- "aiter": Use AITER's top_k_per_row_decode kernel (ROCm gfx950 only,
|
||||
requires VLLM_ROCM_USE_AITER)
|
||||
|
||||
Explicit values raise RuntimeError when their constraints are not met.
|
||||
"""
|
||||
@@ -388,6 +435,7 @@ class KernelConfig:
|
||||
validate_flashinfer_moe_ep_model(
|
||||
self.moe_backend, vllm_config.model_config.architectures
|
||||
)
|
||||
bind_passthrough_all2all_backend(self.moe_backend, vllm_config.parallel_config)
|
||||
|
||||
platform_op_priority = current_platform.get_default_ir_op_priority(vllm_config)
|
||||
logger.debug(
|
||||
|
||||
@@ -68,25 +68,10 @@ class KVTransferConfig:
|
||||
"""The device used by kv connector to buffer the KV cache. Choices are
|
||||
'cuda', 'cpu' and 'xpu'."""
|
||||
|
||||
kv_buffer_size: float = 1e9
|
||||
"""The buffer size for TorchDistributedConnector. Measured in number of
|
||||
bytes. Recommended value: 1e9 (about 1GB)."""
|
||||
|
||||
kv_role: KVRole | None = None
|
||||
"""Whether this vLLM instance produces, consumes KV cache, or both. Choices
|
||||
are 'kv_producer', 'kv_consumer', and 'kv_both'."""
|
||||
|
||||
kv_rank: int | None = None
|
||||
"""The rank of this vLLM instance in the KV cache transfer. Typical value:
|
||||
0 for prefill instance, 1 for decode instance.
|
||||
Currently only 1P1D is supported."""
|
||||
|
||||
kv_parallel_size: int = 1
|
||||
"""The number of parallel instances for KV cache transfer."""
|
||||
|
||||
kv_ip: str = "127.0.0.1"
|
||||
"""The KV connector ip, used to build distributed connection."""
|
||||
|
||||
kv_port: int = 14579
|
||||
"""The KV connector port, used to build distributed connection."""
|
||||
|
||||
|
||||
+24
-1
@@ -124,6 +124,22 @@ _RUNNER_CONVERTS: dict[RunnerType, list[ConvertType]] = {
|
||||
"draft": [],
|
||||
}
|
||||
|
||||
|
||||
def _modelopt_mixed_has_nvfp4(quant_config: dict[str, Any] | None) -> bool:
|
||||
"""Whether a ModelOpt MIXED_PRECISION checkpoint quantizes any layer to NVFP4.
|
||||
|
||||
``W4A16_NVFP4`` is excluded on purpose: it quantizes weights only, so there
|
||||
is no activation quantization for the fusion passes to act on.
|
||||
"""
|
||||
layers = (quant_config or {}).get("quantized_layers")
|
||||
if not isinstance(layers, dict):
|
||||
return False
|
||||
return any(
|
||||
isinstance(info, dict) and info.get("quant_algo") == "NVFP4"
|
||||
for info in layers.values()
|
||||
)
|
||||
|
||||
|
||||
AttnTypeStr = Literal[
|
||||
"decoder", "encoder", "encoder_only", "encoder_decoder", "attention_free", "hybrid"
|
||||
]
|
||||
@@ -2249,13 +2265,20 @@ class ModelConfig:
|
||||
return getattr(self.hf_config, "quantization_config", None) is not None
|
||||
|
||||
def is_nvfp4_quantized(self) -> bool:
|
||||
quant_config = self.model_arch_config.quantization_config
|
||||
|
||||
# ModelOpt NVFP4 checkpoints resolve to modelopt_fp4 quantization method
|
||||
if self.quantization in ("modelopt_fp4",):
|
||||
return True
|
||||
|
||||
# A checkpoint mixing NVFP4 with another algorithm declares
|
||||
# quant_algo MIXED_PRECISION and resolves to modelopt_mixed, so the
|
||||
# per-layer algorithms decide.
|
||||
if self.quantization == "modelopt_mixed":
|
||||
return _modelopt_mixed_has_nvfp4(quant_config)
|
||||
|
||||
# For Compressed Tensors we look for `"format": "nvfp4-pack-quantized"`
|
||||
# in the quantization config
|
||||
quant_config = self.model_arch_config.quantization_config
|
||||
return (
|
||||
self.quantization == "compressed-tensors"
|
||||
and quant_config is not None
|
||||
|
||||
+17
-5
@@ -56,6 +56,7 @@ All2AllBackend = Literal[
|
||||
"flashinfer_all2allv", # temporary alias for flashinfer_nvlink_two_sided
|
||||
"flashinfer_nvlink_two_sided",
|
||||
"flashinfer_nvlink_one_sided",
|
||||
"passthrough",
|
||||
]
|
||||
|
||||
|
||||
@@ -105,6 +106,17 @@ class EPLBConfig:
|
||||
on CUDA, falls back to "torch_gloo")
|
||||
"""
|
||||
|
||||
enable_migration_batching: bool = False
|
||||
"""Schedule expert migrations in batches where each rank communicates with
|
||||
at most one peer. This reduces per-rank network contention at the cost of
|
||||
additional sequential communication steps. This option only applies to
|
||||
async EPLB and is disabled by default."""
|
||||
|
||||
@property
|
||||
def migration_batching_enabled(self) -> bool:
|
||||
"""Whether contention-aware batching is active for this configuration."""
|
||||
return self.use_async and self.enable_migration_batching
|
||||
|
||||
@model_validator(mode="after")
|
||||
def _validate_eplb_config(self) -> Self:
|
||||
if self.use_async and self.policy != "default":
|
||||
@@ -211,7 +223,10 @@ class ParallelConfig:
|
||||
- "moonep": MoonEP balanced EP with dynamic redundant experts (NVLink)
|
||||
- "nixl_ep": Use nixl-ep kernels
|
||||
- "flashinfer_nvlink_one_sided": Use flashinfer high-throughput a2a kernels
|
||||
- "flashinfer_nvlink_two_sided": Use flashinfer two-sided kernels for mnnvl"""
|
||||
- "flashinfer_nvlink_two_sided": Use flashinfer two-sided kernels for mnnvl
|
||||
- "passthrough": No all2all at all: the MoE backend dispatches and combines
|
||||
itself (e.g. the FlashInfer MoE-EP megakernels). Bound automatically for
|
||||
such MoE backends; not selectable from the CLI."""
|
||||
|
||||
max_parallel_loading_workers: int | None = Field(default=None, ge=1)
|
||||
"""Maximum number of parallel loading workers when loading model
|
||||
@@ -277,9 +292,6 @@ class ParallelConfig:
|
||||
worker_cls: str = "auto"
|
||||
"""The full name of the worker class to use. If "auto", the worker class
|
||||
will be determined based on the platform."""
|
||||
sd_worker_cls: str = "auto"
|
||||
"""The full name of the worker class to use for speculative decoding.
|
||||
If "auto", the worker class will be determined based on the platform."""
|
||||
worker_extension_cls: str = ""
|
||||
"""The full name of the worker extension class to use. The worker extension
|
||||
class is dynamically inherited by the worker class. This is used to inject
|
||||
@@ -745,6 +757,7 @@ class ParallelConfig:
|
||||
"deepep_low_latency",
|
||||
"deepep_v2",
|
||||
"flashinfer_nvlink_one_sided",
|
||||
"passthrough",
|
||||
"mori_high_throughput",
|
||||
"mori_low_latency",
|
||||
"nixl_ep",
|
||||
@@ -894,7 +907,6 @@ class ParallelConfig:
|
||||
"placement_group",
|
||||
"distributed_executor_backend",
|
||||
"worker_cls",
|
||||
"sd_worker_cls",
|
||||
"worker_extension_cls",
|
||||
"_api_process_count",
|
||||
"_api_process_rank",
|
||||
|
||||
@@ -22,6 +22,7 @@ from vllm.model_executor.layers.quantization.utils.quant_utils import (
|
||||
kFp8Static128BlockSym,
|
||||
kFp8StaticChannelSym,
|
||||
kFp8StaticTensorSym,
|
||||
kInt4Static32,
|
||||
kInt8StaticChannelSym,
|
||||
kMxfp4Dynamic,
|
||||
kMxfp4Static,
|
||||
@@ -40,6 +41,8 @@ QUANT_KEY_NAMES: dict[str, QuantKey] = {
|
||||
"mxfp8": kMxfp8Dynamic,
|
||||
"mxfp4": kMxfp4Dynamic,
|
||||
"int8_per_channel_static": kInt8StaticChannelSym,
|
||||
# Load-time MXFP4-to-int4 for Kimi-K3 on gfx942.
|
||||
"int4_per_group_32": kInt4Static32,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user