[examples][xegpu] Add gridsearch and genetic algorithm autotuners#79
[examples][xegpu] Add gridsearch and genetic algorithm autotuners#79
Conversation
71b7980 to
513f36b
Compare
|
Thanks to #63 we can now trace the schedule module to construct the search space, enumerate it, and also automatically check the validity of a given set of parameters (what |
| self.logger.setLevel(logging.INFO) | ||
| handler = logging.StreamHandler() | ||
| handler.setFormatter(logging.Formatter("%(message)s")) | ||
| if not self.logger.hasHandlers(): |
There was a problem hiding this comment.
How can it have handler here?
There was a problem hiding this comment.
logging.getLogger("csv_logger") gives you an existing logger instance.
There was a problem hiding this comment.
Pull request overview
Adds two autotuning entrypoints for the XeGPU matmul example (exhaustive grid search + genetic algorithm), along with shared utilities and documentation updates to support running/recording tuning experiments.
Changes:
- Add
tune_matmul_gridsearch.pyfor exhaustive parameter search and CSV logging. - Add
tune_matmul_ga.py+genetic_algorithm.pyfor GA-based adaptive sampling. - Refactor
matmul.pyCLI parsing to share args with tuners and add JSON parameter loading; update README and lit excludes.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/xegpu/tune_matmul_gridsearch.py | Implements exhaustive search, constraints filtering, timed execution, CSV logging, and JSON dumping. |
| examples/xegpu/tune_matmul_ga.py | Implements GA-driven tuning using the shared search-space + logging utilities. |
| examples/xegpu/matmul.py | Extracts shared CLI parser and adds --json parameter loading path. |
| examples/xegpu/lit.local.cfg | Excludes non-test helper/tuner scripts from lit discovery. |
| examples/xegpu/genetic_algorithm.py | New GA + population/search-space utility implementation. |
| examples/xegpu/csv_logger.py | New small CSV logger utility used by both tuners. |
| examples/xegpu/README.md | Documents new tuning workflows and updates matmul CLI usage examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) | ||
| parser.add_argument( | ||
| "--json", | ||
| help="Read problem sizes and tile parameters from a JSON file.", |
There was a problem hiding this comment.
Maybe mention that this will ignore most of the other args
| if args.json: | ||
| with open(args.json, "r") as f: | ||
| params = json.load(f) | ||
| else: | ||
| M, N, K = args.sizes | ||
| params = { | ||
| "m": M, |
There was a problem hiding this comment.
Alternatively, the individual args could overwrite the defaults from json
| assert not os.path.exists(self.filename), ( | ||
| f"CSV file '{self.filename}' already exists" | ||
| ) |
There was a problem hiding this comment.
| assert not os.path.exists(self.filename), ( | |
| f"CSV file '{self.filename}' already exists" | |
| ) | |
| def uniquify(path): | |
| base, ext = os.path.splitext(path) | |
| i = 1 | |
| new_path = path | |
| while os.path.exists(new_path): | |
| new_path = f"{base}_{i}{ext}" | |
| i += 1 | |
| return new_path | |
| self.filename = uniquify(self.filename) |
| from tune_matmul_gridsearch import ( | ||
| construct_search_space, | ||
| execute_and_log, | ||
| dump_configs_json, | ||
| ) |
There was a problem hiding this comment.
nit: common features could go in a separate file.
Adds
tune_matmul_gridsearch.pyandtune_matmul_ga.pymethods. See README.md for instructions.