triton-msl
Write standard Triton kernels and run them
on your Mac's GPU. triton-msl compiles @triton.jit kernels to Metal for Apple Silicon.
@triton.jit → Triton IR → Metal Shading Language → Apple GPU
Develop kernel logic locally, then validate and tune it on your target GPU. The tested sources also run through Triton's NVIDIA and AMD backends; support, numerical precision and performance depend on the backend.
Status: alpha. The goal is to preserve the source computation or refuse an unsupported kernel explicitly. This is not a universal correctness guarantee.
What's new in 0.3.0
This update fixes silent-wrong results, expands attention and matmul coverage, implements retained device assertions, and tightens unsupported-case handling. It includes bounded recoveries for grouped/flat-grid matmul, separate-length and biased attention, single-query decode, and matmul epilogues.
There are performance tradeoffs. The measured warm comparisons retain 13 native-wheel and 14 pure-wheel workloads more than 10% slower than the previous main. Cold specialization is also slower: one formatted-candidate observation put the first add at 9.48 s versus 0.63 s. These are scoped measurements, not a prediction for every model.
Read the 0.3.0 release guide for the improvements, validation results, performance comparisons and limitations. See GitHub releases for published artifacts and their hashes.
Install
You need an Apple Silicon Mac, macOS 14+, Python 3.10+, Xcode Command Line Tools, PyTorch and Triton. The current integration is developed against PyTorch 2.12 and Triton 3.7.0.
xcode-select --install
pip install torch triton-msl
# Triton is installed separately; use the documented 3.7.0 wheel's source revision:
pip install git+https://github.com/triton-lang/triton.git@4da2e268dcccf090370e7bb7b59940e7567bf0ce
pip install triton-msl installs the version currently published on PyPI,
which may lag main. For source development, see
CONTRIBUTING.md.
The 0.3.0 native wheel targets GIL-enabled CPython 3.14, macOS 15+, arm64. Other supported setups use the Python fallback, with different latency. See installation details for the Metal compiler component, optional host helpers and the matching unofficial Triton wheel. M1 compatibility is a target, not independent 0.3.0 hardware validation.
Quick start
Save this as a Python file and run it on your Mac:
import torch
import triton
import triton.language as tl
@triton.jit
def add_kernel(x_ptr, y_ptr, out_ptr, n, BLOCK: tl.constexpr):
offsets = tl.program_id(0) * BLOCK + tl.arange(0, BLOCK)
mask = offsets < n
x = tl.load(x_ptr + offsets, mask=mask)
y = tl.load(y_ptr + offsets, mask=mask)
tl.store(out_ptr + offsets, x + y, mask=mask)
n = 1024
x = torch.randn(n, device="mps")
y = torch.randn(n, device="mps")
out = torch.empty_like(x)
add_kernel[(triton.cdiv(n, 256),)](x, y, out, n, BLOCK=256)
torch.mps.synchronize()
print((out - (x + y)).abs().max().item())
For torch.compile, register the MPS integration and use PyTorch's
inductor backend—not a backend named metal.
More examples
cover registration, MLX, matmul, attention and tuning flags.
Capabilities and limits
- Elementwise kernels, reductions, scans, tensor operations and supported atomics.
- Strided matmul, bounded epilogues, and weight-only int8/int4 routes.
- FlashAttention, bounded decode/biased-attention and MLA routes.
- PyTorch Inductor integration; a narrower MLX launch interface.
- Direct Metal operations for KDA and FlashAttention backward.
Support depends on the source, dtype, layout and tile size. FP64 GPU arithmetic, microscaling and unproved source contracts are not generally available. The optional C++ route is unaudited and off by default. The reported full AlphaFold/trifast workflow is not validated end-to-end.
Native unchanged-state validation skips Python observation callbacks by design.
Set TRITON_MSL_IDENTITY_FAST_PATH=0 if those callbacks are required; see the
observation contract.
Argument checks and immediate device-assertion observation remain enabled.
See the support matrix and capability register for specific envelopes. Cross-vendor tests establish parity only for their named sources and precision settings—not universal byte-identical results.
Documentation
- 0.3.0 release guide — changes, performance, validation and known limitations.
- Usage · Architecture · Portability
- Changelog · Contributing · Citing · References
Metadata
Release files for triton-msl 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| triton_msl-0.3.0.tar.gz | 814.5 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| triton_msl-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
| triton_msl-0.3.0-cp314-cp314-macosx_15_0_arm64.whl | CPython 3.14 | CPython 3.14 | macOS 15.0+ ARM64 | Details |
Total release size: 2.5 MB
Release files / triton_msl-0.3.0.tar.gz
| Download URL | triton_msl-0.3.0.tar.gz |
|---|---|
| Size | 814.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e891aaedba1de85449186cd25384335331892666c9dfbfc180b3eb1c5e23f4a5
|
|
BLAKE2b-256 checksum How to use checksums |
24eb546324dd15ccc895321381f1d58a684642e91a03877ef529c23c59d125f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / triton_msl-0.3.0-py3-none-any.whl
| Download URL | triton_msl-0.3.0-py3-none-any.whl |
|---|---|
| Size | 850.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd6222793845a588f3f9f539d3b1918934aae0530c7a5616562bbb286aa9e720
|
|
BLAKE2b-256 checksum How to use checksums |
6992fb43ad89511dfb395e1cce75b41fd75ea3cb17a422f53c4bb7d6cdd61eff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / triton_msl-0.3.0-cp314-cp314-macosx_15_0_arm64.whl
| Download URL | triton_msl-0.3.0-cp314-cp314-macosx_15_0_arm64.whl |
|---|---|
| Size | 879.6 kB |
| Tags | CPython 3.14 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
79d3a5545538636dc011d513bb35f232ffa757260354424db163aedeb685aee1
|
|
BLAKE2b-256 checksum How to use checksums |
5c1ae109be0449f7007044404d3a99fae0f2896d42ab8c1794274ad0d37a869f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|