[fix] CPUDNNLGEMMHandler pointer baked into inductor artifact (#32913)
Signed-off-by: dolpm <34420038+dolpm@users.noreply.github.com>
This commit is contained in:
+26
-9
@@ -2845,13 +2845,13 @@ if hasattr(torch.ops._C, "int8_scaled_mm_with_quant"):
|
||||
|
||||
class CPUDNNLGEMMHandler:
|
||||
def __init__(self) -> None:
|
||||
self.handler: int | None = None
|
||||
self.handler_tensor: torch.Tensor | None = None
|
||||
self.n = -1
|
||||
self.k = -1
|
||||
|
||||
def __del__(self):
|
||||
if self.handler is not None:
|
||||
torch.ops._C.release_dnnl_matmul_handler(self.handler)
|
||||
if self.handler_tensor is not None:
|
||||
torch.ops._C.release_dnnl_matmul_handler(self.handler_tensor.item())
|
||||
|
||||
|
||||
_supports_onednn = bool(hasattr(torch.ops._C, "create_onednn_mm_handler"))
|
||||
@@ -2867,8 +2867,10 @@ def create_onednn_mm(
|
||||
) -> CPUDNNLGEMMHandler:
|
||||
handler = CPUDNNLGEMMHandler()
|
||||
handler.k, handler.n = weight.size()
|
||||
handler.handler = torch.ops._C.create_onednn_mm_handler(
|
||||
weight, primitive_cache_size
|
||||
# store the handler pointer in a tensor it doesn't get inlined
|
||||
handler.handler_tensor = torch.tensor(
|
||||
torch.ops._C.create_onednn_mm_handler(weight, primitive_cache_size),
|
||||
dtype=torch.int64,
|
||||
)
|
||||
return handler
|
||||
|
||||
@@ -2880,7 +2882,7 @@ def onednn_mm(
|
||||
) -> torch.Tensor:
|
||||
output = torch.empty((*x.shape[0:-1], dnnl_handler.n), dtype=x.dtype)
|
||||
torch.ops._C.onednn_mm(
|
||||
output, x.reshape(-1, dnnl_handler.k), bias, dnnl_handler.handler
|
||||
output, x.reshape(-1, dnnl_handler.k), bias, dnnl_handler.handler_tensor
|
||||
)
|
||||
|
||||
return output
|
||||
@@ -2896,8 +2898,17 @@ def create_onednn_scaled_mm(
|
||||
) -> CPUDNNLGEMMHandler:
|
||||
handler = CPUDNNLGEMMHandler()
|
||||
handler.k, handler.n = weight.size()
|
||||
handler.handler = torch.ops._C.create_onednn_scaled_mm_handler(
|
||||
weight, weight_scales, output_type, dynamic_quant, use_azp, primitive_cache_size
|
||||
# store the handler pointer in a tensor so it doesn't get inlined
|
||||
handler.handler_tensor = torch.tensor(
|
||||
torch.ops._C.create_onednn_scaled_mm_handler(
|
||||
weight,
|
||||
weight_scales,
|
||||
output_type,
|
||||
dynamic_quant,
|
||||
use_azp,
|
||||
primitive_cache_size,
|
||||
),
|
||||
dtype=torch.int64,
|
||||
)
|
||||
return handler
|
||||
|
||||
@@ -2950,7 +2961,13 @@ def onednn_scaled_mm(
|
||||
bias: torch.Tensor | None,
|
||||
) -> torch.Tensor:
|
||||
torch.ops._C.onednn_scaled_mm(
|
||||
output, x, input_scale, input_zp, input_zp_adj, bias, dnnl_handler.handler
|
||||
output,
|
||||
x,
|
||||
input_scale,
|
||||
input_zp,
|
||||
input_zp_adj,
|
||||
bias,
|
||||
dnnl_handler.handler_tensor,
|
||||
)
|
||||
|
||||
return output
|
||||
|
||||
+1
-6
@@ -289,16 +289,11 @@ def use_aot_compile() -> bool:
|
||||
from vllm.model_executor.layers.batch_invariant import (
|
||||
vllm_is_batch_invariant,
|
||||
)
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.utils.torch_utils import is_torch_equal_or_newer
|
||||
|
||||
default_value = (
|
||||
"1"
|
||||
if is_torch_equal_or_newer("2.10.0.dev")
|
||||
and not disable_compile_cache()
|
||||
# Disabling AOT_COMPILE for CPU
|
||||
# See: https://github.com/vllm-project/vllm/issues/32033
|
||||
and not current_platform.is_cpu()
|
||||
if is_torch_equal_or_newer("2.10.0.dev") and not disable_compile_cache()
|
||||
else "0"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user