[XPU] Ensure unquantized linear weight is N-contiguous (#53536)

Signed-off-by: Zhu, Zufang <zufang.zhu@intel.com>
Co-authored-by: opencode <noreply@opencode.ai>
This commit is contained in:
zofia
2026-08-31 16:01:24 +08:00
committed by GitHub
co-authored by opencode
parent fdbf2ddbd2
commit 2a61f060d3
2 changed files with 16 additions and 0 deletions
+11
View File
@@ -213,6 +213,17 @@ class UnquantizedLinearMethod(LinearMethodBase):
from vllm.model_executor.layers.utils import dispatch_cpu_unquantized_gemm
dispatch_cpu_unquantized_gemm(layer, remove_weight=True)
elif current_platform.is_xpu():
# Opt-in: F.linear on XPU is faster with an N-contiguous (N, K) weight
# when K > N, but oneDNN's ab-weights matmul is not run-to-run bitwise
# bitwise reproducible. Off by default.
weight = layer.weight.data
if (
envs.VLLM_XPU_FORCE_N_CONTIG_WEIGHT
and weight.ndim == 2
and weight.stride(0) != 1
):
layer.weight.data = weight.t().contiguous().t()
def apply(
self,