[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:
@@ -315,6 +315,7 @@ if TYPE_CHECKING:
|
||||
VLLM_MEMORY_PROFILER_ESTIMATE_CUDAGRAPHS: bool = True
|
||||
VLLM_NIXL_EP_MAX_NUM_RANKS: int = 32
|
||||
VLLM_XPU_ENABLE_XPU_GRAPH: bool = False
|
||||
VLLM_XPU_FORCE_N_CONTIG_WEIGHT: bool = False
|
||||
VLLM_XPU_USE_SAMPLER_KERNEL: bool = True
|
||||
VLLM_XPU_INC_WNA16_BACKEND: Literal["auto", "ark", "w4a16", "w4a8"] = "auto"
|
||||
VLLM_LORA_ENABLE_DUAL_STREAM: bool = False
|
||||
@@ -2112,6 +2113,10 @@ environment_variables: dict[str, Callable[[], Any]] = {
|
||||
"VLLM_XPU_ENABLE_XPU_GRAPH": lambda: bool(
|
||||
int(os.getenv("VLLM_XPU_ENABLE_XPU_GRAPH", "0"))
|
||||
),
|
||||
# Force N-contiguous weight layout for all XPU unquantized linears.
|
||||
"VLLM_XPU_FORCE_N_CONTIG_WEIGHT": lambda: bool(
|
||||
int(os.getenv("VLLM_XPU_FORCE_N_CONTIG_WEIGHT", "0"))
|
||||
),
|
||||
# whether use xpu specific sample kernel
|
||||
"VLLM_XPU_USE_SAMPLER_KERNEL": lambda: bool(
|
||||
int(os.getenv("VLLM_XPU_USE_SAMPLER_KERNEL", "1"))
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user