Repository navigation
[xegpu][examples] Remove replace_with_fused_attention and switch to dependent reduction fusion. - #298
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Fast-math annotations violate masked-infinity semantics, and the exported legacy API is removed without a compatibility period.
2 open findings
What changed in this PR
Replaces the custom fused-attention rewrite with dependent-reduction fusion across XeGPU schedules and payloads.
Changes:
- Adds shared online-attention fusion and fast-math transforms.
- Expresses softmax explicitly in attention payloads.
- Updates nanoGPT and Llama schedules, including causal masking.
| File | Description |
|---|---|
wg_tiling_schedule.py |
Uses shared attention fusion. |
vectorize_schedule.py |
Removes dead values after vectorization. |
fused_attention_schedule.py |
Adopts dependent-reduction fusion. |
attention_fusion.py |
Adds shared fusion utilities. |
gpu_attention_payload.py |
Emits explicit mixed-precision softmax. |
replace_with_fused_attention.py |
Removes the legacy transform. |
transform_ext/__init__.py |
Removes the legacy API export. |
nanoGPT_schedule.py |
Migrates attention scheduling. |
nanoGPT_payload.py |
Emits explicit softmax reductions. |
llama3.py |
Passes causal configuration into payload generation. |
llama3_schedule.py |
Migrates causal GQA fusion. |
llama3_payload.py |
Emits explicit causal attention dataflow. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| fast = transform.param_constant( | ||
| transform.AnyParamType.get(), ir.Attribute.parse("#arith.fastmath<fast>") | ||
| ) | ||
| for op_name in ("math.exp", "arith.subf"): | ||
| unmarked = structured.structured_match( | ||
| anytype, func, ops=[op_name], op_attrs={"fastmath": no_fastmath} | ||
| ) | ||
| transform.annotate(unmarked, "fastmath", param=fast) |
There was a problem hiding this comment.
Agree that fast is more extreme level of fastmath. In my understanding MathToXeVM depends on both having this flag. I would revisit this later to fine tune the fastmath flags required for this case.
There was a problem hiding this comment.
it turns out the subf does not need the flag here. so I removed it. thanks.
| from .ops.trace_producers import trace_producers | ||
| from .ops.reverse_handles import reverse_handles | ||
| from .ops.update_address_space import update_address_space |
There was a problem hiding this comment.
renamed PR title to avoid the confusion.
tkarna
left a comment
There was a problem hiding this comment.
Very nice! Only minor comments.
replace_with_fused_attention by using dependent reduction fusion. replace_with_fused_attention and switch to dependent reduction fusion.


This PR updates xegpu schedules with
fuse_dependent_reduction_opsto fuse attention-like workloads instead of relying on manualreplace_with_fused_attentionop.Note that
apply_attention_tilingalso uses the new approach.Depends on #297
This is a part of landing #274
Assisted by: Claude, Codex