[BE] [Inductor] Update NoValidChoicesError logic (#162814)

Summary: Updates the NoValidChoicesError logic to include some additional context for if not choices exists or if no choices compiled.

Test Plan:
NFC. Depending on CI.

Rollback Plan:

Differential Revision: D82312035

Pull Request resolved: https://github.com/pytorch/pytorch/pull/162814
Approved by: https://github.com/mlazos
This commit is contained in:
Nick Riasanovsky
2025-09-13 00:45:46 +00:00
committed by PyTorch MergeBot
parent ddc5107601
commit 595e13feb7

View File

@ -2426,19 +2426,20 @@ class AlgorithmSelectorCache(PersistentCache):
N = input_nodes[-1].get_size()[-1]
append_to_log(mm_file_name, {"invoke": str((M, K, N))})
def create_no_valid_choices() -> NoValidChoicesError:
def create_no_valid_choices(reason: str) -> NoValidChoicesError:
backend_config = (
"max_autotune_gemm_backends"
if name != "convolution"
else "max_autotune_conv_backends"
)
return NoValidChoicesError(
f"No choices to select, please consider adding ATEN into {backend_config} "
f"No choices to select. Provided reason: {reason} "
f"please consider adding ATEN into {backend_config} "
"config (defined in torch/_inductor/config.py) to allow at least one choice. "
)
if len(choices) == 0:
raise create_no_valid_choices()
raise create_no_valid_choices("No choices exist for backend.")
log.debug("Max autotune selects from %s choices.", str(len(choices)))
if len(choices) == 1:
@ -2498,7 +2499,9 @@ class AlgorithmSelectorCache(PersistentCache):
# Prune anything that failed to compile
choices = [c for c in choices if not c.failed]
if len(choices) == 0:
raise create_no_valid_choices()
raise create_no_valid_choices(
"All choices failed to compile for backend."
)
candidates = self.prescreen_choices(
choices, name, inputs_key, self.prescreening_cache