vllm.model_executor.layers.fused_moe.experts.cpu_int4_moe ¶
CPU INT4 W4A8 dynamic quantized fused MoE experts.
CPUExpertsInt4 ¶
Bases: FusedMoEExpertsMonolithic
CPU INT4 W4A8 dynamic quantized monolithic MoE experts.
Uses the dynamic_4bit_int_moe kernel for efficient 4-bit weight, 8-bit activation MoE inference on CPU.
Source code in vllm/model_executor/layers/fused_moe/experts/cpu_int4_moe.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
expects_unquantized_inputs property ¶
expects_unquantized_inputs: bool
Expects unquantized inputs (quantization happens in kernel).
_activation_kind ¶
_activation_kind(activation: MoEActivation) -> int
Convert MoEActivation to kernel activation kind integer.
Returns:
| Type | Description |
|---|---|
int | 0 = SwiGLU_Gu (SiLU(g)*u) |
int | 1 = SwiGLU_Ug (SiLU(u)*g) |
int | 2 = SiLU |
Source code in vllm/model_executor/layers/fused_moe/experts/cpu_int4_moe.py
_supports_activation staticmethod ¶
_supports_activation(activation: MoEActivation) -> bool
Supports SiLU and SwiGLU variants.
Source code in vllm/model_executor/layers/fused_moe/experts/cpu_int4_moe.py
_supports_parallel_config staticmethod ¶
_supports_parallel_config(
moe_parallel_config: FusedMoEParallelConfig,
) -> bool
Currently does not support expert parallelism.
Source code in vllm/model_executor/layers/fused_moe/experts/cpu_int4_moe.py
_supports_quant_scheme staticmethod ¶
Supports INT4 weights with INT8 dynamic activations.
This is W4A8 with: - Weights: 4-bit integer (stored as int8, packed to uint8 nibbles) Can be channel-wise or group-wise quantization - Activations: dynamic per-token 8-bit integer quantization
Source code in vllm/model_executor/layers/fused_moe/experts/cpu_int4_moe.py
_supports_router_logits_dtype staticmethod ¶
_supports_router_logits_dtype(
router_logits_dtype: dtype | None,
routing_method: RoutingMethodType,
) -> bool
Accepts any router logits dtype.
_supports_routing_method staticmethod ¶
_supports_routing_method(
routing_method: RoutingMethodType,
weight_key: QuantKey | None,
activation_key: QuantKey | None,
) -> bool
Supports standard routing methods.
Source code in vllm/model_executor/layers/fused_moe/experts/cpu_int4_moe.py
apply ¶
apply(
hidden_states: Tensor,
w1: Tensor,
w2: Tensor,
router_logits: Tensor,
activation: MoEActivation,
global_num_experts: int,
expert_map: Tensor | None,
a1q_scale: Tensor | None,
apply_router_weight_on_input: bool,
num_expert_group: int | None = None,
e_score_correction_bias: Tensor | None = None,
routed_scaling_factor: float | None = None,
topk_group: int | None = None,
) -> Tensor
Apply the monolithic 4-bit INT MoE forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hidden_states | Tensor | Input tensor [num_tokens, hidden_size] | required |
w1 | Tensor | Packed w13 weights (w1+w3 gated weights) | required |
w2 | Tensor | Packed w2 weights (down projection) | required |
router_logits | Tensor | Router output logits [num_tokens, num_experts] | required |
activation | MoEActivation | Activation function type | required |
global_num_experts | int | Total number of experts | required |
expert_map | Tensor | None | Expert mapping for EP (not supported) | required |
a1q_scale | Tensor | None | Activation quantization scale (not used, dynamic) | required |
apply_router_weight_on_input | bool | Whether to apply routing on input | required |
num_expert_group | int | None | For grouped topk | None |
e_score_correction_bias | Tensor | None | Bias for expert scores | None |
routed_scaling_factor | float | None | Scaling factor for routing | None |
topk_group | int | None | Group size for topk | None |
Returns:
| Type | Description |
|---|---|
Tensor | Output tensor after MoE computation |
Source code in vllm/model_executor/layers/fused_moe/experts/cpu_int4_moe.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |