File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515
1616# Standard
1717from typing import Optional
18+ import warnings
1819
1920# Third Party
2021from 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 )
92100else :
93101 torch .library .register_kernel (
94102 torch .ops .aten ._scaled_mm .out , "cpu" , _scaled_mm_cpu_out
You can’t perform that action at this time.
0 commit comments