Skip to content

Commit 0cd22b6

Browse files
committed
match loads inside scf.for for prefetch
1 parent 9da3ef2 commit 0cd22b6

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

‎lighthouse/schedule/xegpu/fused_attention_schedule.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,9 @@ def bundle_xegpu_fused_attention_schedule(
332332
# the other wg-level layouts.
333333
nb_prefetch = parameters.get("nb_prefetch", 1)
334334
if nb_prefetch > 0:
335-
# 3 load_nd ops: Q (hoisted out of the loop), then K and V inside it.
336-
initial_load_nd_ops = match_and_split(
337-
gpu_func, ops={"xegpu.load_nd"}, nhandles=3
338-
)
339-
for load_op in initial_load_nd_ops[1:]:
335+
reduction_loop = match(gpu_func, ops={"scf.for"})
336+
kv_load_ops = match_and_split(reduction_loop, ops={"xegpu.load_nd"}, nhandles=2)
337+
for load_op in kv_load_ops:
340338
xegpu.insert_prefetch(load_op, nb_prefetch=nb_prefetch)
341339
transform.apply_cse(gpu_func)
342340
canonicalize(gpu_func)

0 commit comments

Comments
 (0)