Metadata-Version: 2.4
Name: kernelatlas
Version: 0.1.0
Summary: Discover and validate kernel and compilation choices for Transformers inference
Author: KernelAtlas contributors
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/tarekziade/kernelatlas
Project-URL: Repository, https://github.com/tarekziade/kernelatlas
Project-URL: Issues, https://github.com/tarekziade/kernelatlas/issues
Keywords: transformers,pytorch,kernels,profiling,mps,cuda
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: profile
Requires-Dist: torch>=2.14; extra == "profile"
Requires-Dist: transformers[kernels]>=5.20.1; extra == "profile"
Requires-Dist: accelerate; extra == "profile"
Provides-Extra: release
Requires-Dist: build>=1; extra == "release"
Requires-Dist: twine>=6.1; extra == "release"
Dynamic: license-file

# KernelAtlas

<p align="center"><img src="https://raw.githubusercontent.com/tarekziade/kernelatlas/main/docs/kernel-atlas.png" alt="KernelAtlas: a transformer kernel quest" width="480"></p>

> All KernelAtlas code was generated by AI.

Give KernelAtlas a Hugging Face model ID to find out which kernels and compilation settings to use on your GPU. It profiles Transformers inference, searches the Kernel Hub, and reports which configurations passed its checks and how much time they saved.

## Install

Use Python 3.11 or later with PyTorch for your target GPU.

```sh
python3 -m venv .venv
source .venv/bin/activate
python -m pip install 'kernelatlas[profile]'
```

From a source checkout, install with `python -m pip install -e '.[profile]'`.

## Profile a model

Run the command for your GPU with any supported Transformers causal language model.

```sh
# NVIDIA GPU with CUDA-enabled PyTorch
kernelatlas profile Qwen/Qwen3-0.6B --device cuda

# Apple Silicon with PyTorch MPS
kernelatlas profile Qwen/Qwen3-0.6B --device mps
```

The summary tells you which settings to keep, which Hub kernels were tested, and which operations might benefit from a new kernel. Run the printed `best_combo.py` command to use the selected configuration. Reopen the findings any time or export them for an agent.

```sh
kernelatlas atlas show --model-id Qwen/Qwen3-0.6B
kernelatlas atlas show --model-id Qwen/Qwen3-0.6B --format json
```

The CLI defaults to MPS when you omit `--device`. The end-to-end workflow has been tested on Apple M5. Validation on NVIDIA hardware is pending.

## Choose what to measure

- To inspect automatic and selective Hub loading options without downloading weights, run `kernelatlas recommend MODEL_ID --device cuda` or `--device mps`. A pretrained, unquantized profile also saves examples. Run `kernelatlas compare-kernels RUN_DIRECTORY` to check bindings, logits, and latency against the profiled baseline.
- To measure your generation workload, add `--prompt-length 512 --max-new-tokens 32` to the profile command. The first output token comes from the prompt. The report includes prefill, cached-token, and total latency.
- Floating-point inference defaults to BF16 on supported GPUs and FP16 elsewhere. Use `--dtype bf16`, `--dtype fp16`, or `--dtype fp32` to override it.
- By default, profiling compares eager execution with whole-model and MLP compilation where available. It checks logits and greedy tokens before timing. Use `--no-compile` for an eager-only run.

On MPS, KernelAtlas also supports packed linear weights (`--quantization int4` or `int8`), reduced random-weight text profiles for Inkling-2-Mini and Qwen3.8-27B, and local Metal kernel and static-cache trials for eligible workloads. [Run a local optimization trial](https://github.com/tarekziade/kernelatlas/blob/main/docs/trials.md)

[Benchmark evidence](https://github.com/tarekziade/kernelatlas/tree/main/evidence) · [Release guide](https://github.com/tarekziade/kernelatlas/blob/main/docs/release.md) · [Apache License 2.0](https://github.com/tarekziade/kernelatlas/blob/main/LICENSE)
