Skip to content

Commit 12cc6dd

Browse files
committed
fix
1 parent 7510955 commit 12cc6dd

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

vllm/envs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
VLLM_USE_FLASHINFER_MOE_MXFP4_BF16: bool = False
168168
VLLM_TUNED_CONFIG_FOLDER: Optional[str] = None
169169
VLLM_ROCM_USE_AITER_TRITON_FUSED_ROPE_ZEROS_KV_CACHE: bool = False
170+
VLLM_ROCM_USE_AITER_FUSED_MOE_A16W4: bool = False
170171

171172

172173
def get_default_cache_root():
@@ -1007,6 +1008,9 @@ def get_vllm_port() -> Optional[int]:
10071008
# BF16 (activation) x MXFP4 (weight) MoE backend.
10081009
"VLLM_USE_FLASHINFER_MOE_MXFP4_BF16":
10091010
lambda: bool(int(os.getenv("VLLM_USE_FLASHINFER_MOE_MXFP4_BF16", "0"))),
1011+
1012+
"VLLM_ROCM_USE_AITER_FUSED_MOE_A16W4":
1013+
lambda: bool(int(os.getenv("VLLM_ROCM_USE_AITER_FUSED_MOE_A16W4", "0"))),
10101014

10111015
# Control the cache sized used by the xgrammar compiler. The default
10121016
# of 512 MB should be enough for roughly 1000 JSON schemas.

vllm/model_executor/layers/quantization/mxfp4.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from flashinfer import (mxfp8_quantize, shuffle_matrix_a,
3434
shuffle_matrix_sf_a, trtllm_fp4_block_scale_moe)
3535

36-
if current_platform.is_rocm():
36+
if current_platform.is_rocm() and envs.VLLM_ROCM_USE_AITER_FUSED_MOE_A16W4:
3737
import aiter
3838
from aiter.fused_moe import fused_topk, moe_sorting
3939
from aiter.ops.shuffle import shuffle_mxfp4_weight, shuffle_mxfp4_scale
@@ -374,7 +374,7 @@ def swap_every_two_rows(x, axis=-1):
374374
else:
375375
num_warps = 8
376376

377-
if current_platform.is_rocm():
377+
if current_platform.is_rocm() and envs.VLLM_ROCM_USE_AITER_FUSED_MOE_A16W4:
378378
w13_aiter_weight = layer.w13_weight.contiguous()
379379
w13_aiter_scale = layer.w13_weight_scale.contiguous()
380380
w2_aiter_weight = layer.w2_weight.contiguous()
@@ -542,7 +542,7 @@ def apply(
542542
)[0]
543543
return trtllm_gen_output
544544
else:
545-
if current_platform.is_rocm():
545+
if current_platform.is_rocm() and envs.VLLM_ROCM_USE_AITER_FUSED_MOE_A16W4:
546546
token_num = x.shape[0]
547547
BLOCKM = 16 if token_num < 2048 else 32
548548
topk_weights, topk_ids = fused_topk(x, router_logits, top_k, True)
@@ -566,8 +566,8 @@ def apply(
566566
sorted_expert_ids,
567567
num_valid_ids,
568568
top_k,
569-
0, # n_pad_zeros
570-
0, # k_pad_zeros
569+
192, # n_pad_zeros
570+
128, # k_pad_zeros
571571
None, # sorted_weights
572572
None,
573573
self.w13_scale_aiter_tensor,
@@ -582,8 +582,8 @@ def apply(
582582
sorted_expert_ids,
583583
num_valid_ids,
584584
top_k,
585-
0, # n_pad_zeros
586-
0, # k_pad_zeros
585+
192, # n_pad_zeros
586+
128, # k_pad_zeros
587587
sorted_weights, # sorted_weights
588588
None,
589589
self.w2_scale_aiter_tensor,

0 commit comments

Comments
 (0)