Skip to content

Commit cc29588

Browse files
committed
feat(library): allow fallback when kernel fails
1 parent 4bffe4e commit cc29588

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

quanto/library/ops.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from contextlib import contextmanager
23

34
import torch
@@ -41,7 +42,13 @@ def define(name, schema):
4142
@torch.library.impl(f"quanto::{name}", "default")
4243
def impl(*args, **kwargs):
4344
if _ext_enabled:
44-
return getattr(torch.ops.quanto_ext, name)(*args, **kwargs)
45+
try:
46+
return getattr(torch.ops.quanto_ext, name)(*args, **kwargs)
47+
except Exception as e:
48+
warnings.warn(
49+
f"A {type(e)} exception occured while calling the optimized kernel for quanto::{name}."
50+
"Falling back to default implementation."
51+
)
4552
return getattr(torch.ops.quanto_py, name)(*args, **kwargs)
4653

4754

0 commit comments

Comments
 (0)