Metadata-Version: 2.4
Name: sharktuner
Version: 3.7.0
Summary: IREE Dispatch Tuner
Author: SHARK Authors
License-Expression: Apache-2.0
Project-URL: Repository, https://github.com/nod-ai/shark-ai
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: iree-base-compiler
Requires-Dist: iree-base-runtime
Requires-Dist: numpy
Requires-Dist: tqdm>=4.66.4
Requires-Dist: z3_solver>=4.13.0.0
Provides-Extra: dev
Requires-Dist: mypy==1.8.0; extra == "dev"
Requires-Dist: pre-commit==3.8.0; extra == "dev"
Requires-Dist: virtualenv==20.26.6; extra == "dev"
Requires-Dist: types-tqdm>=4.66.0.20240417; extra == "dev"

# SHARK Tuner
`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:

```shell
cd sharktuner
python -m venv .venv
source .venv/bin/activate
```

### Install python dependencies:

```shell
pip install -r requirements.txt
pip install -r requirements-dev.txt
```

### IREE's Python bindings setup:

#### Using the local IREE's Python bindings:
   - Building with CMake

     Configure

     ```shell
     cmake -G Ninja -B ../iree-build/ -S . \
     -DCMAKE_BUILD_TYPE=RelWithDebInfo \
     -DCMAKE_C_COMPILER=clang \
     -DCMAKE_CXX_COMPILER=clang++ \
     -DIREE_HAL_DRIVER_HIP=ON -DIREE_TARGET_BACKEND_ROCM=ON \
     -DIREE_BUILD_PYTHON_BINDINGS=ON \
     -DPython3_EXECUTABLE="$(which python3)"
     ```

     Build

     ```shell
     cmake --build ../iree-build/
     ```

> [!IMPORTANT]
> Make sure to enable the ROCM and HIP in your cmake configuration.
> See [IREE documentation](https://iree.dev/building-from-source/getting-started/#python-bindings) for the details.

   - 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).


#### Using nightly IREE's Python bindings:

```shell
pip install --upgrade -r ../requirements-iree-unpinned.txt
```

## Examples

For a concrete example, check the [`model_tuner` directory](./model_tuner/) for a sample tuner implemented with `libtuner`.
The [`dispatch example`](model_tuner/README.md) should be a good starting point for most users.
