Add pydocstyle to the ruff rules (#52136)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <hej.mellor@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Harry Mellor
2026-09-16 16:44:29 +00:00
committed by GitHub
co-authored by Claude Opus 5
parent 804e5377aa
commit 8c1557a79c
2002 changed files with 15024 additions and 14269 deletions
@@ -56,9 +56,7 @@ def _aiter_w4a16_silu_via_a8w4(
unpadded_N_w2,
unpadded_K_w2,
) -> torch.Tensor:
"""
MXFP4 w4a16 MoE with a SILU (concatenated ``[gate | up]``) activation.
"""
"""MXFP4 w4a16 MoE with a SILU (concatenated ``[gate | up]``) activation."""
from aiter.ops.triton.fusions.fused_clamp_act_mul import fused_clamp_act_mul
from aiter.ops.triton.quant import dynamic_mxfp8_quant
@@ -29,8 +29,7 @@ __all__ = [
# _get_padding_mask and patch_gating_output after
# https://github.com/ROCm/aiter/pull/4530 is released and consumed by vLLM.
def _get_padding_mask() -> torch.Tensor | None:
"""
Retrieves a boolean mask with non-padding (0) and padding (1) tokens.
"""Retrieves a boolean mask with non-padding (0) and padding (1) tokens.
`slot_mapping < 0` comes from:
@@ -247,8 +246,7 @@ def triton_kernel_fused_mxfp4_w4a8_experts(
class AiterW4A8ExpertsMonolithic(mk.FusedMoEExpertsMonolithic):
"""
Monolithic MXFP4 W4A8 expert using AITER triton kernels.
"""Monolithic MXFP4 W4A8 expert using AITER triton kernels.
This backend uses:
- aiter.ops.triton.moe_routing.routing for routing
@@ -36,7 +36,8 @@ def is_aiter_mxfp8_moe_available() -> bool:
nightly lacking #3811 would wrongly select FlyDSL instead of falling back to
the native Triton dot_scaled path. #3811 added no probe-able public symbol,
so detect the ``minimax_m3_mxfp8`` tuned config it shipped. Every check fails
closed (returns False -> triton dot_scaled), which is always safe."""
closed (returns False -> triton dot_scaled), which is always safe.
"""
if not (current_platform.is_rocm() and current_platform.supports_mx()):
return False
try:
@@ -307,8 +307,7 @@ class BatchedDeepGemmExperts(mk.FusedMoEExpertsModular):
max_num_tokens: int,
num_dispatchers: int,
):
"""
max_num_tokens: Maximum number of tokens from a DP Rank
"""max_num_tokens: Maximum number of tokens from a DP Rank
num_dispatchers: The number of DP dispatchers.
quant_config: Quantization configuration
"""
@@ -350,8 +349,7 @@ class BatchedDeepGemmExperts(mk.FusedMoEExpertsModular):
return True
def supports_packed_ue8m0_act_scales(self) -> bool:
"""
DeepGemm supports packed ue8m0 activation scales on Blackwell-family
"""DeepGemm supports packed ue8m0 activation scales on Blackwell-family
GPUs (SM100 datacenter and SM120 consumer).
"""
return is_deep_gemm_e8m0_used() and (
@@ -172,6 +172,7 @@ class CPUExpertsInt4(mk.FusedMoEExpertsMonolithic):
0 = SwiGLU_Gu (SiLU(g)*u)
1 = SwiGLU_Ug (SiLU(u)*g)
2 = SiLU
"""
if activation == MoEActivation.SWIGLUSTEP:
return 0
@@ -217,6 +218,7 @@ class CPUExpertsInt4(mk.FusedMoEExpertsMonolithic):
Returns:
Output tensor after MoE computation
"""
from vllm.model_executor.layers.fused_moe.router.cpu_router import (
select_experts,
@@ -192,7 +192,8 @@ class CPUUnquantizedExperts(mk.FusedMoEExpertsModular):
def _pad_moe_intermediate(self, layer: torch.nn.Module) -> None:
"""Zero-pad the per-partition MoE intermediate dim of both weights and
the expert bias, see `_padded_intermediate_size`."""
the expert bias, see `_padded_intermediate_size`.
"""
intermediate_size = self.moe_config.intermediate_size_per_partition
padded_size = self._padded_intermediate_size(self.moe_config)
if padded_size == intermediate_size:
@@ -745,6 +746,7 @@ def prepare_int4_moe_layer_for_cpu(
Returns:
(blocked_w13, blocked_w2, blocked_s13, blocked_s2, blocked_z13, blocked_z2)
"""
E = w13_packed.size(0)
@@ -951,7 +953,8 @@ class CPUExpertsInt4(mk.FusedMoEExpertsModular):
class CPUExpertsInt8(mk.FusedMoEExpertsModular):
"""CPU INT8 W8A8 per-channel weight / dynamic per-token activation
modular MoE experts."""
modular MoE experts.
"""
def __init__(
self,
@@ -1055,7 +1058,6 @@ class CPUExpertsInt8(mk.FusedMoEExpertsModular):
def process_weights_after_loading(self, layer: torch.nn.Module) -> None:
"""VNNI-prepack INT8 MoE weights for CPU kernel."""
w13 = torch.ops._C.convert_weight_packed(layer.w13_weight)
w2 = torch.ops._C.convert_weight_packed(layer.w2_weight)
replace_parameter(layer, "w13_weight", w13)
@@ -1285,7 +1287,8 @@ class ArmCPUExpertsInt8(mk.FusedMoEExpertsModular):
class ZenCPUExpertsInt8(mk.FusedMoEExpertsModular):
"""AMD Zen INT8 MoE with per-token activation and channelwise weight
quantization, dispatched through zentorch."""
quantization, dispatched through zentorch.
"""
def __init__(
self,
@@ -518,8 +518,7 @@ def run_cutlass_moe_fp4(
*,
activation_config: ApplyMoEActivationConfig | None = None,
) -> None:
"""
MoE implementation for FP4 Inputs
"""MoE implementation for FP4 Inputs.
# Gemm 1
a: Input tensor: [m, k] (half/bfloat16)
@@ -58,8 +58,7 @@ def _valid_deep_gemm_shape(M: int, N: int, K: int) -> bool:
def _valid_deep_gemm(
hidden_states: torch.Tensor, w1: torch.Tensor, w2: torch.Tensor
) -> bool:
"""
Check if the given problem size is supported by the DeepGemm grouped
"""Check if the given problem size is supported by the DeepGemm grouped
gemm kernel. All of M, N, K and the quantization block_shape must be
aligned by `dg.get_m_alignment_for_contiguous_layout()`.
"""
@@ -30,8 +30,7 @@ class FallbackExperts(mk.FusedMoEExpertsModular, ABC):
type[mk.FusedMoEExpertsModular],
type[mk.FusedMoEExpertsModular],
]:
"""
Get the cls for the experts and fallback experts.
"""Get the cls for the experts and fallback experts.
Subclasses should implement this method, so that
we have a consistent way to call the _supports_*
@@ -107,8 +107,7 @@ class FlashInferCuteDSLBatchedExperts(mk.FusedMoEExpertsModular):
expert_tokens_meta: mk.ExpertTokensMetadata | None,
activation: MoEActivation,
) -> tuple[tuple[int, ...], tuple[int, ...], tuple[int, ...]]:
"""
Compute the shapes for the temporary and final outputs of the two gemms
"""Compute the shapes for the temporary and final outputs of the two gemms
and activation in the fused expert function. Since the gemms are
independent, the workspace for the first gemm can be shared with the
workspace for the last gemm.
@@ -123,7 +122,6 @@ class FlashInferCuteDSLBatchedExperts(mk.FusedMoEExpertsModular):
- Note: in order for activation chunking to work, the first dimension
of each tuple must be the number of tokens.
"""
# We use global_num_experts due to how moe_align_block_size handles
# expert_maps.
K_dim = K * 2 if self.use_deep_ep_ll_nvfp4_dispatch else K
@@ -212,8 +210,7 @@ def flashinfer_cutedsl_moe_masked(
workspace: torch.Tensor,
out: torch.Tensor,
):
"""
Perform masked Mixture-of-Experts computation with FlashInfer's CuteDSL
"""Perform masked Mixture-of-Experts computation with FlashInfer's CuteDSL
kernels.
Args:
@@ -229,13 +226,14 @@ def flashinfer_cutedsl_moe_masked(
a2_global_scale (torch.Tensor): (l,)
w2_blockscale (torch.Tensor): blockscale factors, e4m3,
w2_alpha (torch.Tensor): (l,)
out (torch.Tensor): output tensor written in place, [l, m, k], bf16
masked_m (torch.Tensor): Masked dimension indices
workspace (torch.Tensor): For gateup_output
Notes:
- Assumes max(masked_m) <= m.
"""
"""
# === Assertions on dtypes ===
assert w1.dtype == torch.uint8, f"w1 must be uint8, got {w1.dtype}"
assert w1_blockscale.dtype == torch.float8_e4m3fn, (
@@ -29,8 +29,7 @@ from vllm.utils.flashinfer import (
class FlashInferCuteDSLExperts(mk.FusedMoEExpertsModular):
"""
CuteDSL NvFP4 MoE experts using the FlashInfer functional API.
"""CuteDSL NvFP4 MoE experts using the FlashInfer functional API.
Uses Standard activation format (non-batched). The kernel handles
routing, expert computation, and reduction internally.
@@ -38,8 +38,7 @@ logger = init_logger(__name__)
def is_valid_flashinfer_cutlass_fused_moe(
hidden_states: torch.Tensor, w1: torch.Tensor, w2: torch.Tensor
) -> bool:
"""
Check if the given problem size is supported by the FlashInfer CUTLASS MoE
"""Check if the given problem size is supported by the FlashInfer CUTLASS MoE
kernel.
"""
if not has_flashinfer_cutlass_fused_moe():
@@ -219,8 +218,7 @@ class FlashInferExperts(mk.FusedMoEExpertsModular):
) -> tuple[tuple[int, ...], tuple[int, ...], tuple[int, ...]]:
# We use global_num_experts due to how moe_align_block_size handles
# expert_maps.
"""
Compute the shapes for the temporary and final outputs of the two gemms
"""Compute the shapes for the temporary and final outputs of the two gemms
and activation in the fused expert function. Since the gemms are
independent, the workspace for the first gemm can be shared with the
workspace for the last gemm.
@@ -551,8 +551,7 @@ def invoke_moe_batched_triton_kernel(
class NaiveBatchedExperts(mk.FusedMoEExpertsModular):
"""
A reference MoE expert class that operates on expert batched format,
"""A reference MoE expert class that operates on expert batched format,
i.e. E x max_num_tokens x K. This is the format that the batched
dispatch/combine kernels use.
"""
@@ -775,8 +774,7 @@ def batched_moe_kernel_quantize_input(
class BatchedTritonExperts(mk.FusedMoEExpertsModular):
"""
A Triton based MoE expert class that operates on expert batched format,
"""A Triton based MoE expert class that operates on expert batched format,
i.e. E x max_num_tokens x K. This is the format that the batched
dispatch/combine kernels use.
"""
@@ -352,8 +352,7 @@ class HummingExpertsBase(mk.FusedMoEExpertsModular):
)
def _prequantizes_dispatch_activation(self) -> bool:
"""
Whether the prepare/finalize step should quantize activations before
"""Whether the prepare/finalize step should quantize activations before
the (EP all-to-all) dispatch instead of leaving it to Humming.
This is enabled only for block-FP8 (group-128) activations: quantizing
@@ -373,8 +372,7 @@ class HummingExpertsBase(mk.FusedMoEExpertsModular):
@property
def expects_unquantized_inputs(self) -> bool:
"""
Whether the prepare/finalize step should defer input quantization to
"""Whether the prepare/finalize step should defer input quantization to
the experts (by setting defer_input_quant=True and passing unquantized
inputs).
@@ -832,8 +830,7 @@ class HummingIndexedExperts(HummingExpertsBase):
expert_tokens_meta: mk.ExpertTokensMetadata | None,
apply_router_weight_on_input: bool,
) -> None:
"""
Standard apply implementation for Humming indexed experts.
"""Standard apply implementation for Humming indexed experts.
Note: Humming kernels handle weights internally through the layer
object, so w1, w2, a2_scale are unused. a1q_scale is None on the usual
@@ -967,8 +964,7 @@ class HummingGroupedExperts(HummingExpertsBase):
expert_tokens_meta: mk.ExpertTokensMetadata | None,
apply_router_weight_on_input: bool,
) -> None:
"""
Standard apply implementation for Humming grouped experts.
"""Standard apply implementation for Humming grouped experts.
Note: Humming kernels handle weights internally through the layer
object, so w1, w2, a2_scale are unused. a1q_scale is None on the usual
@@ -1090,8 +1086,7 @@ class BatchedHummingGroupedExperts(HummingExpertsBase):
expert_tokens_meta: mk.ExpertTokensMetadata | None,
apply_router_weight_on_input: bool,
) -> None:
"""
Standard apply implementation for Humming batched grouped experts.
"""Standard apply implementation for Humming batched grouped experts.
Note: Humming kernels handle weights internally through the layer
object, so w1, w2, a2_scale are unused. a1q_scale is None on the usual
@@ -502,8 +502,7 @@ def pack_bitmatrix(
BLOCK_SIZE_M: tl.constexpr,
BLOCK_SIZE_K: tl.constexpr,
):
"""
Packs topk_ids into a bitmatrix.
"""Packs topk_ids into a bitmatrix.
code reference:
https://github.com/triton-lang/triton/blob/dd1bbc52b34d202dfe5ffea1e04fb16166c5c04e/python/triton_kernels/bench/distributed.py#L264
"""
@@ -949,8 +948,7 @@ class BaseOAITritonExperts(mk.FusedMoEExpertsModular):
w2: torch.Tensor,
topk_ids: torch.Tensor,
) -> tuple[int, int, int, int, int]:
"""
Extract the MoE problem size from the given tensor arguments:
"""Extract the MoE problem size from the given tensor arguments:
- a: The hidden states, input to the MoE layer.
- w1: The first set of expert weights.
- w2: The second set of expert weights.
@@ -1075,8 +1073,7 @@ class OAITritonExperts(BaseOAITritonExperts):
class UnfusedOAITritonExperts(LoRAExpertsMixin, BaseOAITritonExperts):
"""
A Triton based MoE expert class that operates on expert standard
"""A Triton based MoE expert class that operates on expert standard
format and explicitly keeps the activation and reduction (moe_sum) steps
unfused from the matmul_ogs kernel. This exposes injection points
for activation and moe_sum.
@@ -10,8 +10,7 @@ from vllm.lora.punica_wrapper.punica_base import PunicaWrapperBase
@dataclass
class MoELoRAContext:
"""
Carries all LoRA state for one MoE forward pass.
"""Carries all LoRA state for one MoE forward pass.
Built by FusedMoEWithLoRA.forward() and propagated explicitly through the
modular kernel path (FusedMoEKernel -> FusedMoEExpertsModular.apply) so
@@ -7,8 +7,7 @@ from vllm.model_executor.layers.fused_moe.experts.lora_context import MoELoRACon
class LoRAExpertsMixin:
"""
Mixin for FusedMoEExpertsModular subclasses that natively handle
"""Mixin for FusedMoEExpertsModular subclasses that natively handle
MoELoRAContext inside their apply() implementation.
Mixing this class in:
@@ -251,26 +251,56 @@ def fused_marlin_moe(
input_dtype: torch.dtype | None = None,
activation_config: ApplyMoEActivationConfig | None = None,
) -> torch.Tensor:
"""
This function computes a Mixture of Experts (MoE) layer using two sets of
"""This function computes a Mixture of Experts (MoE) layer using two sets of
weights, w1 and w2, and top-k gating mechanism.
Parameters:
- hidden_states (torch.Tensor): The input tensor to the MoE layer.
- w1 (torch.Tensor): The first set of expert weights.
- w2 (torch.Tensor): The second set of expert weights.
- w1_scale (torch.Tensor): Scale to be used for w1.
- w2_scale (torch.Tensor): Scale to be used for w2.
- topk_weights (torch.Tensor): Top-k weights.
- topk_ids (torch.Tensor): Indices of topk-k elements.
- w1_zeros (torch.Tensor|None): Optional zero points to be used for w1.
- w2_zeros (torch.Tensor|None): Optional zero points to be used for w2.
- num_bits (bool): The number of bits in expert weights quantization.
Args:
hidden_states (torch.Tensor): The input tensor to the MoE layer.
w1 (torch.Tensor): The first set of expert weights.
w2 (torch.Tensor): The second set of expert weights.
bias1 (torch.Tensor|None): Optional bias for the first GEMM.
bias2 (torch.Tensor|None): Optional bias for the second GEMM.
w1_scale (torch.Tensor): Scale to be used for w1.
w2_scale (torch.Tensor): Scale to be used for w2.
topk_weights (torch.Tensor): Top-k weights.
topk_ids (torch.Tensor): Indices of topk-k elements.
quant_type_id (int): Id of the `ScalarType` the expert weights are
quantized to. Determines the 4- or 8-bit Marlin kernel path.
apply_router_weight_on_input (bool): Apply the topk weights to the
input rather than the output. Only valid when topk is 1.
global_num_experts (int): Total number of experts across all expert
parallel shards. -1 means the local expert count.
activation (MoEActivation): Activation applied between the two GEMMs.
activation_func (Callable|None): Override for the activation
implementation.
moe_sum (Callable|None): Override for the final reduction over the
topk dimension. Defaults to `ops.moe_sum` / `torch.sum`.
expert_map (torch.Tensor|None): Maps global expert indices to the
local expert space of this expert parallel shard.
input_global_scale1 (torch.Tensor|None): NVFP4 global input scale for
the first GEMM.
input_global_scale2 (torch.Tensor|None): NVFP4 global input scale for
the second GEMM.
global_scale1 (torch.Tensor|None): NVFP4 global weight scale for w1.
global_scale2 (torch.Tensor|None): NVFP4 global weight scale for w2.
w1_zeros (torch.Tensor|None): Optional zero points to be used for w1.
w2_zeros (torch.Tensor|None): Optional zero points to be used for w2.
workspace (torch.Tensor|None): Scratch buffer for the Marlin kernels.
intermediate_cache13 (torch.Tensor|None): Scratch buffer for the
first and third intermediate activations.
intermediate_cache2 (torch.Tensor|None): Scratch buffer for the
second intermediate activation.
output (torch.Tensor|None): Tensor to write the result into. A new
tensor is allocated when omitted.
input_dtype (torch.dtype|None): dtype the activations are quantized
to. A 1-byte dtype raises the M block size to at least 16.
activation_config (ApplyMoEActivationConfig|None): Extra
configuration forwarded to the activation.
Returns:
- torch.Tensor: The output tensor after applying the MoE layer.
"""
torch.Tensor: The output tensor after applying the MoE layer.
"""
quant_type = ScalarType.from_id(quant_type_id)
assert quant_type in [
scalar_types.uint4,
@@ -399,8 +429,7 @@ def batched_fused_marlin_moe(
activation_func: Callable[..., None] | None = None,
activation_config: ApplyMoEActivationConfig | None = None,
) -> torch.Tensor:
"""
This function massages the inputs so the batched hidden_states can be
"""This function massages the inputs so the batched hidden_states can be
presented as a 2D contiguous tensor that could be used with
_fused_marlin_moe.
@@ -423,7 +452,6 @@ def batched_fused_marlin_moe(
expert_ids tensors, so only relevant/valid rows of A (hidden_states)
are accessed and are processed with the correct expert_ids.
"""
assert hidden_states.ndim == 3, (
f"hidden states must be batched. e.g. [B, MAX_TOKENS, K]."
f"But got {hidden_states.size()}"
@@ -34,7 +34,8 @@ from vllm.triton_utils import tl, triton
def _select_cfg(M, N, K, block_m):
"""Pick the launch config from host constants only (M=num_valid_tokens, N, K,
block_m) — graph-capture safe (no GPU-scalar branch)."""
block_m) — graph-capture safe (no GPU-scalar branch).
"""
# Per-regime winners (measured, isolated cuda-event A/B on gfx950, GPU 3):
# BLOCK_K=256 (fewer K-iters + bigger MX scale-load coalesced with the dot),
# num_stages=2 (software-pipeline overlaps the E8M0 scale-load with the scaled
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
NVFP4 quantization emulation for MoE.
"""NVFP4 quantization emulation for MoE.
This file implements NVFP4 emulation for NVFP4 MOE in case the hardware used does not
natively support NVFP4 MOE.
@@ -86,8 +85,7 @@ def fused_moe_nvfp4_emulation_kernel(
compute_type: tl.constexpr,
group_size: tl.constexpr,
):
"""
Fused MoE kernel for emulated NVFP4 weight-only dequantization + GEMM.
"""Fused MoE kernel for emulated NVFP4 weight-only dequantization + GEMM.
Activations A are BF16 (already QDQ'd externally).
Weights B are packed uint8 NVFP4 [E, N, K//2] — two FP4 values per byte
@@ -334,8 +332,7 @@ def invoke_fused_moe_nvfp4_emulation_kernel(
class Nvfp4QuantizationEmulationTritonExperts(TritonExperts):
"""
Extension of TritonExperts to support emulated NVFP4 MoE experts.
"""Extension of TritonExperts to support emulated NVFP4 MoE experts.
It may be used for NVFP4 models when the device does not have
native support for this dtype.
@@ -427,8 +424,7 @@ class Nvfp4QuantizationEmulationTritonExperts(TritonExperts):
expert_tokens_meta: mk.ExpertTokensMetadata | None,
apply_router_weight_on_input: bool,
):
"""
Apply emulated quantized MoE computation.
"""Apply emulated quantized MoE computation.
This dequantizes the weights on the fly and calls fused_experts_impl
with activation quantization support.
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
OCP MX quantization emulation for MoE.
"""OCP MX quantization emulation for MoE.
This file implements OCP MX (MXFP4/MXFP6) emulation for MoE in case the
hardware used does not natively support OCP MX MoE.
@@ -50,6 +49,7 @@ def activation_quant_dtype(
Raises:
NotImplementedError: If the scheme has no emulated activation dtype.
"""
if ocp_mx_scheme in {
OCP_MX_Scheme.w_mxfp4,
@@ -82,8 +82,7 @@ def activation_quant_dtype(
class OCP_MXQuantizationEmulationTritonExperts(TritonExperts):
"""
Extension of TritonExperts to support emulated OCP MX MoE experts.
"""Extension of TritonExperts to support emulated OCP MX MoE experts.
It may be used for OCP MX (MXFP4/MXFP6) models when the device does not
have native support for these dtypes.
@@ -190,8 +189,7 @@ class OCP_MXQuantizationEmulationTritonExperts(TritonExperts):
expert_tokens_meta: mk.ExpertTokensMetadata | None,
apply_router_weight_on_input: bool,
):
"""
Apply emulated quantized MoE computation.
"""Apply emulated quantized MoE computation.
This dequantizes the weights on the fly and calls TritonExperts.apply
with activation quantization support.
@@ -32,8 +32,7 @@ from vllm.utils.flashinfer import has_flashinfer_trtllm_fused_moe
class TrtLlmBf16ExpertsBase:
"""
BF16 unquantized TRTLLM-Gen MoE kernels. Shared base for modular and
"""BF16 unquantized TRTLLM-Gen MoE kernels. Shared base for modular and
monolithic interfaces.
"""
@@ -124,9 +123,7 @@ class TrtLlmBf16ExpertsBase:
class TrtLlmBf16ExpertsModular(TrtLlmBf16ExpertsBase, mk.FusedMoEExpertsModular):
"""
BF16 unquantized TRTLLM-Gen MoE kernels. Supports modular interface.
"""
"""BF16 unquantized TRTLLM-Gen MoE kernels. Supports modular interface."""
@staticmethod
def _supports_parallel_config(
@@ -224,9 +221,7 @@ class TrtLlmBf16ExpertsModular(TrtLlmBf16ExpertsBase, mk.FusedMoEExpertsModular)
class TrtLlmBf16ExpertsMonolithic(TrtLlmBf16ExpertsBase, mk.FusedMoEExpertsMonolithic):
"""
BF16 unquantized TRTLLM-Gen MoE kernels. Supports monolithic interface.
"""
"""BF16 unquantized TRTLLM-Gen MoE kernels. Supports monolithic interface."""
@staticmethod
def _supports_parallel_config(
@@ -58,8 +58,7 @@ def prepare_deepseek_fp8_x_sf(x: torch.Tensor, x_sf: torch.Tensor) -> torch.Tens
class TrtLlmFp8ExpertsBase:
"""
Fp8 TRTLLM-Gen MoE kernels. Shared base for modular and monolithic
"""Fp8 TRTLLM-Gen MoE kernels. Shared base for modular and monolithic
interfaces.
"""
@@ -194,9 +193,7 @@ class TrtLlmFp8ExpertsBase:
class TrtLlmFp8ExpertsModular(TrtLlmFp8ExpertsBase, mk.FusedMoEExpertsModular):
"""
Fp8 TRTLLM-Gen MoE kernels. Supports modular interface.
"""
"""Fp8 TRTLLM-Gen MoE kernels. Supports modular interface."""
@staticmethod
def _supports_parallel_config(moe_parallel_config: FusedMoEParallelConfig) -> bool:
@@ -330,9 +327,7 @@ class TrtLlmFp8ExpertsModular(TrtLlmFp8ExpertsBase, mk.FusedMoEExpertsModular):
class TrtLlmFp8ExpertsMonolithic(TrtLlmFp8ExpertsBase, mk.FusedMoEExpertsMonolithic):
"""
Fp8 TRTLLM-Gen MoE kernels. Supports monolithic interface.
"""
"""Fp8 TRTLLM-Gen MoE kernels. Supports monolithic interface."""
def supports_routing_replay_capture(self) -> bool:
return True
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
LoRA-aware FlashInfer TRT-LLM MoE experts (BF16).
"""LoRA-aware FlashInfer TRT-LLM MoE experts (BF16).
Reuses the routed API + ``gemm1_lora_delta`` path from FlashInfer PR #3153:
@@ -109,7 +108,7 @@ def _finalize_lora_kernel(
class _TrtLlmLoRAExpertsBase(LoRAExpertsMixin, mk.FusedMoEExpertsModular):
"""LoRA-aware trtllm MoE experts"""
"""LoRA-aware trtllm MoE experts."""
def __init__(
self,
@@ -35,9 +35,7 @@ from vllm.utils.flashinfer import has_flashinfer
class TrtLlmMxfp4ExpertsBase:
"""
MXFP4 TRTLLM-Gen MoE kernels. Shared base for modular and monolithic.
"""
"""MXFP4 TRTLLM-Gen MoE kernels. Shared base for modular and monolithic."""
def __init__(
self,
@@ -164,8 +162,7 @@ class TrtLlmMxfp4ExpertsBase:
class TrtLlmMxfp4ExpertsMonolithic(
TrtLlmMxfp4ExpertsBase, mk.FusedMoEExpertsMonolithic
):
"""
Monolithic version of the MXFP4 TRTLLM kernel (router + experts).
"""Monolithic version of the MXFP4 TRTLLM kernel (router + experts).
Wraps flashinfer.trtllm_fp4_block_scale_moe().
"""
@@ -287,8 +284,7 @@ class TrtLlmMxfp4ExpertsMonolithic(
class TrtLlmMxfp4ExpertsModular(TrtLlmMxfp4ExpertsBase, mk.FusedMoEExpertsModular):
"""
Modular version of the MXFP4 TRTLLM kernel (just the experts).
"""Modular version of the MXFP4 TRTLLM kernel (just the experts).
Wraps flashinfer.trtllm_fp4_block_scale_routed_moe().
Moved from trtllm_moe.py.
"""
@@ -19,8 +19,7 @@ from vllm.platforms import current_platform
class TrtLlmMxint4ExpertsMonolithic(mk.FusedMoEExpertsMonolithic):
"""
FlashInfer TRT-LLM MxInt4 MoE kernel. Monolithic interface
"""FlashInfer TRT-LLM MxInt4 MoE kernel. Monolithic interface
(fused router + experts).
Wraps flashinfer_trtllm_mxint4_moe().
@@ -42,9 +42,7 @@ _PER_TOKEN_BASE_GLOBAL_SCALE = 1.0 / (448.0 * 6.0)
class TrtLlmNvFp4ExpertsBase:
"""
NvFp4 TRTLLM-Gen MoE kernels. Supports modular and monolithic interface.
"""
"""NvFp4 TRTLLM-Gen MoE kernels. Supports modular and monolithic interface."""
def __init__(
self,
@@ -300,9 +298,7 @@ class TrtLlmNvFp4ExpertsBase:
class TrtLlmNvFp4ExpertsModular(TrtLlmNvFp4ExpertsBase, mk.FusedMoEExpertsModular):
"""
Modular version of the implementation (just the experts).
"""
"""Modular version of the implementation (just the experts)."""
@staticmethod
def _supports_parallel_config(moe_parallel_config: FusedMoEParallelConfig) -> bool:
@@ -467,9 +463,7 @@ class TrtLlmNvFp4ExpertsModular(TrtLlmNvFp4ExpertsBase, mk.FusedMoEExpertsModula
class TrtLlmNvFp4ExpertsMonolithic(
TrtLlmNvFp4ExpertsBase, mk.FusedMoEExpertsMonolithic
):
"""
Monolithic version of the kernel (router + experts).
"""
"""Monolithic version of the kernel (router + experts)."""
def supports_routing_replay_capture(self) -> bool:
return True