Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d14f20b
add humming moe backend to all fused moe oracles
jinzhen-lin May 4, 2026
2c86fcd
Merge remote-tracking branch 'origin2/main' into humming-backend
jinzhen-lin May 6, 2026
166ddde
add humming linear kernel support
jinzhen-lin May 10, 2026
b115b59
fix pre-commit
jinzhen-lin May 10, 2026
b5f299a
Merge remote-tracking branch 'origin2/main' into humming-backend
jinzhen-lin Jun 20, 2026
207a706
update
jinzhen-lin Jun 20, 2026
6687e74
fix pre-commit
jinzhen-lin Jun 20, 2026
beb0999
update
jinzhen-lin Jun 20, 2026
4ecb8f5
many fixes
jinzhen-lin Jun 20, 2026
1a06dc8
fix pre-commit
jinzhen-lin Jun 20, 2026
6f5887c
Merge remote-tracking branch 'origin2/main' into humming-backend
jinzhen-lin Jun 23, 2026
626aa82
add lm-eval tests
jinzhen-lin Jun 23, 2026
ae90542
Update humming-kernels version to 0.1.7
jinzhen-lin Jun 26, 2026
25247c3
Merge branch 'main' into humming-backend
jinzhen-lin Jun 27, 2026
841b1e2
Merge main into humming-backend: rework humming MoE/linear onto #43373
mgoin Jun 29, 2026
02e4300
refactor: keep humming kernel-format knowledge in the MoE oracles
mgoin Jun 30, 2026
23c9477
fix humming import
jinzhen-lin Jun 30, 2026
de9ed1a
fix humming import
jinzhen-lin Jun 30, 2026
7265e1c
test linear backend with moe models that have quantized linear weight
jinzhen-lin Jun 30, 2026
c2b3931
avoid use deepgemm when humming is selected
jinzhen-lin Jun 30, 2026
b0a532c
fix errors
jinzhen-lin Jun 30, 2026
6ba8b2f
fix pre-commit
jinzhen-lin Jun 30, 2026
fe03d17
fix bugs
jinzhen-lin Jun 30, 2026
7803a49
fix errors
jinzhen-lin Jul 1, 2026
85db7dc
try remove Qwen3.5-4B-quantized.w4a16
jinzhen-lin Jul 1, 2026
45a2cb4
update humming-kernels to 0.1.8
jinzhen-lin Jul 1, 2026
e0fd192
Merge branch 'main' of github.com:vllm-project/vllm into humming-backend
jinzhen-lin Jul 1, 2026
62eb762
update humming-kernels to 0.1.9
jinzhen-lin Jul 1, 2026
48e9fe7
add Qwen3.5-4B-quantized.w4a16
jinzhen-lin Jul 1, 2026
5c00887
test with tar.gz
jinzhen-lin Jul 2, 2026
7094fd4
change test order
jinzhen-lin Jul 2, 2026
34b96ed
Merge branch 'main' into humming-backend
jinzhen-lin Jul 2, 2026
86e36f3
try latest humming-kernels
jinzhen-lin Jul 2, 2026
965ff97
Merge branch 'humming-backend' of github.com:jinzhen-lin/vllm into hu…
jinzhen-lin Jul 2, 2026
6095bb1
try running Qwen3.5-4B-quantized.w4a16 without humming
jinzhen-lin Jul 2, 2026
8328ad5
use humming-kernels 0.1.10 and remove Qwen3.5-4B-quantized.w4a16
jinzhen-lin Jul 2, 2026
8556751
add optional=true
jinzhen-lin Jul 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vllm/model_executor/layers/fused_moe/fused_humming_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(
num_dispatchers: int | None = None,
):
self.layer = layer
self.num_experts = self.layer.num_experts
self.num_experts = self.layer.local_num_experts
self.global_num_experts = self.layer.global_num_experts
self.init_humming_moe()

Expand Down
58 changes: 58 additions & 0 deletions vllm/model_executor/layers/fused_moe/oracle/fp8.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from enum import Enum
from typing import Any

import torch

