Skip to content

Commit 5ed2f82

Browse files
committed
Create tiny_config.
(cherry picked from commit 9f19754) (cherry picked from commit dee2fdf)
1 parent f80f0b8 commit 5ed2f82

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

torch/_inductor/runtime/triton_heuristics.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,27 +2108,31 @@ def _persistent_reduction_configs(
21082108
if xblock == 1 or (xblock <= xnumel and (max_autotune_enabled or rnumel * xblock <= 4096))
21092109
]
21102110

2111+
tiny_configs = [
2112+
triton_config_reduction(
2113+
size_hints,
2114+
2 * (256 // rnumel) if rnumel <= 256 else 1,
2115+
rnumel,
2116+
)
2117+
]
2118+
2119+
# defer to more autotuning, initially
2120+
if "y" in size_hints:
2121+
pass
21112122
# TODO(jansel): we should be able to improve these heuristics
2112-
if not max_autotune_enabled: # Don't filter if tuning enabled
2123+
elif not max_autotune_enabled: # Don't filter if tuning enabled
21132124
if reduction_hint == ReductionHint.INNER and rnumel >= 256:
21142125
configs = configs[:1]
21152126
elif reduction_hint == ReductionHint.OUTER:
21162127
configs = configs[-1:]
2117-
2118-
if reduction_hint == ReductionHint.OUTER_TINY:
2119-
tiny_configs = [
2120-
triton_config_reduction(
2121-
size_hints,
2122-
2 * (256 // rnumel) if rnumel <= 256 else 1,
2123-
rnumel,
2124-
)
2125-
]
2126-
if max_autotune_enabled:
2127-
for tconfig in tiny_configs:
2128-
if tconfig not in configs:
2129-
configs.append(tconfig)
2130-
else:
2131-
configs = tiny_configs
2128+
elif reduction_hint == ReductionHint.OUTER_TINY:
2129+
configs = tiny_configs
2130+
else:
2131+
if torch.version.hip:
2132+
# If autotune is enabled append tiny configs
2133+
for conf in tiny_configs:
2134+
if conf not in configs:
2135+
configs.append(conf)
21322136

21332137
for c in configs:
21342138
# we don't need Rn_BLOCK for persistent reduction

0 commit comments

Comments
 (0)