Skip to content

Commit

Permalink
Make CI error on inductor fallback when decomp is available (#99473)
Browse files Browse the repository at this point in the history
Fixes #99446

Remove the warning, as that annoyed end-users who don't know what to do about it.

Instead, try to hold the line by preventing any decomp from being added without making
the corresponding change to inductor's fallbacks.

Note: we probably still need to better document how to update inductor's decomps,
for now it's pretty much "go ask the inductor team for advice"

Pull Request resolved: #99473
Approved by: https://github.com/ezyang, https://github.com/ngimel, https://github.com/jansel
  • Loading branch information
wconstab authored and pytorchmergebot committed Apr 21, 2023
1 parent deaf983 commit 63690af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions torch/_decomp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def core_aten_decompositions() -> Dict[OpOverload, Callable]:
aten.elu_backward,
aten._embedding_bag,
aten.embedding_dense_backward,
aten._euclidean_dist.default,
aten.expand_as,
aten.eye,
aten.fill,
Expand Down
23 changes: 20 additions & 3 deletions torch/_inductor/lowering.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
type_to_dtype,
)
from torch.fx.experimental.symbolic_shapes import magic_methods, method_to_operator
from torch.testing._internal.common_utils import IS_CI
from torch.utils._pytree import tree_flatten
from .._dynamo.utils import import_submodule

Expand Down Expand Up @@ -1107,9 +1108,22 @@ def make_fallback(kernel, layout_constraint=None, warn=True):
assert (
kernel not in decompositions
), f"both a fallback and a decomp for same kernel: {kernel}"
if get_decompositions([kernel]) and warn:
developer_warning(
f"make_fallback({kernel}): a decomposition exists, we should switch to it"
if get_decompositions([kernel]) and warn and IS_CI:
# Note: 'warn' is holdover from when this was a warning, but for ops that previously
# set warn=False we do not want a CI error.
# Ignore the 'suppress errors' configs in CI, as this particular warning happens on startup anyway and is not
# likely to be triggered preferentially on one CI config over another.
if torch._dynamo.config.suppress_errors:
torch._dynamo.config.suppress_errors = False
log.warning(
"A make_fallback error occured in suppress_errors config,"
" and suppress_errors is being disabled to surface it."
)
raise AssertionError(
f"make_fallback({kernel}): a decomposition exists, we should switch to it."
" To fix this error, either add a decomposition to core_aten_decompositions (preferred)"
" or inductor_decompositions, and delete the corresponding `make_fallback` line."
" Get help from the inductor team if unsure, don't pick arbitrarily to unblock yourself.",
)

add_needs_realized_inputs(kernel)
Expand Down Expand Up @@ -1481,6 +1495,9 @@ def apply_constraint(arg, fx_arg):
make_fallback(aten._linalg_eigh)
make_fallback(aten.zeros.names)

# fails accuracy on test_torch.py, and explicit fallback required to avoid warn=True on implicit
make_fallback(aten.exponential.default, warn=False)


@register_lowering(aten.clone)
def clone(x, *, memory_format=0):
Expand Down

0 comments on commit 63690af

Please sign in to comment.