Expand Down Expand Up @@ -49,6 +50,7 @@ class Fp8MoeBackend(Enum):
DEEPGEMM = "DEEPGEMM"
BATCHED_DEEPGEMM = "BATCHED_DEEPGEMM"
MARLIN = "MARLIN"
HUMMING = "HUMMING"
TRITON = "TRITON"
BATCHED_TRITON = "BATCHED_TRITON"
AITER = "AITER"
Expand Down Expand Up @@ -76,6 +78,7 @@ def _get_priority_backends(
Fp8MoeBackend.VLLM_CUTLASS,
Fp8MoeBackend.TRITON,
Fp8MoeBackend.MARLIN,
Fp8MoeBackend.HUMMING,
Fp8MoeBackend.BATCHED_DEEPGEMM,
Fp8MoeBackend.BATCHED_VLLM_CUTLASS,
Fp8MoeBackend.BATCHED_TRITON,
Expand Down Expand Up @@ -137,6 +140,15 @@ def backend_to_kernel_cls(

return [BatchedDeepGemmExperts]

elif backend == Fp8MoeBackend.HUMMING:
import vllm.model_executor.layers.fused_moe.fused_humming_moe as humming_moe

return [
humming_moe.BatchedHummingGroupedExperts,
humming_moe.HummingGroupedExperts,
humming_moe.HummingIndexedExperts,
]

elif backend == Fp8MoeBackend.MARLIN:
from vllm.model_executor.layers.fused_moe.fused_marlin_moe import (
MarlinExperts,
Expand Down Expand Up @@ -199,6 +211,7 @@ def map_fp8_backend(runner_backend: MoEBackend) -> Fp8MoeBackend:
"flashinfer_trtllm": Fp8MoeBackend.FLASHINFER_TRTLLM,
"flashinfer_cutlass": Fp8MoeBackend.FLASHINFER_CUTLASS,
"marlin": Fp8MoeBackend.MARLIN,
"humming": Fp8MoeBackend.HUMMING,
"aiter": Fp8MoeBackend.AITER,
}
if backend := mapping.get(runner_backend):
Expand Down Expand Up @@ -430,6 +443,34 @@ def convert_to_fp8_moe_kernel_format(
)
elif fp8_backend == Fp8MoeBackend.AITER:
w13, w2 = rocm_aiter_ops.shuffle_weights(w13, w2)
elif fp8_backend == Fp8MoeBackend.HUMMING:
from vllm.model_executor.layers.quantization.utils.humming_utils import (
prepare_humming_moe_layer,
)

quant_config: dict[str, Any]
weight_block_size = getattr(layer, "weight_block_size", None)
quant_method_name = layer.quant_method.__class__.__name__
if "CompressedTensors" in quant_method_name:
from compressed_tensors.quantization import QuantizationArgs

weight_quant = getattr(layer.quant_method, "weight_quant", None)
assert isinstance(weight_quant, QuantizationArgs)
quant_config = weight_quant.model_dump()
quant_config["quant_method"] = "compressed-tensors"
quant_config["format"] = "float-quantized"
elif "ModelOptMxfp8" in quant_method_name:
quant_config = {"quant_method": "modelopt", "quant_algo": "mxfp8"}
else:
quant_config = {"quant_method": "fp8"}
if weight_block_size is not None:
quant_config["weight_block_size"] = weight_block_size

prepare_humming_moe_layer(layer, quant_config)
w13 = layer.w13_weight
w2 = layer.w2_weight
w13_scale = layer.w13_weight_scale
w2_scale = layer.w2_weight_scale
elif fp8_backend == Fp8MoeBackend.MARLIN:
weight_block_size = getattr(layer, "weight_block_size", None)
if weight_block_size == [1, 32]:
Expand Down Expand Up @@ -494,6 +535,7 @@ def make_fp8_moe_quant_config(
block_shape: list[int] | None = None,
per_act_token_quant: bool = False,
per_out_ch_quant: bool = False,
layer: torch.nn.Module | None = None,
) -> FusedMoEQuantConfig:
"""
Create FusedMoEQuantConfig for the specified FP8 Backend.
Expand All @@ -515,6 +557,14 @@ def make_fp8_moe_quant_config(
w2_scale=w2_scale,
block_shape=block_shape,
)
elif fp8_backend == Fp8MoeBackend.HUMMING:
from vllm.model_executor.layers.fused_moe.layer import FusedMoE
from vllm.model_executor.layers.quantization.utils.humming_utils import (
get_humming_moe_quant_config,
)

assert isinstance(layer, FusedMoE)
return get_humming_moe_quant_config(layer)

# Flashinfer CUTLASS per-tensor uses single dq scale
# (alpha = w_scale * a_scale) and inverse a2 scale.
Expand Down Expand Up @@ -564,6 +614,7 @@ def make_fp8_moe_kernel(
fp8_backend: Fp8MoeBackend,
routing_tables: tuple[torch.Tensor, torch.Tensor, torch.Tensor] | None = None,
shared_experts: SharedExperts | None = None,
layer: torch.nn.Module | None = None,
) -> mk.FusedMoEKernel:
# Create Prepare/Finalize.
prepare_finalize = maybe_make_prepare_finalize(
Expand All @@ -577,6 +628,11 @@ def make_fp8_moe_kernel(

logger.info_once("Using %s", prepare_finalize.__class__.__name__)

extra_kwargs = {}
if fp8_backend == Fp8MoeBackend.HUMMING:
assert layer is not None
extra_kwargs = {"layer": layer}

# Create Experts.
if prepare_finalize.activation_format == mk.FusedMoEActivationFormat.BatchedExperts:
max_num_tokens = prepare_finalize.max_num_tokens_per_rank()
Expand All @@ -586,11 +642,13 @@ def make_fp8_moe_kernel(
quant_config=moe_quant_config,
max_num_tokens=max_num_tokens,
num_dispatchers=prepare_finalize.num_dispatchers(),
**extra_kwargs,
)
else:
experts = experts_cls(
moe_config=moe_config,
quant_config=moe_quant_config,
**extra_kwargs,
)

# NOTE(rob): we only want the mk to control the shared_expert
Expand Down
82 changes: 81 additions & 1 deletion vllm/model_executor/layers/fused_moe/oracle/int8.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from vllm.model_executor.layers.fused_moe.runner.shared_experts import (
SharedExperts,
)
from vllm.model_executor.layers.quantization.utils import replace_parameter
from vllm.model_executor.layers.quantization.utils.quant_utils import (
QuantKey,
kInt8DynamicTokenSym,
Expand All @@ -31,6 +32,7 @@

class Int8MoeBackend(Enum):
TRITON = "TRITON"
HUMMING = "HUMMING"


def _get_priority_backends(
Expand All @@ -39,7 +41,7 @@ def _get_priority_backends(
"""
Get available backends in priority order based on platform and config.
"""
return [Int8MoeBackend.TRITON]
return [Int8MoeBackend.TRITON, Int8MoeBackend.HUMMING]


def backend_to_kernel_cls(
Expand All @@ -52,6 +54,15 @@ def backend_to_kernel_cls(

return [TritonExperts]

elif backend == Int8MoeBackend.HUMMING:
import vllm.model_executor.layers.fused_moe.fused_humming_moe as humming_moe

return [
humming_moe.BatchedHummingGroupedExperts,
humming_moe.HummingGroupedExperts,
humming_moe.HummingIndexedExperts,
]

else:
raise ValueError(f"Unknown Int8 MoE backend: {backend.value}")

Expand All @@ -60,6 +71,7 @@ def map_int8_backend(runner_backend: MoEBackend) -> Int8MoeBackend:
"""Map user's MoEBackend to Int8MoeBackend."""
mapping = {
"triton": Int8MoeBackend.TRITON,
"humming": Int8MoeBackend.HUMMING,
}
if backend := mapping.get(runner_backend):
return backend
Expand Down Expand Up @@ -149,16 +161,29 @@ def _return_or_raise(


def make_int8_moe_quant_config(
int8_backend: Int8MoeBackend,
w1_scale: torch.Tensor,
w2_scale: torch.Tensor,
a1_scale: torch.Tensor | None = None,
a2_scale: torch.Tensor | None = None,
per_act_token_quant: bool = False,
layer: torch.nn.Module | None = None,
) -> FusedMoEQuantConfig:
assert (a1_scale is None and a2_scale is None) or (
a1_scale is not None and a2_scale is not None
), "a1_scale and a2_scale must both be provided or both be None"

if int8_backend == Int8MoeBackend.HUMMING:
from vllm.model_executor.layers.fused_moe.layer import FusedMoE
from vllm.model_executor.layers.quantization.utils.humming_utils import (
get_humming_moe_quant_config,
)

assert isinstance(layer, FusedMoE)
return get_humming_moe_quant_config(layer)

assert int8_backend == Int8MoeBackend.TRITON

if a1_scale is None or a2_scale is None:
return int8_w8a16_moe_quant_config(
w1_scale=w1_scale,
Expand All @@ -176,12 +201,60 @@ def make_int8_moe_quant_config(
)


def convert_to_int8_moe_kernel_format(
int8_backend: Int8MoeBackend,
layer: torch.nn.Module,
w13: torch.Tensor,
w2: torch.Tensor,
w13_scale: torch.Tensor,
w2_scale: torch.Tensor,
w13_input_scale: torch.Tensor | None,
w2_input_scale: torch.Tensor | None,
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]:
if int8_backend == Int8MoeBackend.HUMMING:
from vllm.model_executor.layers.quantization.utils.humming_utils import (
prepare_humming_moe_layer,
)

quant_method_name = layer.quant_method.__class__.__name__
if "CompressedTensors" in quant_method_name:
from compressed_tensors.quantization import QuantizationArgs

weight_quant = getattr(layer.quant_method, "weight_quant", None)
assert isinstance(weight_quant, QuantizationArgs)
quant_config = weight_quant.model_dump()
quant_config["quant_method"] = "compressed-tensors"
quant_config["format"] = "int-quantized"
else:
assert "Int8Online" in quant_method_name
replace_parameter(layer, "w13_weight", (w13 + 128).view(torch.int32))
replace_parameter(layer, "w2_weight", (w2 + 128).view(torch.int32))
w13_scale = w13_scale.to(layer.params_dtype).unsqueeze(-1)
w2_scale = w2_scale.to(layer.params_dtype).unsqueeze(-1)
layer.w13_weight_scale = torch.nn.Parameter(w13_scale, requires_grad=False)
layer.w2_weight_scale = torch.nn.Parameter(w2_scale, requires_grad=False)
quant_config = {"quant_method": "humming", "dtype": "int8"}

prepare_humming_moe_layer(layer, quant_config)

return (
layer.w13_weight,
layer.w2_weight,
layer.w13_weight_scale,
layer.w2_weight_scale,
)

return w13, w2, w13_scale, w2_scale


def make_int8_moe_kernel(
int8_backend: Int8MoeBackend,
moe_quant_config: FusedMoEQuantConfig,
moe_config: FusedMoEConfig,
experts_cls: type[mk.FusedMoEExperts],
routing_tables: tuple[torch.Tensor, torch.Tensor, torch.Tensor] | None = None,
shared_experts: SharedExperts | None = None,
layer: torch.nn.Module | None = None,
) -> mk.FusedMoEKernel:
# Create Prepare/Finalize.
prepare_finalize = maybe_make_prepare_finalize(
Expand All @@ -195,6 +268,11 @@ def make_int8_moe_kernel(

logger.info_once("Using %s", prepare_finalize.__class__.__name__)

extra_kwargs = {}
if int8_backend == Int8MoeBackend.HUMMING:
assert layer is not None
extra_kwargs = {"layer": layer}

# Create Experts.
if prepare_finalize.activation_format == mk.FusedMoEActivationFormat.BatchedExperts:
max_num_tokens = prepare_finalize.max_num_tokens_per_rank()
Expand All @@ -204,11 +282,13 @@ def make_int8_moe_kernel(
quant_config=moe_quant_config,
max_num_tokens=max_num_tokens,
num_dispatchers=prepare_finalize.num_dispatchers(),
**extra_kwargs,
)
else:
experts = experts_cls(
moe_config=moe_config,
quant_config=moe_quant_config,
**extra_kwargs,
)

kernel = mk.FusedMoEKernel(
Expand Down
Loading
Loading