Validate MLX model repositories before loading them.
Project description
mlx-model-doctor
Validate an MLX / Hugging Face model repository before you load it.
A model repo can be broken in ways you only discover halfway through load(): a config.json that disagrees with the weights, a missing tokenizer file, a model.safetensors.index.json that points at shards that aren't there, quantization metadata that doesn't match the tensors, or a model that simply won't fit in the memory you have. mlx-model-doctor checks those up front and prints a report, so a bad repo fails fast with a clear reason instead of a confusing crash.
The static checks read repository metadata only — config.json, the tokenizer files, the safetensors index, quantization fields. They need no GPU or MLX and don't download the weights, so they're cheap to run anywhere. An optional --smoke check loads the model through mlx-lm (Apple Silicon) under a memory cap, to confirm it loads and generates.
mlx-model-doctor check local ./my-model
mlx-model-doctor check hf mlx-community/Llama-3.2-3B-Instruct-4bit
Install
pip install mlx-model-doctor
# With the optional mlx-lm smoke check (Apple Silicon):
pip install "mlx-model-doctor[mlx-lm]"
Or with uv:
uv add mlx-model-doctor
uv add "mlx-model-doctor[mlx-lm]"
Verify the install:
mlx-model-doctor version
mlx-model-doctor --help
Requires Python ≥ 3.11. The static checks are pure Python (huggingface-hub + safetensors); only the optional --smoke runtime check needs mlx-lm and Apple Silicon.
What it checks
The built-in text plugin runs these against a model repository, in order:
- Required files —
config.jsonis present and readable. - Config consistency —
config.jsonparses, and itsmodel_typeis set. - Tokenizer — the tokenizer files a text model needs are present, and the special-token configuration is coherent.
- Safetensors index — when the weights are sharded,
model.safetensors.index.jsonis valid and every shard it references exists. - Quantization metadata — quantization fields in the config are consistent with what the weights actually carry.
- Memory budget — an estimate of the memory the model needs at your context length, compared against a budget you pass with
--max-memory.
Each check returns a result with a status (pass / warn / fail / skip), a message, and — when something is wrong — a remediation hint. The report aggregates them, and the process exit code reflects the worst result under your fail policy.
Python API
from mlx_model_doctor import check_local_model, check_hf_model
report = check_local_model("./my-model")
print(report.summary) # {"pass": 6, "warn": 1, "fail": 0, "skip": 1}
for result in report.results:
print(result.status, result.check_id, result.message)
# Hugging Face repos (hits the Hub):
report = check_hf_model("mlx-community/Llama-3.2-3B-Instruct-4bit")
DoctorReport renders to text, JSON, or Markdown (render_text / render_json / render_markdown), and the result objects are frozen dataclasses, so the output is stable to diff in CI.
Commands
| Command | What it does |
|---|---|
version |
Print the version plus the active Python, virtualenv, and dependency status. |
man |
Print usage examples and the exit-code table. |
plugins |
List registered check plugins (text today). |
check local <path> |
Validate a model directory on disk. |
check hf <repo_id> |
Validate a model repository on the Hugging Face Hub (network). |
sample hf |
Survey likely-MLX repos for an author and validate a deterministic sample. |
check accepts --format {text,json,markdown}, --output <file>, --max-memory <e.g. 32gb>, --context-length <n>, --fail-on {error,warn,never}, --include-weights, and --smoke.
Exit codes: 0 checks passed (under the fail policy), 1 checks found failures, 2 tool error — a bad target, a missing dependency, or zero checks run.
The Hugging Face path
check hf and sample hf talk to the Hub through huggingface-hub. They read repository metadata (the file list, sizes, and the small text files) rather than downloading the weights, but they do need network access, and an auth or rate-limit problem surfaces as a clear tool error rather than a stack trace. sample hf is a survey: it lists an author's repos, keeps the ones that look like MLX models, validates a deterministic sample of them, and reports each as its own batch item — a per-model failure is recorded and the run continues.
Status
Alpha (0.1.0). The static check local path and the report/CLI surface are solid and well tested. The Hugging Face path (check hf, sample hf) is implemented and tested offline against fakes; its live behavior is exercised by opt-in network tests. The API may still shift before 1.0 — pin a version if you depend on it.
License
Apache-2.0. See LICENSE and NOTICE. Validating a model repository does not touch the model's own weights or license; those belong to their respective authors.
Acknowledgements
- Apple ML Explore for MLX and
mlx-lm. - Hugging Face for the Hub client and
safetensors.
By Denis Ineshin · ineshin.space
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mlx_model_doctor-0.1.0.tar.gz.
File metadata
- Download URL: mlx_model_doctor-0.1.0.tar.gz
- Upload date:
- Size: 146.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62e00597f821163ff1c7a690b323147cb0a36238fefb2fdb4dee03621e53048e
|
|
| MD5 |
7ee5c80bae1613e88216e6d5844ea6b9
|
|
| BLAKE2b-256 |
cc52d106c0e77af6ee24c9d0ce7196598da91bcba12607808c0e44bd6086fc98
|
Provenance
The following attestation bundles were made for mlx_model_doctor-0.1.0.tar.gz:
Publisher:
release.yml on IonDen/mlx-model-doctor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mlx_model_doctor-0.1.0.tar.gz -
Subject digest:
62e00597f821163ff1c7a690b323147cb0a36238fefb2fdb4dee03621e53048e - Sigstore transparency entry: 1720847070
- Sigstore integration time:
-
Permalink:
IonDen/mlx-model-doctor@671b21d97c9ef02ba9576c9d8b777162517ee77c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/IonDen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@671b21d97c9ef02ba9576c9d8b777162517ee77c -
Trigger Event:
push
-
Statement type:
File details
Details for the file mlx_model_doctor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mlx_model_doctor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 41.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ec1e9a94b48a606f753b1e2bf1e2ad294d9b477b4a69542193e62f2b8f530d9
|
|
| MD5 |
6b2bdf8d58548e9b7cb43f9de35f65df
|
|
| BLAKE2b-256 |
15fb61b6d3fd813525a8020b70d68189c53292d5ad9a171181be1389f1c2af78
|
Provenance
The following attestation bundles were made for mlx_model_doctor-0.1.0-py3-none-any.whl:
Publisher:
release.yml on IonDen/mlx-model-doctor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mlx_model_doctor-0.1.0-py3-none-any.whl -
Subject digest:
9ec1e9a94b48a606f753b1e2bf1e2ad294d9b477b4a69542193e62f2b8f530d9 - Sigstore transparency entry: 1720847158
- Sigstore integration time:
-
Permalink:
IonDen/mlx-model-doctor@671b21d97c9ef02ba9576c9d8b777162517ee77c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/IonDen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@671b21d97c9ef02ba9576c9d8b777162517ee77c -
Trigger Event:
push
-
Statement type: