Skip to content

Commit ec1a426

Browse files
committed
reduction schedule: cross-subgroup reduction is not supported
The parallel wg/sg dims and reductions dims must be orthogonal.
1 parent c386918 commit ec1a426

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

‎lighthouse/schedule/xegpu/reduction_schedule.py‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ def bundle_xegpu_reduction_schedule(
128128
assert len(wg_tile) == len(sg_tile) == len(reduction_tile), (
129129
"wg_tile, sg_tile, and reduction_tile must have the same number of dimensions"
130130
)
131+
assert all(red == 0 or sg == 0 for red, sg in zip(reduction_tile, sg_tile)), (
132+
"Reduction dimensions cannot be distributed across subgroups"
133+
)
131134
if wg_subtile:
132135
assert len(wg_subtile) == len(wg_tile), (
133136
"wg_subtile must have the same number of dimensions as wg_tile"
@@ -299,11 +302,9 @@ def tile_and_fuse_reduction(reduction_op, tile_sizes):
299302
launch_op = match_and_split(func, ops={"gpu.launch"})
300303
num_subgroups = 1
301304
_wg_tile = wg_subtile if apply_wg_subtile else wg_tile
302-
for i, (wg, red, sg) in enumerate(zip(_wg_tile, reduction_tile, sg_tile)):
305+
for wg, sg in zip(_wg_tile, sg_tile):
303306
if wg > 0 and sg > 0:
304307
num_subgroups *= wg // sg
305-
if red > 0 and sg > 0:
306-
num_subgroups *= red // sg
307308
num_threads = num_subgroups * subgroup_size
308309
xegpu.set_gpu_launch_threads(launch_op[0], threads=[num_threads, 1, 1])
309310

@@ -329,9 +330,7 @@ def tile_and_fuse_reduction(reduction_op, tile_sizes):
329330
store_nd_ops = match(gpu_func, ops={"xegpu.store_nd"})
330331
store_matrix_ops = match(gpu_func, ops={"xegpu.store_matrix"})
331332
sg_layout = [1] * ndims
332-
for i, (wg, red, sg) in enumerate(zip(_wg_tile, reduction_tile, sg_tile)):
333-
if red > 0 and sg > 0:
334-
sg_layout[i] = int(red // sg)
333+
for i, (wg, sg) in enumerate(zip(_wg_tile, sg_tile)):
335334
if wg > 0 and sg > 0:
336335
sg_layout[i] = int(wg // sg)
337336
sg_data = [1] * ndims

0 commit comments

Comments
 (0)