metal-kernels
Python package for metal-kernels, a collection of Apple Metal GPU kernels for Apple silicon. The collection currently has FlashAttention for head dim 32.
python3 -m pip install metal-kernels
The base package has no required dependencies. Optional extras (mlx, torch, reference, dev, mac) are listed in the repository README. From a checkout, the development install is python3 -m pip install -e "./python[dev]" at the repository root.
The .metal file in kernels/ is the only copy of each shader. The package vendors that source and returns its text on import. It does not import MLX or PyTorch. A kernel's launch module compiles the source on first launch, through MLX or PyTorch MPS.
from metal_kernels.flash_attention import flash_attention_hd32
out = flash_attention_hd32(q, k, v, bias=None, scale=None, backend="mlx") # or backend="mps"
SAM 3 on MPS
metal_kernels.integrations.sam3 patches the pinned SAM 3 checkout (31cb7e624e4fe95301b1be1d4e809111593d2e45) at import time so the image model and the tracker can run without CUDA. Call it before importing SAM 3:
from metal_kernels.integrations.sam3 import build_image_model, install
install() # cuda if present, else mps, else cpu
model = build_image_model(load_from_HF=False)
The ViT MLP uses linear plus GELU on CPU and MPS. On CUDA the original fused op is left in place. MPS itself is not executed by the tests in this repository. The command that times the built-in kernels on a Mac is in bench/sam3_shapes/README.md.
Metadata
Release files for metal-kernels 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| metal_kernels-0.1.1.tar.gz | 33.3 kB | With provenance | Details for metal_kernels-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| metal_kernels-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for metal_kernels-0.1.1-py3-none-any.whl |
Total release size: 68.3 kB
Release files / metal_kernels-0.1.1.tar.gz
| Download URL | metal_kernels-0.1.1.tar.gz |
|---|---|
| Size | 33.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8208419420a30e22f4df63b7affc3c2c00f8df9bdfb2293455d0f7406a98f78
|
|
BLAKE2b-256 checksum How to use checksums |
0759c993f0bd7bd622c4a12ecb29cec45ef705c5525e178cf1ee6192a69f94ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / metal_kernels-0.1.1-py3-none-any.whl
| Download URL | metal_kernels-0.1.1-py3-none-any.whl |
|---|---|
| Size | 35.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9cbc1782a6773b4938b2630b73e02827f8add94d2e182f8d7da8f5b3bc62c98
|
|
BLAKE2b-256 checksum How to use checksums |
ddd1f1c19869a3beb17054961a17ab2e4cdccb2767fa87b798b2968f042319f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logSecurity for metal-kernels 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for metal_kernels-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.