From 7ff0534fe54dcb03a57bae6bfda1bc753cf95654 Mon Sep 17 00:00:00 2001 From: Jakub Kuderski Date: Fri, 15 Nov 2024 11:17:48 -0500 Subject: [PATCH] [tuner] Update README (#532) Add a warning about the tuner being in early development. Update the tuner readme and remove obsolete instructions. --- README.md | 5 +++++ tuner/README.md | 53 ++++++++++--------------------------------------- 2 files changed, 16 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index f5a255c84..517980838 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,11 @@ conversion tools to produce inference-optimized programs. The Tuner sub-project assists with tuning program performance by searching for optimal parameter configurations to use during model compilation. +> [!WARNING] +> SHARK Tuner is still in early development. Interested users may want +> to try it out, but the tuner is not ready for general use yet. Check out +> [the readme](tuner/README.md) for more details. + ## Support matrix diff --git a/tuner/README.md b/tuner/README.md index 47156779c..e6a515729 100644 --- a/tuner/README.md +++ b/tuner/README.md @@ -1,5 +1,8 @@ # IREE dispatch auto-tuning scripts -`libtuner.py` is the core Python script that provides the fundamental functions for the tuning loop. It imports `candidate_gen.py` for candidate generation. To implement the full tuning loop, `libtuner.py` requires a separate Python script that uses the provided `TuningClient` API from `libtuner.py`. +`libtuner.py` is the core Python script that provides the fundamental functions +for the tuning loop. It imports `candidate_gen.py` for candidate generation. To +implement the full tuning loop, `libtuner.py` requires a separate Python script +that uses the provided `TuningClient` API from `libtuner.py`. ## Prerequisites [Optional] Using virtual environments: @@ -22,47 +25,13 @@ Using the IREE's Python bindings: - Set environment ```shell source ../iree-build/.env && export PYTHONPATH + export PATH="$(realpath ../iree-build/tools):$PATH" ``` -For more information, refer to the [IREE documentation](https://iree.dev/building-from-source/getting-started/#python-bindings) +For more information, refer to the [IREE +documentation](https://iree.dev/building-from-source/getting-started/#python-bindings). -### Overall flow +## Examples -1. Symlink all scripts and mlir/irpa files in your build dir. - - Symlink `iree-build-dir/tools` inside `tuning`. - - Symlink ML model MLIR and weights based on `unet.sh`. - -2. Copy the attention/matmul spec as `config.mlir` in the tuning dir. - -3. Temporarily comment out all the existing configs in `config.mlir`. - - Example: - ```mlir - // , @match_mmt_2048x10240x1280 -> @apply_op_config - // , @match_mmt_2048x1280x5120 -> @apply_op_config - // , @match_mmt_2048x1280x1280 -> @apply_op_config - ``` - -4. Compile a baseline unet -```shell -./unet.sh winograd unet.mlir -o unet_baseline.vmfb --iree-hal-dump-executable-files-to=dump-winograd -``` - -5. Find the matmul to tune and copy the `*_benchmark.mlir` file to the build dir. -```shell -cp dump-winograd/*_141_*benchmark.mlir ./141.mlir -``` - -6. Run the tuning script. - - Example: - ```shell - python -m examples.punet 141.mlir --devices=hip://GPU-0,hip://GPU-4 --num-candidates=1024 - ``` - -7. Check the winner candidate in `result_summary.log`, find and copy the transform spec. - -8. Paste the transform spec into the `config.mlir` and uncomment them. - -9. Add the match function to the entry point in `config.mlir` - - Example: - ```mlir - @match_something -> @apply_op_config - ``` +Check the `examples` directory for sample tuners implemented with `libtuner`. +The [`dispatch` example](https://github.com/nod-ai/SHARK-Platform/tree/main/tuner/examples/dispatch) +should be a good starting point for most users.