mlx-model-doctor 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mlx_model_doctor-0.1.0/.github/workflows/ci.yml +68 -0
- mlx_model_doctor-0.1.0/.github/workflows/release.yml +46 -0
- mlx_model_doctor-0.1.0/.gitignore +18 -0
- mlx_model_doctor-0.1.0/CHANGELOG.md +31 -0
- mlx_model_doctor-0.1.0/LICENSE +201 -0
- mlx_model_doctor-0.1.0/NOTICE +8 -0
- mlx_model_doctor-0.1.0/PKG-INFO +137 -0
- mlx_model_doctor-0.1.0/README.md +105 -0
- mlx_model_doctor-0.1.0/ROADMAP.md +39 -0
- mlx_model_doctor-0.1.0/pyproject.toml +124 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/__init__.py +26 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/_version.py +24 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/api.py +75 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/checks/__init__.py +21 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/checks/base.py +16 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/checks/config.py +127 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/checks/files.py +48 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/checks/memory.py +224 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/checks/quantization.py +88 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/checks/safetensors.py +207 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/checks/smoke.py +196 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/checks/tokenizer.py +121 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/cli.py +284 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/context.py +59 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/environment.py +76 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/errors.py +47 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/exit_codes.py +30 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/memory.py +137 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/plugins/__init__.py +22 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/plugins/base.py +20 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/plugins/text.py +41 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/py.typed +0 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/report.py +171 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/runners/__init__.py +6 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/runners/core.py +34 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/runners/smoke.py +137 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/runners/static.py +13 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/sampling.py +346 -0
- mlx_model_doctor-0.1.0/src/mlx_model_doctor/targets.py +245 -0
- mlx_model_doctor-0.1.0/tests/__init__.py +1 -0
- mlx_model_doctor-0.1.0/tests/conftest.py +43 -0
- mlx_model_doctor-0.1.0/tests/fakes.py +51 -0
- mlx_model_doctor-0.1.0/tests/live/README.md +4 -0
- mlx_model_doctor-0.1.0/tests/live/known-broken.toml +4 -0
- mlx_model_doctor-0.1.0/tests/live/known-good.toml +5 -0
- mlx_model_doctor-0.1.0/tests/test_api.py +312 -0
- mlx_model_doctor-0.1.0/tests/test_checks_config.py +149 -0
- mlx_model_doctor-0.1.0/tests/test_checks_files.py +39 -0
- mlx_model_doctor-0.1.0/tests/test_checks_memory.py +230 -0
- mlx_model_doctor-0.1.0/tests/test_checks_quantization.py +80 -0
- mlx_model_doctor-0.1.0/tests/test_checks_safetensors.py +199 -0
- mlx_model_doctor-0.1.0/tests/test_checks_smoke.py +211 -0
- mlx_model_doctor-0.1.0/tests/test_checks_tokenizer.py +85 -0
- mlx_model_doctor-0.1.0/tests/test_cli.py +533 -0
- mlx_model_doctor-0.1.0/tests/test_collection_gating.py +14 -0
- mlx_model_doctor-0.1.0/tests/test_context.py +110 -0
- mlx_model_doctor-0.1.0/tests/test_environment.py +74 -0
- mlx_model_doctor-0.1.0/tests/test_exit_codes.py +55 -0
- mlx_model_doctor-0.1.0/tests/test_hf_target.py +128 -0
- mlx_model_doctor-0.1.0/tests/test_live_models.py +370 -0
- mlx_model_doctor-0.1.0/tests/test_memory.py +25 -0
- mlx_model_doctor-0.1.0/tests/test_memory_caps.py +74 -0
- mlx_model_doctor-0.1.0/tests/test_package_surface.py +23 -0
- mlx_model_doctor-0.1.0/tests/test_report.py +184 -0
- mlx_model_doctor-0.1.0/tests/test_runners.py +82 -0
- mlx_model_doctor-0.1.0/tests/test_runners_smoke.py +199 -0
- mlx_model_doctor-0.1.0/tests/test_targets.py +110 -0
- mlx_model_doctor-0.1.0/uv.lock +1673 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [master]
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: [master]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
lint:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v6
|
|
13
|
+
with:
|
|
14
|
+
fetch-depth: 0
|
|
15
|
+
- uses: actions/setup-python@v6
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
- name: Install uv
|
|
19
|
+
run: pip install uv
|
|
20
|
+
- name: Sync
|
|
21
|
+
run: uv sync --group lint
|
|
22
|
+
- name: Ruff check
|
|
23
|
+
run: uv run ruff check .
|
|
24
|
+
- name: Ruff format check
|
|
25
|
+
run: uv run ruff format --check .
|
|
26
|
+
|
|
27
|
+
typecheck:
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v6
|
|
31
|
+
with:
|
|
32
|
+
fetch-depth: 0
|
|
33
|
+
- uses: actions/setup-python@v6
|
|
34
|
+
with:
|
|
35
|
+
python-version: "3.12"
|
|
36
|
+
- name: Install uv
|
|
37
|
+
run: pip install uv
|
|
38
|
+
- name: Sync
|
|
39
|
+
run: uv sync --group typecheck
|
|
40
|
+
- name: Mypy
|
|
41
|
+
run: uv run mypy
|
|
42
|
+
|
|
43
|
+
test:
|
|
44
|
+
# The default suite is pure Python — static repo checks + fakes. The MLX /
|
|
45
|
+
# smoke / gpu / network tests are gated out below, so it runs on Linux.
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
strategy:
|
|
48
|
+
fail-fast: false
|
|
49
|
+
matrix:
|
|
50
|
+
python: ["3.11", "3.12", "3.13"]
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@v6
|
|
53
|
+
with:
|
|
54
|
+
fetch-depth: 0
|
|
55
|
+
- uses: actions/setup-python@v6
|
|
56
|
+
with:
|
|
57
|
+
python-version: ${{ matrix.python }}
|
|
58
|
+
- name: Install uv
|
|
59
|
+
run: pip install uv
|
|
60
|
+
- name: Sync (test group only — keep CI light)
|
|
61
|
+
run: uv sync --group test
|
|
62
|
+
- name: Run tests
|
|
63
|
+
run: |
|
|
64
|
+
uv run pytest \
|
|
65
|
+
--cov=mlx_model_doctor \
|
|
66
|
+
--cov-report=term-missing \
|
|
67
|
+
--cov-fail-under=85 \
|
|
68
|
+
-m "not benchmark and not network and not gpu and not smoke"
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# .github/workflows/release.yml
|
|
2
|
+
name: Release
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v6
|
|
12
|
+
with:
|
|
13
|
+
fetch-depth: 0
|
|
14
|
+
- uses: hynek/build-and-inspect-python-package@v2
|
|
15
|
+
|
|
16
|
+
publish:
|
|
17
|
+
needs: build
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
environment: pypi
|
|
20
|
+
permissions:
|
|
21
|
+
id-token: write
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/download-artifact@v4
|
|
24
|
+
with:
|
|
25
|
+
name: Packages
|
|
26
|
+
path: dist
|
|
27
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
28
|
+
|
|
29
|
+
github-release:
|
|
30
|
+
needs: publish
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
permissions:
|
|
33
|
+
contents: write
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/download-artifact@v4
|
|
36
|
+
with:
|
|
37
|
+
name: Packages
|
|
38
|
+
path: dist
|
|
39
|
+
- name: Create GitHub Release
|
|
40
|
+
uses: softprops/action-gh-release@v3
|
|
41
|
+
with:
|
|
42
|
+
files: dist/*
|
|
43
|
+
generate_release_notes: true
|
|
44
|
+
draft: false
|
|
45
|
+
# Tags containing a hyphen (e.g. v0.1.0-alpha) are marked prerelease.
|
|
46
|
+
prerelease: ${{ contains(github.ref_name, '-') }}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.codegraph/
|
|
2
|
+
.hypothesis/
|
|
3
|
+
|
|
4
|
+
# Workspace working-state must never live inside the repo (mac/ convention) —
|
|
5
|
+
# specs/plans/reviews and the granular backlog live at the workspace root.
|
|
6
|
+
docs/superpowers/
|
|
7
|
+
docs/backlog/
|
|
8
|
+
|
|
9
|
+
.coverage
|
|
10
|
+
.mypy_cache/
|
|
11
|
+
.pytest_cache/
|
|
12
|
+
.ruff_cache/
|
|
13
|
+
.venv/
|
|
14
|
+
__pycache__/
|
|
15
|
+
build/
|
|
16
|
+
dist/
|
|
17
|
+
*.egg-info/
|
|
18
|
+
src/mlx_model_doctor/_version.py
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] — 2026-06-04
|
|
9
|
+
|
|
10
|
+
Initial public release.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Static validation for local model repositories (`check local <path>` /
|
|
14
|
+
`check_local_model`): config presence and consistency, tokenizer files and
|
|
15
|
+
special tokens, safetensors-index integrity, quantization metadata, and a
|
|
16
|
+
context-length-aware memory-budget estimate. The static checks read repository
|
|
17
|
+
metadata only — no MLX or GPU, and no weight download.
|
|
18
|
+
- Hugging Face target (`check hf <repo_id>` / `check_hf_model`): the same checks
|
|
19
|
+
against a Hub repository, reading metadata over `huggingface-hub`. Auth,
|
|
20
|
+
not-found, and rate-limit failures surface as a clear tool error.
|
|
21
|
+
- `sample hf`: survey an author's likely-MLX repositories and validate a
|
|
22
|
+
deterministic sample as a batch report. A per-model error is recorded as a
|
|
23
|
+
batch item and the run continues; a listing failure is a tool error.
|
|
24
|
+
- Optional memory-safe `mlx-lm` smoke check (`--smoke`, `mlx-lm` extra): loads
|
|
25
|
+
the model under an MLX wired-memory cap and refuses to load if the cap cannot
|
|
26
|
+
be installed, so a smoke run can't push the machine into a memory panic.
|
|
27
|
+
- Reports render to text, JSON, and Markdown; results are frozen dataclasses, so
|
|
28
|
+
output is stable to diff. Exit codes: `0` pass, `1` fail-under-policy,
|
|
29
|
+
`2` tool error or zero checks — tunable with `--fail-on`.
|
|
30
|
+
- `version`, `man`, and `plugins` commands; the built-in `text` plugin; a
|
|
31
|
+
`py.typed` marker.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file type. We recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Denis Ineshin
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
mlx-model-doctor
|
|
2
|
+
Copyright 2026 Denis Ineshin
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mlx-model-doctor
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Validate MLX model repositories before loading them.
|
|
5
|
+
Project-URL: Homepage, https://github.com/IonDen/mlx-model-doctor
|
|
6
|
+
Project-URL: Source, https://github.com/IonDen/mlx-model-doctor
|
|
7
|
+
Project-URL: Issues, https://github.com/IonDen/mlx-model-doctor/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/IonDen/mlx-model-doctor/blob/master/CHANGELOG.md
|
|
9
|
+
Project-URL: Roadmap, https://github.com/IonDen/mlx-model-doctor/blob/master/ROADMAP.md
|
|
10
|
+
Author-email: Denis Ineshin <denis.ineshin@gmail.com>
|
|
11
|
+
License-Expression: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
License-File: NOTICE
|
|
14
|
+
Keywords: apple-silicon,huggingface,mlx,mlx-lm,model-validation
|
|
15
|
+
Classifier: Development Status :: 3 - Alpha
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Intended Audience :: Science/Research
|
|
18
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
19
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.11
|
|
27
|
+
Requires-Dist: huggingface-hub>=0.24
|
|
28
|
+
Requires-Dist: safetensors>=0.4
|
|
29
|
+
Provides-Extra: mlx-lm
|
|
30
|
+
Requires-Dist: mlx-lm>=0.31.3; extra == 'mlx-lm'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# mlx-model-doctor
|
|
34
|
+
|
|
35
|
+
[](https://pypi.org/project/mlx-model-doctor/)
|
|
36
|
+
[](https://pypi.org/project/mlx-model-doctor/)
|
|
37
|
+
[](https://github.com/IonDen/mlx-model-doctor/blob/master/LICENSE)
|
|
38
|
+
|
|
39
|
+
Validate an MLX / Hugging Face model repository before you load it.
|
|
40
|
+
|
|
41
|
+
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.
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
mlx-model-doctor check local ./my-model
|
|
47
|
+
mlx-model-doctor check hf mlx-community/Llama-3.2-3B-Instruct-4bit
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install mlx-model-doctor
|
|
54
|
+
# With the optional mlx-lm smoke check (Apple Silicon):
|
|
55
|
+
pip install "mlx-model-doctor[mlx-lm]"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Or with `uv`:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
uv add mlx-model-doctor
|
|
62
|
+
uv add "mlx-model-doctor[mlx-lm]"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Verify the install:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
mlx-model-doctor version
|
|
69
|
+
mlx-model-doctor --help
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
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.
|
|
73
|
+
|
|
74
|
+
## What it checks
|
|
75
|
+
|
|
76
|
+
The built-in `text` plugin runs these against a model repository, in order:
|
|
77
|
+
|
|
78
|
+
- **Required files** — `config.json` is present and readable.
|
|
79
|
+
- **Config consistency** — `config.json` parses, and its `model_type` is set.
|
|
80
|
+
- **Tokenizer** — the tokenizer files a text model needs are present, and the special-token configuration is coherent.
|
|
81
|
+
- **Safetensors index** — when the weights are sharded, `model.safetensors.index.json` is valid and every shard it references exists.
|
|
82
|
+
- **Quantization metadata** — quantization fields in the config are consistent with what the weights actually carry.
|
|
83
|
+
- **Memory budget** — an estimate of the memory the model needs at your context length, compared against a budget you pass with `--max-memory`.
|
|
84
|
+
|
|
85
|
+
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.
|
|
86
|
+
|
|
87
|
+
## Python API
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from mlx_model_doctor import check_local_model, check_hf_model
|
|
91
|
+
|
|
92
|
+
report = check_local_model("./my-model")
|
|
93
|
+
print(report.summary) # {"pass": 6, "warn": 1, "fail": 0, "skip": 1}
|
|
94
|
+
for result in report.results:
|
|
95
|
+
print(result.status, result.check_id, result.message)
|
|
96
|
+
|
|
97
|
+
# Hugging Face repos (hits the Hub):
|
|
98
|
+
report = check_hf_model("mlx-community/Llama-3.2-3B-Instruct-4bit")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`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.
|
|
102
|
+
|
|
103
|
+
## Commands
|
|
104
|
+
|
|
105
|
+
| Command | What it does |
|
|
106
|
+
|---|---|
|
|
107
|
+
| `version` | Print the version plus the active Python, virtualenv, and dependency status. |
|
|
108
|
+
| `man` | Print usage examples and the exit-code table. |
|
|
109
|
+
| `plugins` | List registered check plugins (`text` today). |
|
|
110
|
+
| `check local <path>` | Validate a model directory on disk. |
|
|
111
|
+
| `check hf <repo_id>` | Validate a model repository on the Hugging Face Hub (network). |
|
|
112
|
+
| `sample hf` | Survey likely-MLX repos for an author and validate a deterministic sample. |
|
|
113
|
+
|
|
114
|
+
`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`.
|
|
115
|
+
|
|
116
|
+
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.
|
|
117
|
+
|
|
118
|
+
## The Hugging Face path
|
|
119
|
+
|
|
120
|
+
`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.
|
|
121
|
+
|
|
122
|
+
## Status
|
|
123
|
+
|
|
124
|
+
**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.
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE). Validating a model repository does not touch the model's own weights or license; those belong to their respective authors.
|
|
129
|
+
|
|
130
|
+
## Acknowledgements
|
|
131
|
+
|
|
132
|
+
- [Apple ML Explore](https://github.com/ml-explore/mlx) for MLX and [`mlx-lm`](https://github.com/ml-explore/mlx-lm).
|
|
133
|
+
- [Hugging Face](https://github.com/huggingface/huggingface_hub) for the Hub client and `safetensors`.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
By Denis Ineshin · [ineshin.space](https://ineshin.space)
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# mlx-model-doctor
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/mlx-model-doctor/)
|
|
4
|
+
[](https://pypi.org/project/mlx-model-doctor/)
|
|
5
|
+
[](https://github.com/IonDen/mlx-model-doctor/blob/master/LICENSE)
|
|
6
|
+
|
|
7
|
+
Validate an MLX / Hugging Face model repository before you load it.
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
mlx-model-doctor check local ./my-model
|
|
15
|
+
mlx-model-doctor check hf mlx-community/Llama-3.2-3B-Instruct-4bit
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install mlx-model-doctor
|
|
22
|
+
# With the optional mlx-lm smoke check (Apple Silicon):
|
|
23
|
+
pip install "mlx-model-doctor[mlx-lm]"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or with `uv`:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
uv add mlx-model-doctor
|
|
30
|
+
uv add "mlx-model-doctor[mlx-lm]"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Verify the install:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
mlx-model-doctor version
|
|
37
|
+
mlx-model-doctor --help
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
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.
|
|
41
|
+
|
|
42
|
+
## What it checks
|
|
43
|
+
|
|
44
|
+
The built-in `text` plugin runs these against a model repository, in order:
|
|
45
|
+
|
|
46
|
+
- **Required files** — `config.json` is present and readable.
|
|
47
|
+
- **Config consistency** — `config.json` parses, and its `model_type` is set.
|
|
48
|
+
- **Tokenizer** — the tokenizer files a text model needs are present, and the special-token configuration is coherent.
|
|
49
|
+
- **Safetensors index** — when the weights are sharded, `model.safetensors.index.json` is valid and every shard it references exists.
|
|
50
|
+
- **Quantization metadata** — quantization fields in the config are consistent with what the weights actually carry.
|
|
51
|
+
- **Memory budget** — an estimate of the memory the model needs at your context length, compared against a budget you pass with `--max-memory`.
|
|
52
|
+
|
|
53
|
+
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.
|
|
54
|
+
|
|
55
|
+
## Python API
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from mlx_model_doctor import check_local_model, check_hf_model
|
|
59
|
+
|
|
60
|
+
report = check_local_model("./my-model")
|
|
61
|
+
print(report.summary) # {"pass": 6, "warn": 1, "fail": 0, "skip": 1}
|
|
62
|
+
for result in report.results:
|
|
63
|
+
print(result.status, result.check_id, result.message)
|
|
64
|
+
|
|
65
|
+
# Hugging Face repos (hits the Hub):
|
|
66
|
+
report = check_hf_model("mlx-community/Llama-3.2-3B-Instruct-4bit")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`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.
|
|
70
|
+
|
|
71
|
+
## Commands
|
|
72
|
+
|
|
73
|
+
| Command | What it does |
|
|
74
|
+
|---|---|
|
|
75
|
+
| `version` | Print the version plus the active Python, virtualenv, and dependency status. |
|
|
76
|
+
| `man` | Print usage examples and the exit-code table. |
|
|
77
|
+
| `plugins` | List registered check plugins (`text` today). |
|
|
78
|
+
| `check local <path>` | Validate a model directory on disk. |
|
|
79
|
+
| `check hf <repo_id>` | Validate a model repository on the Hugging Face Hub (network). |
|
|
80
|
+
| `sample hf` | Survey likely-MLX repos for an author and validate a deterministic sample. |
|
|
81
|
+
|
|
82
|
+
`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`.
|
|
83
|
+
|
|
84
|
+
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.
|
|
85
|
+
|
|
86
|
+
## The Hugging Face path
|
|
87
|
+
|
|
88
|
+
`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.
|
|
89
|
+
|
|
90
|
+
## Status
|
|
91
|
+
|
|
92
|
+
**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.
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE). Validating a model repository does not touch the model's own weights or license; those belong to their respective authors.
|
|
97
|
+
|
|
98
|
+
## Acknowledgements
|
|
99
|
+
|
|
100
|
+
- [Apple ML Explore](https://github.com/ml-explore/mlx) for MLX and [`mlx-lm`](https://github.com/ml-explore/mlx-lm).
|
|
101
|
+
- [Hugging Face](https://github.com/huggingface/huggingface_hub) for the Hub client and `safetensors`.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
By Denis Ineshin · [ineshin.space](https://ineshin.space)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# mlx-model-doctor Roadmap
|
|
2
|
+
|
|
3
|
+
A non-binding sketch of where the library is headed. Items move between sections
|
|
4
|
+
as priorities change.
|
|
5
|
+
|
|
6
|
+
## Released
|
|
7
|
+
|
|
8
|
+
- **v0.1.0** (2026-06-04) — initial public release. Static validation for local
|
|
9
|
+
model repositories; the Hugging Face target (`check hf`, `sample hf`); the
|
|
10
|
+
optional memory-safe `mlx-lm` smoke check; text / JSON / Markdown reports; the
|
|
11
|
+
`text` check plugin.
|
|
12
|
+
|
|
13
|
+
## Active
|
|
14
|
+
|
|
15
|
+
(Empty.)
|
|
16
|
+
|
|
17
|
+
## Future (no fixed release target)
|
|
18
|
+
|
|
19
|
+
- **More check plugins beyond `text`.** The plugin protocol is in place; vision
|
|
20
|
+
and embedding model families would each get their own ordered check list.
|
|
21
|
+
- **Richer Hugging Face surveying.** Caching, broader candidate signals, and
|
|
22
|
+
pagination so `sample hf` can cover more of an author's catalog.
|
|
23
|
+
- **A docs site.** The `mkdocs-material` dependency group is wired, but there is
|
|
24
|
+
no published site yet.
|
|
25
|
+
|
|
26
|
+
## Out of scope (deliberate non-goals)
|
|
27
|
+
|
|
28
|
+
- **Running or serving models.** `mlx-model-doctor` validates a repository;
|
|
29
|
+
`mlx-lm` and `mflux` run it. The optional `--smoke` check is a minimal
|
|
30
|
+
load-and-generate probe, not a runtime or a server.
|
|
31
|
+
- **Repairing repositories.** It reports problems and suggests fixes; it does not
|
|
32
|
+
rewrite `config.json`, re-shard weights, or edit the repo.
|
|
33
|
+
|
|
34
|
+
Re-opening an out-of-scope item requires evidence that the original reasoning no
|
|
35
|
+
longer holds.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
By Denis Ineshin · [ineshin.space](https://ineshin.space)
|