Skip to main content

PyTorch-minor-specific Kestrel MPS native op loader

Project description

kestrel-mps-torch-ext

Small ABI-specific sidecar for Kestrel's native MPS tensor/stream handles.

This package follows the same basic pattern as torch-c-dlpack-ext: the Python loader selects a native library whose filename includes the runtime PyTorch major/minor version and loads it with ctypes.CDLL. The native library still links against libtorch, so this is not a stable ABI. It just isolates the torch-version-sensitive part into a small package.

Wheels are published per Python ABI (cp310, cp311, ...). Each wheel can bundle multiple PyTorch-minor-specific dylibs such as torch29, torch210, torch211, and torch212. Patch versions do not get separate dylibs: torch 2.12.0 and 2.12.1 both resolve to torch212.

This package does not ship Metal kernel source, a metallib, or Kestrel torch op registrations. It only exports a narrow C ABI for:

  • resolving a torch.Tensor Python object to its MTLBuffer plus shape/stride metadata;
  • accessing the current PyTorch MPS stream, command buffer, device, and queue;
  • ending PyTorch kernel coalescing and committing the stream.

The main kestrel-kernels package remains responsible for loading kestrel_mps.metallib and dispatching the actual Metal kernels.

Build

Install the exact PyTorch version you want this wheel to target, then build without PEP 517 isolation so CMake sees that same torch install:

python -m pip install "torch==2.12.0" scikit-build-core cmake ninja packaging wheel
python -m pip wheel --no-build-isolation .

The build backend defaults MACOSX_DEPLOYMENT_TARGET to 13.0, so a build on macOS 15 still produces a macosx_13_0_arm64 wheel. Override the target only when intentionally changing the runtime support floor:

MACOSX_DEPLOYMENT_TARGET=14.0 python -m pip wheel --no-build-isolation .

No Kestrel source checkout is required.

Runtime

import kestrel_mps_torch_ext

kestrel_mps_torch_ext.load_torch_mps_bridge()

After that call, the ABI-matched dylib is loaded with RTLD_GLOBAL, so the main Kestrel native library can find KestrelMPSTorchExtAPI_v1 with dlsym.

Unsupported PyTorch Minors

If the installed PyTorch minor is not bundled in the wheel, import fails before any native code is used. The error lists the installed torch version, the supported torch minors, and the missing dylib name.

Use one of the listed PyTorch minors, install a newer kestrel-mps-torch-ext wheel that includes your minor, or email contact@moondream.ai for help.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

kestrel_mps_torch_ext-0.1.0-cp314-cp314-macosx_13_0_arm64.whl (216.6 kB view details)

Uploaded CPython 3.14macOS 13.0+ ARM64

kestrel_mps_torch_ext-0.1.0-cp313-cp313-macosx_13_0_arm64.whl (216.4 kB view details)

Uploaded CPython 3.13macOS 13.0+ ARM64

kestrel_mps_torch_ext-0.1.0-cp312-cp312-macosx_13_0_arm64.whl (216.1 kB view details)

Uploaded CPython 3.12macOS 13.0+ ARM64

kestrel_mps_torch_ext-0.1.0-cp311-cp311-macosx_13_0_arm64.whl (214.4 kB view details)

Uploaded CPython 3.11macOS 13.0+ ARM64

kestrel_mps_torch_ext-0.1.0-cp310-cp310-macosx_13_0_arm64.whl (209.0 kB view details)

Uploaded CPython 3.10macOS 13.0+ ARM64

File details

Details for the file kestrel_mps_torch_ext-0.1.0-cp314-cp314-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for kestrel_mps_torch_ext-0.1.0-cp314-cp314-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 63162eb89b10b6e16e7b09c3dc6fddc1d112defe7aa27707417f9ca10c072022
MD5 c2d5caf1ccc0df6822a0fd6b28ba7349
BLAKE2b-256 cece26e51ddb682e83b6911b9af71c87c1520a547e01ebc49d5af2eabb339eef

See more details on using hashes here.

File details

Details for the file kestrel_mps_torch_ext-0.1.0-cp313-cp313-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for kestrel_mps_torch_ext-0.1.0-cp313-cp313-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 982a8bb20339903086cd7662ed9c48a0dbe419af56755aaaa4b08a827b8e1a56
MD5 90682c701736091504a9719d749f5eaf
BLAKE2b-256 f4192a70eed0dad093bfdb4aa3dd88413abb7fd2db8eef1eb33c3d05edd10611

See more details on using hashes here.

File details

Details for the file kestrel_mps_torch_ext-0.1.0-cp312-cp312-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for kestrel_mps_torch_ext-0.1.0-cp312-cp312-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 daf22affa544eebaf36d71bd1d8eeead92e6e3f510b113456c67146d6b1ea796
MD5 3c07b056c68e92ea0a2c775ac42eac61
BLAKE2b-256 914879e5f127401deeb4b1643787a2a7e030360c99766a1ac52ffbc731b01dcb

See more details on using hashes here.

File details

Details for the file kestrel_mps_torch_ext-0.1.0-cp311-cp311-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for kestrel_mps_torch_ext-0.1.0-cp311-cp311-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 b491416da0315b900459cc5ab1fbd116fb6a3cb0032204ceaf8b49173c85ff7a
MD5 f13e476c5a131ae1cd9319672024a722
BLAKE2b-256 e8f0800c2ec1d9a63e1cb9e91ca51bf9abe8c2e2b91286561292a84c782d4161

See more details on using hashes here.

File details

Details for the file kestrel_mps_torch_ext-0.1.0-cp310-cp310-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for kestrel_mps_torch_ext-0.1.0-cp310-cp310-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 7fcc9010e248466ddf5955456dfb85b12e7736b8f0d93de8d25b3ef913a60479
MD5 59119de91f88dae3db621e0761f5693d
BLAKE2b-256 e40c31d4df869bd2e47b30f2824b658f6cb559b5c516cbe4bf5d4473977814d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page