[xegpu] Add matmul cost model and tile size selector#156
Open
tkarna wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a XeGPU matmul tile-parameter cost model plus device-spec plumbing, and updates the XeGPU matmul/MLP scheduling path (and examples) to auto-populate missing tiling parameters when a shape is not present in the JSON parameter DB.
Changes:
- Introduces
XeGPUSpecs(device specs DB) and amatmul_costmodelgrid-search/roofline estimator to rank valid tiling configs. - Replaces the old function-based parameter selector with
XeGPUParameterSelector, and wiresmlp_scheduleto generate/fill missing tiling parameters per layer. - Refactors examples to pass only required
(m,n,k)(plus optional--target) and rely on the schedule to complete parameters; reuses centralized constraint checks.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| lighthouse/schedule/xegpu/xegpu_specs.py | Adds device-spec DB and XeGPUSpecs used by the cost model/selector. |
| lighthouse/schedule/xegpu/xegpu_parameter_selector.py | Implements class-based param selection with JSON DB lookup + cost-model fallback. |
| lighthouse/schedule/xegpu/mlp_schedule.py | Adds pre-processing to auto-fill missing layer tile parameters via selector; moves constants to shared constraints module. |
| lighthouse/schedule/xegpu/matmul_costmodel.py | Adds config generation + simple roofline-based performance estimation. |
| lighthouse/schedule/xegpu/matmul_constraints.py | Centralizes tiling/prefetch validity checks and shared constants. |
| lighthouse/schedule/xegpu/init.py | Exposes new selector/specs/constraint helper via package exports. |
| examples/xegpu/tune_matmul_gridsearch.py | Switches to shared check_constraints and adds GPU target selection. |
| examples/xegpu/torch_matmul.py | Simplifies parameter init to (m,n,k) + optional target; removes legacy selector usage. |
| examples/xegpu/mlp.py | Passes per-layer (m,n,k) (and optional target) and relies on schedule for completion. |
| examples/xegpu/matmul.py | Passes (m,n,k) (and optional target) and relies on schedule for completion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends the XeGPU MLP/matmul schedule with a cost model that can be used to generate valid tile sizes for given (M, N, K) matmul shape.
XeGPUSpecs: Object that contains GPU specifications required by the cost model.XeGPUParameterSelector: Param selector is now a class that usesXeGPUSpecsand can generate valid tile size configurations if (M, N, K) case is not found in the existing parameter JSON file.mlp_schedulestill takes a list of param dicts, one for each layer. Only"m","n","k"entries are required however; if any parameter is missing,XeGPUParameterSelectoris called to populate the tile sizes.generate_configsgenerates valid workgroup, subgroup, and k tile size configurations and estimates their performance based on a simple roofline model. Returns configs sorted by estimated performance.generate_prefetch_tilesgenerates all valid thread cooperative prefetch strategies, sorted by the number of cooperative threads. No performance estimate is provided.Currently data types are assumed to be
float16andfloat32for A/B and C, respectively. To be generalized later.We can now execute any nicely-shaped matrix multiplication without the need to define tile sizes. If the matmul is compute-bound performance should be decent.