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.1-cp314-cp314-macosx_13_0_arm64.whl (217.8 kB view details)

Uploaded CPython 3.14macOS 13.0+ ARM64

kestrel_mps_torch_ext-0.1.1-cp313-cp313-macosx_13_0_arm64.whl (217.7 kB view details)

Uploaded CPython 3.13macOS 13.0+ ARM64

kestrel_mps_torch_ext-0.1.1-cp312-cp312-macosx_13_0_arm64.whl (217.5 kB view details)

Uploaded CPython 3.12macOS 13.0+ ARM64

kestrel_mps_torch_ext-0.1.1-cp311-cp311-macosx_13_0_arm64.whl (215.7 kB view details)

Uploaded CPython 3.11macOS 13.0+ ARM64

kestrel_mps_torch_ext-0.1.1-cp310-cp310-macosx_13_0_arm64.whl (210.3 kB view details)

Uploaded CPython 3.10macOS 13.0+ ARM64

File details

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

File metadata

File hashes

Hashes for kestrel_mps_torch_ext-0.1.1-cp314-cp314-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 f3b1468c5b2113671620183a137f930ab77f1d87dc89f50350179a5d75995b7c
MD5 a720c8a7d29ddf9fa41ee972745151c8
BLAKE2b-256 f7d119dfd608caa20b314cacb14089b28ad9a0a28f9cd8e503e515b51a836a2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kestrel_mps_torch_ext-0.1.1-cp313-cp313-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 5af9ab20eb59d2f501c77e82f2756630dcaa626a29a43bf48015dadd37d43bdb
MD5 bf73057e7897c609ec5dbbb6157597c0
BLAKE2b-256 75245abc7c34778b9e85eaa2650d8b09c595cab9e43f56d60ca427c66a6d8dfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kestrel_mps_torch_ext-0.1.1-cp312-cp312-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 1788454f8bee7144d005aac116ef2482ee017ab5ecc1dd725a1935cb27c6c4c6
MD5 48f9cfc636054048972819553d8d1e40
BLAKE2b-256 da7dab54edfa1d13cef6a7fe516581e9e00b8ca76b7496c562f9ab375e14f045

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kestrel_mps_torch_ext-0.1.1-cp311-cp311-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 373946adcd489da9ea1f5d00ba433e7f582a5e8c887b92ea42078c40f4a2f542
MD5 5ad94b5865cb40cd419848bda883222f
BLAKE2b-256 dcd27064adb6e1f33307f875b15f7c6fe974a391d7644de40018da648c4c38c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kestrel_mps_torch_ext-0.1.1-cp310-cp310-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 6c99d03330472a649511b97fef9862307117208ffd375e3c826be2be93764c6b
MD5 89d51ea3bacfccf029308bdb6aac6432
BLAKE2b-256 2445b2d1c72b8e56f02b8eb38a519361a32365c82f065030649fcecc08ca1ad3

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