Skip to content

Commit ba3820b

Browse files
author
Varun Sundar Rabindranath
committed
refactor no-op conditions
Signed-off-by: Varun Sundar Rabindranath <[email protected]>
1 parent 8893c78 commit ba3820b

File tree

1 file changed

+9
-3
lines changed
  • vllm/model_executor/layers/fused_moe

1 file changed

+9
-3
lines changed

vllm/model_executor/layers/fused_moe/layer.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,11 +1411,17 @@ def _maybe_make_contiguous(
14111411
"""
14121412
if p.ndim != 3:
14131413
return p
1414-
# Check if the last 2 dimensions are trasposed
1415-
is_transposed = p.stride(1) == 1 and p.stride(2) != 1
1416-
if p.is_contiguous() or not is_transposed or "weight_scale" not in name:
1414+
if p.is_contiguous():
1415+
# Already contiguous. do nothing.
1416+
return p
1417+
# p is non-contiguous. We only handle the case where the last 2
1418+
# dimensions of the scales tensor is transposed. We can handle
1419+
# other cases when they become relevant.
1420+
is_transposed_12 = p.stride(1) == 1 and p.stride(2) != 1
1421+
if "weight_scale" not in name or not is_transposed_12:
14171422
# do nothing.
14181423
return p
1424+
14191425
# Do not update the layer paramater as the layer's MoE operations would
14201426
# expect the parameter's tensor to the same shape / stride. Instead,
14211427
# make a new torch.nn.Parameter that is used just in the context of

0 commit comments

Comments
 (0)