File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 12
12
find_spec ("triton" ) is not None
13
13
or find_spec ("pytorch-triton-xpu" ) is not None # Not compatible
14
14
)
15
+ if HAS_TRITON :
16
+ try :
17
+ from triton .backends import backends
18
+
19
+ # It's generally expected that x.driver exists and has
20
+ # an is_active method.
21
+ # The `x.driver and` check adds a small layer of safety.
22
+ active_drivers = [
23
+ x .driver for x in backends .values ()
24
+ if x .driver and x .driver .is_active ()
25
+ ]
26
+ if len (active_drivers ) != 1 :
27
+ logger .info (
28
+ "Triton is installed but %d active driver(s) found "
29
+ "(expected 1). Disabling Triton to prevent runtime errors." ,
30
+ len (active_drivers ))
31
+ HAS_TRITON = False
32
+ except ImportError :
33
+ # This can occur if Triton is partially installed or triton.backends
34
+ # is missing.
35
+ logger .warning (
36
+ "Triton is installed, but `triton.backends` could not be imported. "
37
+ "Disabling Triton." )
38
+ HAS_TRITON = False
39
+ except Exception as e :
40
+ # Catch any other unexpected errors during the check.
41
+ logger .warning (
42
+ "An unexpected error occurred while checking Triton active drivers:"
43
+ " %s. Disabling Triton." , e )
44
+ HAS_TRITON = False
15
45
16
46
if not HAS_TRITON :
17
47
logger .info ("Triton not installed or not compatible; certain GPU-related"
You can’t perform that action at this time.
0 commit comments