Skip to content

Commit f5003e0

Browse files
committed
add warning suppression for op override
Signed-off-by: Andrea Fasoli <andrea.fasoli@ibm.com>
1 parent ce20be8 commit f5003e0

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

fms_mo/aiu_addons/fp8/fp8_spyre_op.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
# Standard
1717
from typing import Optional
18+
import warnings
1819

1920
# Third Party
2021
from torch import Tensor
@@ -87,8 +88,15 @@ def _scaled_mm_cpu(
8788
# In PyTorch 2.8+, use torch.library.impl to override the native CPU kernel
8889
# The py_kernels dictionary assignment no longer works to override native kernels
8990
# Note: default overload is registered without the ".default" suffix
90-
torch.library.impl("aten::_scaled_mm.out", "CPU")(_scaled_mm_cpu_out)
91-
torch.library.impl("aten::_scaled_mm", "CPU")(_scaled_mm_cpu)
91+
# Suppress the UserWarning about overriding a previously registered kernel
92+
with warnings.catch_warnings():
93+
warnings.filterwarnings(
94+
"ignore",
95+
category=UserWarning,
96+
message=".*Overriding a previously registered kernel.*",
97+
)
98+
torch.library.impl("aten::_scaled_mm.out", "CPU")(_scaled_mm_cpu_out)
99+
torch.library.impl("aten::_scaled_mm", "CPU")(_scaled_mm_cpu)
92100
else:
93101
torch.library.register_kernel(
94102
torch.ops.aten._scaled_mm.out, "cpu", _scaled_mm_cpu_out

0 commit comments

Comments
 (0)