Use has_triton_package in _inductor.runtime.hints (#147442)

Fixes #ISSUE_NUMBER
Use existing method for triton check

Pull Request resolved: https://github.com/pytorch/pytorch/pull/147442
Approved by: https://github.com/Skylion007
This commit is contained in:
dilililiwhy 2025-02-21 05:51:58 +00:00 committed by PyTorch MergeBot
parent 533b884870
commit 86ae672b6a

View File

@ -7,6 +7,8 @@ import typing
from enum import auto, Enum
from typing import Optional, Union
from torch.utils._triton import has_triton_package
# The following maximums only apply to runtime autotuning, when using FixedTritonConfig one may see larger values
# NOTE: if these fail asserts submit a PR to increase them
@ -32,17 +34,9 @@ class TileHint(Enum):
DEFAULT = 1
def _is_triton_available() -> bool:
try:
import triton # noqa: F401
return True
except ImportError:
return False
# Define `AttrsDescriptorWrapper` function with clear conditional handling
if _is_triton_available():
if has_triton_package():
import triton
import triton.backends.compiler
import triton.compiler.compiler