medmlx-core
Shared MLX building blocks for MedMLX medical imaging models on Apple Silicon.
- Metal runtime checks and memory reporting
- 3D convolutions, resampling and sliding-window inference
- Tensor layouts, precision helpers and checkpoint conversion
- Portable saved-graph inference and dense registration geometry
PyPI · Releases · Technical reference
Install · Python · Technical details · License
Requirements
Apple Silicon Mac, macOS, Python 3.13 or 3.14, and Metal GPU access. NumPy and MLX install automatically. Inference raises an error when Metal is unavailable.
Install
pip install medmlx-core
For optional PyTorch checkpoint conversion:
pip install "medmlx-core[conversion]"
Python
Run a small synthetic volume through overlapping patches:
import numpy as np
from medmlx_core import sliding_window_inference
volume = np.ones((1, 1, 32, 32, 32), dtype=np.float32)
output = sliding_window_inference(
volume,
roi_size=(16, 16, 16),
sw_batch_size=1,
predictor=lambda patch: patch * 2,
)
print(output.shape) # (1, 1, 32, 32, 32)
Arrays use batch, channel, depth, height and width axes. Replace the example predictor with your model; the result is a NumPy array.
MedMLX model packages provide the architectures, weights and image workflows. This library supplies their shared runtime operations.
Converted graphs run directly through core:
from pathlib import Path
import mlx.core as mx
from medmlx_core.graph.runtime import Session
session = Session.load(Path("build/my-native-lungmask"))
log_probs, = session(mx.zeros((1, 1, 256, 256), dtype=mx.float32))
Graph schema 2, its codec and Metal executor are owned here. Source capture,
ATen translation and source comparisons live in medmlx-convert. Inference
does not require that converter, Torch, TensorFlow, Core ML or Core AI. Existing
schema-1 pilot bundles must be regenerated; no legacy graph loader is retained.
See the graph and geometry contract for the bounded
operation coverage and numerical qualification scope.
medmlx_core.compensated provides explicit accuracy profiles using FP32 Metal
storage. CompensatedFloat32Operators keeps product and summation residuals
inside convolution, GroupNorm, frozen BatchNorm, ELU, softmax and Gaussian
filtering, with FP32 outputs. CompensatedFloat48Operators carries both words
between convolution, GroupNorm, transpose-convolution, addition and ReLU layers.
The latter packs high and low words along the batch axis. Independent float64
source operators are the numerical references for both profiles.
For paired network outputs, sliding_window_inference(..., predictor_input="numpy") accepts a host NumPy callback and float64 windows and
stitching. This explicit mode lets the callback run a paired Metal network and
export both words for host blending. The default callback still uses MLX arrays
and FP16/FP32 inputs.
Technical details
API contracts, numerical references and development commands are in the technical reference. See the decoder note for the Metal transpose-convolution fix.
License
Apache-2.0. Includes third-party notices and the upstream MONAI license.
Implementation mapping
implementation-map.json records upstream-to-native changes, source references and qualification scope.
Metadata
Release files for medmlx-core 0.2.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 | |
|---|---|---|---|---|
| medmlx_core-0.2.1.tar.gz | 316.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| medmlx_core-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 375.2 kB
Release files / medmlx_core-0.2.1.tar.gz
| Download URL | medmlx_core-0.2.1.tar.gz |
|---|---|
| Size | 316.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
27ea5d6e78ffbd0419f2d49c19af3b5f9624a62799a7b224c6a3c27f5afc73f5
|
|
BLAKE2b-256 checksum How to use checksums |
77e4ba3679c98554cbe474d2d5576cba488f864e17b54a24af63a0a710b923a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / medmlx_core-0.2.1-py3-none-any.whl
| Download URL | medmlx_core-0.2.1-py3-none-any.whl |
|---|---|
| Size | 58.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a6307315f34f2ae1eef0dbba00385209f9f523d563dad18219d9b057f2e7794
|
|
BLAKE2b-256 checksum How to use checksums |
5c00ac4b2e1b47777f42c2c32e3eaa37ca28dfd8785fd820337be77427b886df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for medmlx-core 0.2.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.