Repository navigation
[xegpu] Generalize reduction schedule to work with nD inputs - #278
Conversation
- reductions are tiled with tile_using_for; avoids iter dim permutation issue in tile_reduction_using_for - add optional wg_subtile parameter - apply math-expand-ops after vectorization; pow(x, 2) -> x*x - support kernelbench rms norm case
There was a problem hiding this comment.
🟡 Changes recommended
examples/xegpu/kernel_bench.py can raise an UnboundLocalError because layer_params is not initialized for unsupported elemwise+reduction shapes/iterator layouts before it is used.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the XeGPU reduction scheduling pipeline to support nD inputs (notably enabling KernelBench level1/36_RMSNorm_.py) by generalizing tiling parameters and adding a new transform to simplify slice patterns before vectorization.
Changes:
- Generalizes reduction schedule parameters to nD (
wg_tile,sg_tile,reduction_tile) and adds optionalwg_subtilefor persistent workgroup sub-tiling. - Adds a new
sink_extract_slice_into_looptransform extension op (with tests) and uses it in the reduction schedule to avoid problematic extract/insert slice patterns prior to vectorization. - Adjusts vectorization and lowering behavior (disable multi-reduction→contract patterns; apply
math-expand-opsafter vectorization) and updates example parameter wiring.
File summaries
| File | Description |
|---|---|
test/transform/test_sink_extract_slice_into_loop.py |
Adds a FileCheck test validating the new sink transform behavior on matching vs non-matching loops. |
lighthouse/schedule/xegpu/reduction_schedule.py |
Generalizes reduction tiling to nD, adds optional WG subtile loop, sinks extract-slices into loops, and updates vectorization/lowering sequencing. |
lighthouse/schedule/xegpu/lowering_common.py |
Extends the common vectorize helper with a flag to disable multi-reduction→contract patterns. |
lighthouse/dialects/transform/transform_ext/ops/sink_extract_slice_into_loop.py |
Implements the new transform extension op to sink tensor.extract_slice loop inits into scf.for. |
lighthouse/dialects/transform/transform_ext/__init__.py |
Exports the new sink_extract_slice_into_loop op from the extension package. |
examples/xegpu/softmax.py |
Updates CLI schedule parameters to the new nD tiling format. |
examples/xegpu/layer_norm.py |
Updates CLI schedule parameters to the new nD tiling format. |
examples/xegpu/kernel_bench.py |
Updates parameter inference for elemwise+reduction kernels (including RMSNorm-like 4D case) and adjusts verification tolerances/verbosity wiring. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
c6716d6 to
2f4e098
Compare
|
Overall, the |
ecdd20c to
825d7f6
Compare
Updates
reduction_scheduleso that KernelBenchlevel1/36_RMSNorm_.pycase can be executed.reduction_scheduleparameters:wg_tile,sg_tile,reduction_tileparameters are n-D lists.wg_subtileparameter to add a persistent for loop to reduce WG tile size.tile_using_for; avoids iter dim permutation issue caused bytile_reduction_using_for.math-expand-opspass after vectorization; e.g. pow(x, 2) -> x*xsink_extract_slice_into_looptransform_ext op to avoid spuriousvector.transfer_read/writepatterns.vectorizefunction takesdisable_multi_reduction_to_contract_patternsargument; Setting it avoids convertingvector.multi_reductionops tovector.contractwhich xegpu lowering does not support correctly at the moment.Assisted-by: Claude