Repository navigation
[xegpu] Add modular parameter-free pipeline - #293
Conversation
8c28598 to
9e6a3dc
Compare
|
Currently supported KernelBench kernels. The new pipeline produces identical xegpu-wg level IR as the existing mlp/reduction/fused_attention schedules.
|
9e6a3dc to
2431d89
Compare
Interfaces must be registered for every new context, the python class bool _interfaces_attached persists across contexts.
2431d89 to
f634cea
Compare
adam-smnk
left a comment
There was a problem hiding this comment.
Could you also add more granular tests per new transform op?
Probably not all really need it but at least the infer ones.
812c343 to
c0327ac
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved parameter-inference and lowering failures prevent reliable execution of the new pipeline.
Review effort: Balanced
Findings: 3
Open (9)
GPU pipeline drops the requested payload function name · New Empty GPU pipeline crashes before returning the module · New Reduction-only payloads fail epilogue extraction · New Transpose slice shape recovery returns incorrect dimensions · New Untiled matmul shape analysis ignores indexing maps · New Parameter inference rejects nested workgroup and K loops · New Payload lookup misses operations normalized by cleanup · New Unsupported multi-reduction-to-contract patterns remain enabled · New Fast path ignores forced subgroup tile sizes · New
What changed in this PR
Introduces modular XeGPU lowering schedules that select parameters during transformation, moving toward a shared pipeline for matmul, reduction, and attention payloads.
Changes:
- Adds standalone lowering stages and fallback alternatives.
- Introduces transform-based parameter inference and layout calculations.
- Integrates the pipeline into KernelBench and adds matmul-analysis tests.
| File | Description |
|---|---|
| test/transform/test_matmul_analysis.py | Tests shape and tile inference. |
| lighthouse/utils/mlir.py | Stops producer traversal at matmuls. |
| lighthouse/transform/alternatives.py | Wraps fallback transform regions. |
| lighthouse/transform/__init__.py | Exports alternatives wrapper. |
| lighthouse/schedule/xegpu/xegpu_parameter_selector.py | Supports constrained parameter selection. |
| lighthouse/schedule/xegpu/wg_tiling_schedule.py | Adds tiling alternatives. |
| lighthouse/schedule/xegpu/vectorize_schedule.py | Adds standalone vectorization. |
| lighthouse/schedule/xegpu/vector_to_xegpu_schedule.py | Adds vector-to-XeGPU conversion stage. |
| lighthouse/schedule/xegpu/outline_gpu_func_schedule.py | Infers launch threads and outlines kernels. |
| lighthouse/schedule/xegpu/matmul_costmodel.py | Supports fixed tile constraints. |
| lighthouse/schedule/xegpu/lowering_common.py | Generalizes shared lowering helpers. |
| lighthouse/schedule/xegpu/cleanup_schedule.py | Normalizes input operations. |
| lighthouse/schedule/xegpu/bufferize_schedule.py | Adds standalone GPU bufferization. |
| lighthouse/schedule/xegpu/annotate_layouts_schedule.py | Adds layout and prefetch annotation. |
| lighthouse/schedule/xegpu/__init__.py | Exports modular schedules. |
| lighthouse/dialects/transform/transform_ext/utils/xegpu_param_selection.py | Connects analysis to parameter selection. |
| lighthouse/dialects/transform/transform_ext/utils/matmul_analysis.py | Infers matmul shapes and tiles. |
| lighthouse/dialects/transform/transform_ext/ops/replace_with_fused_attention.py | Accepts transform-valued tile sizes. |
| lighthouse/dialects/transform/transform_ext/ops/infer_xegpu_reduction_params.py | Adds placeholder reduction parameters. |
| lighthouse/dialects/transform/transform_ext/ops/infer_xegpu_gemm_params.py | Infers GEMM parameter dictionaries. |
| lighthouse/dialects/transform/transform_ext/ops/infer_xegpu_attention_params.py | Adds placeholder attention parameters. |
| lighthouse/dialects/transform/transform_ext/ops/get_param_dict_entry.py | Extracts dictionary parameters. |
| lighthouse/dialects/transform/transform_ext/ops/extract_handle.py | Supports recoverable extraction failures. |
| lighthouse/dialects/transform/transform_ext/ops/emit_definite_failure.py | Reports exhausted alternatives. |
| lighthouse/dialects/transform/transform_ext/ops/compute_sg_layout.py | Computes subgroup layouts. |
| lighthouse/dialects/transform/transform_ext/ops/compute_num_threads.py | Computes launch thread counts. |
| lighthouse/dialects/transform/transform_ext/__init__.py | Exports new transform operations. |
| lighthouse/dialects/transform/smt_ext/ops/constrain_params.py | Attaches interfaces per context. |
| examples/xegpu/llama3_schedule.py | Updates helper call to keyword syntax. |
| examples/xegpu/kernel_bench.py | Adds optional modular pipeline execution. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| TransformExtensionDialect.Operation, name="infer_xegpu_attention_params" | ||
| ): | ||
| """ | ||
| Infer XeGPU attention tiling parameters for an attention anchor op. |
There was a problem hiding this comment.
what is an attention anchor op? Do you mean to say that we match the attention pattern and then use this op to derive tile shapes?
There was a problem hiding this comment.
For the time being the "anchor" op is actually not used - infer_xegpu_attention_params just returns the hardcoded parameters. We need to revisit this once we have an idea how to do this. Maybe we need to pass in the qk/reduction/pv op handles (?).
| n_ctx = ir.RankedTensorType(k.type).shape[-2] | ||
| tile_size = ir.IntegerAttr(op.tile_size).value | ||
| tile_size_params = state.get_params(op.tile_size) | ||
| if len(tile_size_params) != 1 or not isinstance( |
There was a problem hiding this comment.
how would this look like when we transition to dependent reduction fusion approach? I believe you will still pass the derived attention tiling params to the sequence of transform ops?
There was a problem hiding this comment.
Yes, the new reduction tiling op should accept tile sizes either as ints or transform parameters. The replace_with_fused_attention wrapper converts the tile sizes to transform parameters before calling ReplaceWithFusedAttentionOp.
| lh_transform.cleanup(func) | ||
|
|
||
| # Fuse elementwise ops, also removes unused linalg op results (if any). | ||
| func = apply_registered_pass(func, "linalg-fuse-elementwise-ops") |
There was a problem hiding this comment.
I wonder if we can avoid this pass and use your upstreamed change for "unused linalg op results (if any)"
There was a problem hiding this comment.
Yes, I'm planning to remove the linalg-fuse-elementwise-ops pass call, we'll need to update mlir version so I'll leave it for another PR.
adam-smnk
left a comment
There was a problem hiding this comment.
+1 for the overall pipeline structure
I'll leave finer GPU details to Charitha
65b3f4a to
6603d55
Compare
splitting analyze_matmul_op and analyze_wg_k_tile_size tests to separate files
282ae39 to
7acf84d
Compare


Introduces a new XeGPU pipeline that consists of parameter-free sub-schedules.
The full pipeline is defined as
The long-term goal is that we could replace all the existing xegpu schedules, e.g.,
mlp_schedule,reduction_schedule,fused_attetnion_schedule, with a single pipeline that can consume any kind of input IR.This PR is just a first step toward that direction, and still in progress. Currently the pipeline supports basic matmul, reduction and attention payloads (from the KernelBench suite). The matmul support is most mature - it implements the existing GEMM tile size selection mechanism completely. At the moment, the new pipeline is only used in
kernel_bench.pyscript.Some schedules, like
xepgu.wg_tiling(), implement different lowering implementations for gemm, reduction, and attention -like payloads. These implementations are handled by thetransform.alternativesop that tries to apply each defined "alternative" block until one succeeds.As the parameters are not concrete Python values, all calculations that involve parameters must be done inside a dedicated transform op (see e.g., compute_sg_layout.py), or via the transform dialect SMT extension (see annotate_layouts schedule for example).