Triton on Windows: a 5-minute install, and why torch.compile gave me zero speedup
torch.compile on Windows dies with RuntimeError: Cannot find a working triton installation. That wall is now removable: the community project triton-windows publishes wheels on PyPI, and you need neither Visual Studio nor the CUDA Toolkit.
Installing it is not the hard part. Knowing whether to install it is. On my batch-1 decode workload the compiled model ran at 24.0 tok/s, exactly the same as eager on an RTX 3060.
This post covers both: the install path you can copy, including the Python.h not found trap that hits every portable Python build, and the benchmark that tells you whether the 40 MB is worth it.
The short answer
pip install -U "triton-windows<3.3" # torch 2.6 → Triton 3.2No Visual Studio. No CUDA Toolkit. On embedded Python, call the interpreter explicitly:
D:\your-portable-python\python.exe -m pip install -U "triton-windows<3.3"If your Python is a portable/embedded build, you also need to copy two development artifacts into it, covered below.
Why Triton on Windows is awkward in the first place
Triton is the default backend for torch.compile, and PyTorch only ships Linux and macOS wheels. For years the standard Windows answer was WSL2.
triton-windows closed that gap:
- Since 3.2.0.post11 the wheels are on PyPI, so pip resolves them without downloading a wheel by hand from GitHub Releases.
- Since 3.2.0.post13 TinyCC ships inside the wheel, so no MSVC is required.
- The CUDA toolchain is bundled too: Triton 3.1–3.2 carries CUDA 12.4, 3.3 and later carries 12.8. The “install CUDA Toolkit” step is skippable.
Versions must line up. Each PyTorch minor release is only guaranteed to work with one Triton minor release. Table below is from the project README, read 2026-12-02:
| PyTorch | triton-windows | Install |
|---|---|---|
| 2.6 | 3.2.x | pip install -U "triton-windows<3.3" |
| 2.7 | 3.3.x | pip install -U "triton-windows<3.4" |
| 2.8 | 3.4.x | pip install -U "triton-windows<3.5" |
| 2.9 | 3.5.x | pip install -U "triton-windows<3.6" |
| 2.10 | 3.6.x | pip install -U "triton-windows<3.7" |
Pinning the upper bound matters. Leave it off and a future pip resolve silently pulls a Triton that breaks torch.compile on your existing torch build.
Development has moved to triton-lang/triton-windows. The old URL still resolves and the install command is unchanged.
Verify the install
python -c "import triton; print(triton.__version__)"# expect 3.2.0 or 3.2.0.postXXThen a real compile:
python -c "import torch@torch.compiledef f(x): return torch.relu(x) @ xx = torch.randn(256, 256, device='cuda')f(x); torch.cuda.synchronize()print('torch.compile CUDA OK')"torch.compile CUDA OK means you are done. The first call is slow because Triton compiles kernels at that moment, not at decoration time.
The trap: Python.h not found
This is the part with almost no Chinese-language coverage, and it is where portable builds break.
Symptom
The installation succeeds, then torch.compile fails during kernel compilation:
Failed to compile. cc_cmd: ['...\\triton\\runtime\\tcc\\tcc.exe','...\\cuda_utils.c', ..., '-ID:\\xxx\\python\\Include']error: include file 'Python.h' not foundUsually paired with Failed to find Python libs.
Cause
Triton compiles a small C extension (cuda_utils, which wraps the driver API for memory management) at runtime. That extension needs Python.h and python3xx.lib.
Embedded Python — the python-3.12.x-embed-amd64.zip distribution behind most “portable Python runtime” bundles, including repackaged ones — ships the runtime only, with no development files:
Test-Path D:\your-portable-python\Include\Python.h # False → you will hit thisTest-Path D:\your-portable-python\libs\python312.lib # False → you will hit thisTorch, CUDA and the driver can all be perfectly fine. Two files are missing, nothing else.
Fix: copy the development files from a full install
$SRC = "C:\Users\admin\AppData\Local\Programs\Python\Python312" # full install$DST = "D:\your-portable-python"Copy-Item -Recurse "$SRC\Include" "$DST\Include"New-Item -ItemType Directory -Force "$DST\libs" | Out-NullCopy-Item "$SRC\libs\python312.lib" "$DST\libs\"Two details people get wrong:
- Match the minor version.
python312.libis ABI-locked to Python 3.12 and cannot serve 3.13. Patch versions do interoperate (3.12.10 lib with a 3.12.14 runtime is fine). Runpython --versionon both sides before copying. - Do not install Visual Studio. TinyCC and the CUDA headers are already in the wheel. Reading “C compilation failed” as “no C++ toolchain” and installing multi-GB Build Tools is a misdiagnosis that fixes nothing.
Benchmark: what torch.compile actually bought
Setup: Windows 11, RTX 3060 12 GB, Python 3.12.10, torch 2.6.0+cu124, triton-windows 3.2.0.post21. Model: Unlimited-SVG, a DeepSeek-VL2-style MoE with hidden size 1280, 12 layers, 64 experts with top-6 routing, 6.2 GB of bf16 weights.
| Configuration | Decode speed (steady state) | vs eager |
|---|---|---|
| eager baseline | 24.0 tok/s | 1.0x |
torch.compile(dynamic=True) | 24.0 tok/s | 1.0x |
Zero. The reason is structural, not a tuning mistake:
- Batch-1 decode is memory-bound. Every token requires reading the active weight set once from VRAM: the routed experts, the shared parameters, and the 129k-row
lm_head. Kernel fusion changes how many launches read those bytes, not how many bytes are read. - Resolution does not move the needle. The same model at 1024 and 2048 input resolution decodes at 22.1 and 23 tok/s. The bottleneck was never attention or sequence length.
- Compile coverage was partial. The attention subgraph hit an inductor dynamic-shape bug, so I ran with
suppress_errors=Trueand that subgraph fell back to eager, shrinking what compilation could even touch.
One counterintuitive detail: torch.compile(...) returns in about a second. Compilation happens on the first forward pass. Judging compile cost by the decorator’s own runtime gives you the wrong picture entirely.
Should you install it?
| Your workload | Verdict |
|---|---|
| ComfyUI / Stable Diffusion (diffusion UNet, larger batch, compute-heavy) | Yes. triton-windows with SageAttention has real, measured gains and a mature community path |
| Local LLM chat or streaming (batch-1 autoregressive decode) | Benchmark for 10 minutes first. Likely zero gain. Better levers, in order: higher memory bandwidth GPU > quantization (INT8/FP8) > CUDA Graphs |
| Training / fine-tuning | Yes. Compute-bound workloads compile well |
| You just need a Triton-dependent library to import (SageAttention, etc.) | Yes. Follow the steps above |
| Shipping a portable bundle (embedded Python) | Doable, but copy Include and libs, then re-test the ~40 MB size increase |
Minimal benchmark harness, with model.infer(...) replaced by your own generation call:
import torch._dynamotorch._dynamo.config.suppress_errors = True # fall back to eager on failed subgraphscompiled = torch.compile(model, dynamic=True)# Run two full generations, measure the second one.# The first includes compile time and must be discarded.FAQ
Can triton and triton-windows coexist?
No. triton-windows also installs a module named triton. Run pip uninstall triton first. The two are mutually exclusive, and with both present import triton may report a version you did not intend.
Do I need Visual Studio or the CUDA Toolkit? No. Wheels from 3.2.0.post13 onward bundle TinyCC and the CUDA headers. You only need MSVC plus nvcc if you are building Triton, SageAttention or flash-attn from source.
I get Python.h not found but I use a full Python install.
Check for multiple interpreters. Run python -c "import sys; print(sys.prefix)" and compare it against the -I include path in the error. Triton uses the interpreter of the running process, so a wrong interpreter selected in an IDE or a stale venv is the usual cause.
The first compiled run takes forever. Is that normal?
Yes. Compilation happens on first call and can take seconds to minutes. Discard the warm-up round when timing. If every run is slow, check that torch.compile is not sitting inside a function that re-decorates on every call.
Any torch.compile alternatives on Windows? Yes, ordered by expected payoff for batch-1 decode: ONNX Runtime or TensorRT (framework-level), bitsandbytes quantization (cuts bytes per token), hand-rolled CUDA Graphs (removes launch overhead). Quantization attacks the actual bottleneck, memory bandwidth, more directly than compilation does.
Is WSL2 the better choice? If your workflow already lives in WSL2 or Linux, yes. Official Triton, flash-attn and CUDA Graphs all work there. But if the deliverable is a Windows portable bundle, native Windows plus triton-windows is the only self-consistent option.
Bottom line
Getting Triton running natively on Windows in 2026 is a solved problem: one pip install, plus two development directories for portable Python builds.
The real question is why you want it. Diffusion and training workloads get measurable returns. Batch-1 LLM decoding is the textbook “installs fine, speeds up nothing” case. Spend ten minutes benchmarking before you ship an extra 40 MB in your bundle.
Not affiliated with the triton-windows maintainers. Version data reflects the official README as of 2026-12-02; all benchmark numbers come from the machine described above, and your GPU and torch build may produce different results.