reprospec 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.
- reprospec-0.1.0/.github/workflows/ci.yml +36 -0
- reprospec-0.1.0/.github/workflows/release.yml +103 -0
- reprospec-0.1.0/.gitignore +19 -0
- reprospec-0.1.0/CHANGELOG.md +9 -0
- reprospec-0.1.0/LICENSE +21 -0
- reprospec-0.1.0/PKG-INFO +180 -0
- reprospec-0.1.0/README.md +157 -0
- reprospec-0.1.0/pyproject.toml +52 -0
- reprospec-0.1.0/src/reprospec/__init__.py +3 -0
- reprospec-0.1.0/src/reprospec/__main__.py +5 -0
- reprospec-0.1.0/src/reprospec/capture.py +151 -0
- reprospec-0.1.0/src/reprospec/cli.py +42 -0
- reprospec-0.1.0/src/reprospec/diff.py +534 -0
- reprospec-0.1.0/src/reprospec/doctor.py +372 -0
- reprospec-0.1.0/src/reprospec/manifest.py +316 -0
- reprospec-0.1.0/src/reprospec/probes/__init__.py +9 -0
- reprospec-0.1.0/src/reprospec/probes/_inside.py +240 -0
- reprospec-0.1.0/src/reprospec/probes/accelerator.py +169 -0
- reprospec-0.1.0/src/reprospec/probes/host.py +167 -0
- reprospec-0.1.0/src/reprospec/probes/python_env.py +161 -0
- reprospec-0.1.0/src/reprospec/probes/system.py +68 -0
- reprospec-0.1.0/tests/__init__.py +0 -0
- reprospec-0.1.0/tests/data/linux-a100.json +87 -0
- reprospec-0.1.0/tests/data/macbook-m3.json +82 -0
- reprospec-0.1.0/tests/fakes.py +61 -0
- reprospec-0.1.0/tests/test_accelerator.py +209 -0
- reprospec-0.1.0/tests/test_capture.py +156 -0
- reprospec-0.1.0/tests/test_cli.py +30 -0
- reprospec-0.1.0/tests/test_diff.py +313 -0
- reprospec-0.1.0/tests/test_doctor.py +262 -0
- reprospec-0.1.0/tests/test_host.py +233 -0
- reprospec-0.1.0/tests/test_manifest.py +195 -0
- reprospec-0.1.0/tests/test_python_env.py +255 -0
- reprospec-0.1.0/uv.lock +552 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_call: # lets the release workflow run these tests first
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
name: ${{ matrix.os }} / Python ${{ matrix.python }}
|
|
12
|
+
runs-on: ${{ matrix.os }}
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
# macos-latest runs on Apple Silicon, matching your Mac.
|
|
17
|
+
os: [ubuntu-latest, macos-latest]
|
|
18
|
+
# Oldest and newest supported versions.
|
|
19
|
+
python: ["3.9", "3.13"]
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Install uv
|
|
24
|
+
uses: astral-sh/setup-uv@v6
|
|
25
|
+
|
|
26
|
+
- name: Install Python ${{ matrix.python }}
|
|
27
|
+
run: uv python install ${{ matrix.python }}
|
|
28
|
+
|
|
29
|
+
- name: Lint
|
|
30
|
+
run: uv run --python ${{ matrix.python }} ruff check .
|
|
31
|
+
|
|
32
|
+
- name: Check formatting
|
|
33
|
+
run: uv run --python ${{ matrix.python }} ruff format --check .
|
|
34
|
+
|
|
35
|
+
- name: Test
|
|
36
|
+
run: uv run --python ${{ matrix.python }} pytest -v
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Pushing a tag like v0.1.0 publishes to PyPI and creates a GitHub release.
|
|
4
|
+
# Running this workflow by hand (Actions tab -> Release -> Run workflow)
|
|
5
|
+
# publishes to TestPyPI instead, as a rehearsal.
|
|
6
|
+
#
|
|
7
|
+
# Publishing uses PyPI's trusted publishing: no API token is stored anywhere.
|
|
8
|
+
# Each index needs this repository registered as a trusted publisher first
|
|
9
|
+
# (see "Releasing" in the README).
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
push:
|
|
13
|
+
tags: ["v*"]
|
|
14
|
+
workflow_dispatch:
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
test:
|
|
18
|
+
uses: ./.github/workflows/ci.yml
|
|
19
|
+
|
|
20
|
+
build:
|
|
21
|
+
needs: test
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
- name: Install uv
|
|
27
|
+
uses: astral-sh/setup-uv@v6
|
|
28
|
+
|
|
29
|
+
- name: Check the tag matches the package version
|
|
30
|
+
if: github.event_name == 'push'
|
|
31
|
+
run: |
|
|
32
|
+
version=$(python3 -c "import re, pathlib; print(re.search(r'__version__ = \"(.+)\"', pathlib.Path('src/reprospec/__init__.py').read_text()).group(1))")
|
|
33
|
+
if [ "v$version" != "$GITHUB_REF_NAME" ]; then
|
|
34
|
+
echo "::error::Tag $GITHUB_REF_NAME doesn't match the package version $version"
|
|
35
|
+
exit 1
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
- name: Build
|
|
39
|
+
run: uv build
|
|
40
|
+
|
|
41
|
+
- name: Smoke-test the built package
|
|
42
|
+
run: |
|
|
43
|
+
uv venv /tmp/smoke
|
|
44
|
+
uv pip install --python /tmp/smoke dist/*.whl
|
|
45
|
+
/tmp/smoke/bin/reprospec --version
|
|
46
|
+
/tmp/smoke/bin/reprospec capture --python /tmp/smoke/bin/python -o /tmp/smoke.json
|
|
47
|
+
/tmp/smoke/bin/reprospec diff /tmp/smoke.json /tmp/smoke.json
|
|
48
|
+
/tmp/smoke/bin/reprospec doctor --manifest /tmp/smoke.json --fail-on never
|
|
49
|
+
|
|
50
|
+
- uses: actions/upload-artifact@v4
|
|
51
|
+
with:
|
|
52
|
+
name: dist
|
|
53
|
+
path: dist/
|
|
54
|
+
|
|
55
|
+
testpypi:
|
|
56
|
+
name: Publish to TestPyPI
|
|
57
|
+
if: github.event_name == 'workflow_dispatch'
|
|
58
|
+
needs: build
|
|
59
|
+
runs-on: ubuntu-latest
|
|
60
|
+
environment: testpypi
|
|
61
|
+
permissions:
|
|
62
|
+
id-token: write
|
|
63
|
+
steps:
|
|
64
|
+
- uses: actions/download-artifact@v4
|
|
65
|
+
with:
|
|
66
|
+
name: dist
|
|
67
|
+
path: dist/
|
|
68
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
69
|
+
with:
|
|
70
|
+
repository-url: https://test.pypi.org/legacy/
|
|
71
|
+
# A version can be uploaded only once; rerunning the rehearsal is fine.
|
|
72
|
+
skip-existing: true
|
|
73
|
+
|
|
74
|
+
pypi:
|
|
75
|
+
name: Publish to PyPI
|
|
76
|
+
if: github.event_name == 'push'
|
|
77
|
+
needs: build
|
|
78
|
+
runs-on: ubuntu-latest
|
|
79
|
+
environment: pypi
|
|
80
|
+
permissions:
|
|
81
|
+
id-token: write
|
|
82
|
+
steps:
|
|
83
|
+
- uses: actions/download-artifact@v4
|
|
84
|
+
with:
|
|
85
|
+
name: dist
|
|
86
|
+
path: dist/
|
|
87
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
88
|
+
|
|
89
|
+
github-release:
|
|
90
|
+
name: Create GitHub release
|
|
91
|
+
needs: pypi
|
|
92
|
+
runs-on: ubuntu-latest
|
|
93
|
+
permissions:
|
|
94
|
+
contents: write
|
|
95
|
+
steps:
|
|
96
|
+
- uses: actions/download-artifact@v4
|
|
97
|
+
with:
|
|
98
|
+
name: dist
|
|
99
|
+
path: dist/
|
|
100
|
+
- name: Create release
|
|
101
|
+
env:
|
|
102
|
+
GH_TOKEN: ${{ github.token }}
|
|
103
|
+
run: gh release create "$GITHUB_REF_NAME" dist/* --repo "$GITHUB_REPOSITORY" --title "$GITHUB_REF_NAME" --generate-notes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
build/
|
|
6
|
+
dist/
|
|
7
|
+
|
|
8
|
+
# Environments
|
|
9
|
+
.venv/
|
|
10
|
+
|
|
11
|
+
# Tool caches
|
|
12
|
+
.pytest_cache/
|
|
13
|
+
.ruff_cache/
|
|
14
|
+
|
|
15
|
+
# macOS
|
|
16
|
+
.DS_Store
|
|
17
|
+
|
|
18
|
+
# Manifests captured while trying the tool locally
|
|
19
|
+
*.reprospec.json
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
First release.
|
|
6
|
+
|
|
7
|
+
- `capture` records an ML environment as a JSON manifest: OS, CPU and C library; the GPU backend (Apple MPS, NVIDIA CUDA, AMD ROCm) with device and driver details; the Python interpreter, including Rosetta detection on Apple Silicon; installed packages; PyTorch, TensorFlow, JAX and NumPy build and determinism settings; and the environment variables that affect results. It works on macOS and Linux, needs nothing installed in the inspected environment, and records the home folder as `~`.
|
|
8
|
+
- `diff` compares two manifests and grades each difference as critical, high, medium or low, with a reason. It can print JSON and works as a CI check through its exit code.
|
|
9
|
+
- `doctor` checks one environment for problems such as PyTorch not using the GPU, Python under Rosetta, a CUDA driver too old for PyTorch, MPS fallback to the CPU, and missing determinism settings, each with a fix.
|
reprospec-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ramachandra Anirudh Vemulapalli
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
reprospec-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: reprospec
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Explain why your ML model gives different results on two machines.
|
|
5
|
+
Project-URL: Homepage, https://github.com/aniru-dh21/reprospec
|
|
6
|
+
Project-URL: Issues, https://github.com/aniru-dh21/reprospec/issues
|
|
7
|
+
Project-URL: Changelog, https://github.com/aniru-dh21/reprospec/blob/main/CHANGELOG.md
|
|
8
|
+
Author: Your Name
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: cuda,environment,machine-learning,mps,pytorch,reproducibility
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# reprospec
|
|
25
|
+
|
|
26
|
+
**Find out why your ML model gives different numbers on two machines.**
|
|
27
|
+
|
|
28
|
+
Your model trains fine on your laptop and drifts on the cluster. Same code, same `requirements.txt`, different results. The cause is usually below the package list: a different GPU backend, a PyTorch build for another CUDA version, TF32 switched on, NumPy using a different math library, or an environment variable nobody remembers setting.
|
|
29
|
+
|
|
30
|
+
`reprospec` records those layers in one file, compares two of them, and tells you which differences matter.
|
|
31
|
+
|
|
32
|
+
- **`capture`** records an environment: hardware, GPU (Apple MPS, NVIDIA CUDA, AMD ROCm), Python, packages, PyTorch/TensorFlow/JAX/NumPy build and determinism settings, and the environment variables that change results.
|
|
33
|
+
- **`diff`** compares two captures and ranks every difference by how likely it is to change results, with a one-line reason each.
|
|
34
|
+
- **`doctor`** checks one environment for problems, such as PyTorch not using your GPU or Python running under Rosetta, with a one-line fix each.
|
|
35
|
+
|
|
36
|
+
It has no dependencies, and it doesn't need to be installed in the environment it inspects.
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
uv tool install reprospec # or: pipx install reprospec
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`pip install reprospec` works too. Installing it as a tool keeps it out of your ML environments, and it can still inspect any of them.
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
Record the environment on each machine:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
reprospec capture -o laptop.json # on your laptop
|
|
52
|
+
reprospec capture -o cluster.json # on the cluster
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Then compare them:
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
reprospec diff laptop.json cluster.json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
Reference: laptop.json
|
|
63
|
+
Compared: cluster.json
|
|
64
|
+
|
|
65
|
+
CRITICAL accelerator.backend: mps -> cuda
|
|
66
|
+
Different accelerator: GPU kernels differ, so results won't match exactly.
|
|
67
|
+
CRITICAL frameworks.torch.version: 2.5.1 -> 2.5.1+cu124
|
|
68
|
+
Same release, different build (default vs cu124).
|
|
69
|
+
HIGH frameworks.numpy.build.blas: accelerate -> openblas
|
|
70
|
+
Different math library: results can differ in the last digits.
|
|
71
|
+
HIGH frameworks.torch.deterministic_algorithms: false -> true
|
|
72
|
+
Deterministic-algorithm enforcement differs.
|
|
73
|
+
MEDIUM env.OMP_NUM_THREADS: (unset) -> 8
|
|
74
|
+
Thread count differs: parallel sums can add up in a different order.
|
|
75
|
+
...
|
|
76
|
+
Summary: 5 critical, 10 high, 4 medium, 3 low (3 low hidden; use --all to show)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Or check one environment for problems:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
reprospec doctor
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
Checked: ~/ml/.venv/bin/python (Python 3.12.7, x86_64, mps)
|
|
87
|
+
|
|
88
|
+
ERROR rosetta
|
|
89
|
+
Python runs under Rosetta (x86_64 emulation on an Apple Silicon Mac). It's slower,
|
|
90
|
+
uses different math libraries, and PyTorch can't use the GPU.
|
|
91
|
+
Fix: Install an arm64 Python (e.g. `uv python install 3.12`) and recreate the
|
|
92
|
+
environment with it.
|
|
93
|
+
|
|
94
|
+
Summary: 1 error, 2 info (2 info hidden; use --all to show)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Commands
|
|
98
|
+
|
|
99
|
+
### capture
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
reprospec capture [--python PATH] [-o FILE] [-q]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Inspects the active virtualenv or conda environment, or `python3` on your PATH. Use `--python` to inspect a specific interpreter. A short summary goes to stderr; the manifest goes to `FILE`, or to stdout without `-o`.
|
|
106
|
+
|
|
107
|
+
A manifest is a plain, sorted JSON file that's easy to read and to commit next to an experiment. Your home folder is recorded as `~`, and no hostname is stored, so it doesn't reveal your username.
|
|
108
|
+
|
|
109
|
+
### diff
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
reprospec diff REFERENCE TEST [--all] [--json] [--fail-on LEVEL]
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Grades every difference:
|
|
116
|
+
|
|
117
|
+
| Level | Examples |
|
|
118
|
+
|---|---|
|
|
119
|
+
| critical | GPU backend; PyTorch/TensorFlow/JAX version or CUDA build; GPU usable in only one environment |
|
|
120
|
+
| high | determinism and TF32 settings; NumPy's math library; Python minor version or Rosetta; macOS version on MPS; numerically sensitive packages like `transformers` or `scipy` |
|
|
121
|
+
| medium | drivers, CPU model, C library, thread counts |
|
|
122
|
+
| low | other packages, OS version |
|
|
123
|
+
|
|
124
|
+
Low-impact differences are hidden unless you pass `--all`. Exit code: 0 if nothing at or above `--fail-on` (default `high`) differs, 1 if something does, 2 on errors. That makes it usable as a CI check:
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
reprospec capture -o current.json
|
|
128
|
+
reprospec diff reference.json current.json --fail-on critical
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### doctor
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
reprospec doctor [--python PATH | --manifest FILE] [--all] [--json] [--ignore ID] [--fail-on LEVEL]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Checks for, among others:
|
|
138
|
+
|
|
139
|
+
- PyTorch not using the GPU: Apple MPS unavailable, a CPU-only build on an NVIDIA machine, or a CUDA driver too old for PyTorch
|
|
140
|
+
- Python running under Rosetta on Apple Silicon
|
|
141
|
+
- A framework that fails to import
|
|
142
|
+
- `PYTORCH_ENABLE_MPS_FALLBACK` silently running ops on the CPU
|
|
143
|
+
- Determinism settings: `CUBLAS_WORKSPACE_CONFIG`, cuDNN benchmark mode, TF32, deterministic algorithms, `PYTHONHASHSEED`, thread counts
|
|
144
|
+
|
|
145
|
+
Each issue is an error, a warning or info, and has an id you can pass to `--ignore`. Info notes are hidden unless you pass `--all`. Exit code: 1 if anything at or above `--fail-on` (default `error`) is found.
|
|
146
|
+
|
|
147
|
+
## Platforms
|
|
148
|
+
|
|
149
|
+
- macOS on Apple Silicon (MPS) and Intel Macs
|
|
150
|
+
- Linux with NVIDIA CUDA, AMD ROCm, or CPU only
|
|
151
|
+
|
|
152
|
+
Python 3.9 or newer, for both reprospec and the environments it inspects.
|
|
153
|
+
|
|
154
|
+
## Limitations
|
|
155
|
+
|
|
156
|
+
- Framework settings such as `torch.backends.cudnn.benchmark` are recorded as they are right after import. If your training script changes them, the manifest won't show it, which is why `doctor` only reports them as info.
|
|
157
|
+
- For AMD GPUs, only the ROCm version is recorded, not the device details yet.
|
|
158
|
+
- reprospec explains differences; it doesn't recreate environments yet.
|
|
159
|
+
|
|
160
|
+
## Development
|
|
161
|
+
|
|
162
|
+
Requires [uv](https://docs.astral.sh/uv/).
|
|
163
|
+
|
|
164
|
+
```sh
|
|
165
|
+
uv sync # create .venv and install dev tools
|
|
166
|
+
uv run reprospec --version # run the CLI
|
|
167
|
+
uv run pytest # run tests
|
|
168
|
+
uv run ruff check . # lint
|
|
169
|
+
uv run ruff format . # format
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Releasing
|
|
173
|
+
|
|
174
|
+
1. Update the version in `src/reprospec/__init__.py` and add an entry to `CHANGELOG.md`.
|
|
175
|
+
2. Optional rehearsal: in GitHub, open Actions, then Release, then "Run workflow". This publishes to TestPyPI.
|
|
176
|
+
3. Tag and push: `git tag v0.1.0 && git push origin v0.1.0`. This runs the tests, publishes to PyPI and creates a GitHub release.
|
|
177
|
+
|
|
178
|
+
## License
|
|
179
|
+
|
|
180
|
+
MIT
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# reprospec
|
|
2
|
+
|
|
3
|
+
**Find out why your ML model gives different numbers on two machines.**
|
|
4
|
+
|
|
5
|
+
Your model trains fine on your laptop and drifts on the cluster. Same code, same `requirements.txt`, different results. The cause is usually below the package list: a different GPU backend, a PyTorch build for another CUDA version, TF32 switched on, NumPy using a different math library, or an environment variable nobody remembers setting.
|
|
6
|
+
|
|
7
|
+
`reprospec` records those layers in one file, compares two of them, and tells you which differences matter.
|
|
8
|
+
|
|
9
|
+
- **`capture`** records an environment: hardware, GPU (Apple MPS, NVIDIA CUDA, AMD ROCm), Python, packages, PyTorch/TensorFlow/JAX/NumPy build and determinism settings, and the environment variables that change results.
|
|
10
|
+
- **`diff`** compares two captures and ranks every difference by how likely it is to change results, with a one-line reason each.
|
|
11
|
+
- **`doctor`** checks one environment for problems, such as PyTorch not using your GPU or Python running under Rosetta, with a one-line fix each.
|
|
12
|
+
|
|
13
|
+
It has no dependencies, and it doesn't need to be installed in the environment it inspects.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
uv tool install reprospec # or: pipx install reprospec
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`pip install reprospec` works too. Installing it as a tool keeps it out of your ML environments, and it can still inspect any of them.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
Record the environment on each machine:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
reprospec capture -o laptop.json # on your laptop
|
|
29
|
+
reprospec capture -o cluster.json # on the cluster
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Then compare them:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
reprospec diff laptop.json cluster.json
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
Reference: laptop.json
|
|
40
|
+
Compared: cluster.json
|
|
41
|
+
|
|
42
|
+
CRITICAL accelerator.backend: mps -> cuda
|
|
43
|
+
Different accelerator: GPU kernels differ, so results won't match exactly.
|
|
44
|
+
CRITICAL frameworks.torch.version: 2.5.1 -> 2.5.1+cu124
|
|
45
|
+
Same release, different build (default vs cu124).
|
|
46
|
+
HIGH frameworks.numpy.build.blas: accelerate -> openblas
|
|
47
|
+
Different math library: results can differ in the last digits.
|
|
48
|
+
HIGH frameworks.torch.deterministic_algorithms: false -> true
|
|
49
|
+
Deterministic-algorithm enforcement differs.
|
|
50
|
+
MEDIUM env.OMP_NUM_THREADS: (unset) -> 8
|
|
51
|
+
Thread count differs: parallel sums can add up in a different order.
|
|
52
|
+
...
|
|
53
|
+
Summary: 5 critical, 10 high, 4 medium, 3 low (3 low hidden; use --all to show)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or check one environment for problems:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
reprospec doctor
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
Checked: ~/ml/.venv/bin/python (Python 3.12.7, x86_64, mps)
|
|
64
|
+
|
|
65
|
+
ERROR rosetta
|
|
66
|
+
Python runs under Rosetta (x86_64 emulation on an Apple Silicon Mac). It's slower,
|
|
67
|
+
uses different math libraries, and PyTorch can't use the GPU.
|
|
68
|
+
Fix: Install an arm64 Python (e.g. `uv python install 3.12`) and recreate the
|
|
69
|
+
environment with it.
|
|
70
|
+
|
|
71
|
+
Summary: 1 error, 2 info (2 info hidden; use --all to show)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Commands
|
|
75
|
+
|
|
76
|
+
### capture
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
reprospec capture [--python PATH] [-o FILE] [-q]
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Inspects the active virtualenv or conda environment, or `python3` on your PATH. Use `--python` to inspect a specific interpreter. A short summary goes to stderr; the manifest goes to `FILE`, or to stdout without `-o`.
|
|
83
|
+
|
|
84
|
+
A manifest is a plain, sorted JSON file that's easy to read and to commit next to an experiment. Your home folder is recorded as `~`, and no hostname is stored, so it doesn't reveal your username.
|
|
85
|
+
|
|
86
|
+
### diff
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
reprospec diff REFERENCE TEST [--all] [--json] [--fail-on LEVEL]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Grades every difference:
|
|
93
|
+
|
|
94
|
+
| Level | Examples |
|
|
95
|
+
|---|---|
|
|
96
|
+
| critical | GPU backend; PyTorch/TensorFlow/JAX version or CUDA build; GPU usable in only one environment |
|
|
97
|
+
| high | determinism and TF32 settings; NumPy's math library; Python minor version or Rosetta; macOS version on MPS; numerically sensitive packages like `transformers` or `scipy` |
|
|
98
|
+
| medium | drivers, CPU model, C library, thread counts |
|
|
99
|
+
| low | other packages, OS version |
|
|
100
|
+
|
|
101
|
+
Low-impact differences are hidden unless you pass `--all`. Exit code: 0 if nothing at or above `--fail-on` (default `high`) differs, 1 if something does, 2 on errors. That makes it usable as a CI check:
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
reprospec capture -o current.json
|
|
105
|
+
reprospec diff reference.json current.json --fail-on critical
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### doctor
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
reprospec doctor [--python PATH | --manifest FILE] [--all] [--json] [--ignore ID] [--fail-on LEVEL]
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Checks for, among others:
|
|
115
|
+
|
|
116
|
+
- PyTorch not using the GPU: Apple MPS unavailable, a CPU-only build on an NVIDIA machine, or a CUDA driver too old for PyTorch
|
|
117
|
+
- Python running under Rosetta on Apple Silicon
|
|
118
|
+
- A framework that fails to import
|
|
119
|
+
- `PYTORCH_ENABLE_MPS_FALLBACK` silently running ops on the CPU
|
|
120
|
+
- Determinism settings: `CUBLAS_WORKSPACE_CONFIG`, cuDNN benchmark mode, TF32, deterministic algorithms, `PYTHONHASHSEED`, thread counts
|
|
121
|
+
|
|
122
|
+
Each issue is an error, a warning or info, and has an id you can pass to `--ignore`. Info notes are hidden unless you pass `--all`. Exit code: 1 if anything at or above `--fail-on` (default `error`) is found.
|
|
123
|
+
|
|
124
|
+
## Platforms
|
|
125
|
+
|
|
126
|
+
- macOS on Apple Silicon (MPS) and Intel Macs
|
|
127
|
+
- Linux with NVIDIA CUDA, AMD ROCm, or CPU only
|
|
128
|
+
|
|
129
|
+
Python 3.9 or newer, for both reprospec and the environments it inspects.
|
|
130
|
+
|
|
131
|
+
## Limitations
|
|
132
|
+
|
|
133
|
+
- Framework settings such as `torch.backends.cudnn.benchmark` are recorded as they are right after import. If your training script changes them, the manifest won't show it, which is why `doctor` only reports them as info.
|
|
134
|
+
- For AMD GPUs, only the ROCm version is recorded, not the device details yet.
|
|
135
|
+
- reprospec explains differences; it doesn't recreate environments yet.
|
|
136
|
+
|
|
137
|
+
## Development
|
|
138
|
+
|
|
139
|
+
Requires [uv](https://docs.astral.sh/uv/).
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
uv sync # create .venv and install dev tools
|
|
143
|
+
uv run reprospec --version # run the CLI
|
|
144
|
+
uv run pytest # run tests
|
|
145
|
+
uv run ruff check . # lint
|
|
146
|
+
uv run ruff format . # format
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Releasing
|
|
150
|
+
|
|
151
|
+
1. Update the version in `src/reprospec/__init__.py` and add an entry to `CHANGELOG.md`.
|
|
152
|
+
2. Optional rehearsal: in GitHub, open Actions, then Release, then "Run workflow". This publishes to TestPyPI.
|
|
153
|
+
3. Tag and push: `git tag v0.1.0 && git push origin v0.1.0`. This runs the tests, publishes to PyPI and creates a GitHub release.
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
MIT
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "reprospec"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Explain why your ML model gives different results on two machines."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
authors = [{ name = "Your Name" }]
|
|
14
|
+
keywords = ["machine-learning", "reproducibility", "pytorch", "cuda", "mps", "environment"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Intended Audience :: Science/Research",
|
|
20
|
+
"Operating System :: MacOS",
|
|
21
|
+
"Operating System :: POSIX :: Linux",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
25
|
+
]
|
|
26
|
+
# No runtime dependencies on purpose: part of reprospec runs inside the user's
|
|
27
|
+
# ML environment, and it must not require or install anything there.
|
|
28
|
+
dependencies = []
|
|
29
|
+
|
|
30
|
+
[project.scripts]
|
|
31
|
+
reprospec = "reprospec.cli:main"
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/aniru-dh21/reprospec"
|
|
35
|
+
Issues = "https://github.com/aniru-dh21/reprospec/issues"
|
|
36
|
+
Changelog = "https://github.com/aniru-dh21/reprospec/blob/main/CHANGELOG.md"
|
|
37
|
+
|
|
38
|
+
[dependency-groups]
|
|
39
|
+
dev = ["pytest>=8", "ruff>=0.6", "numpy"]
|
|
40
|
+
|
|
41
|
+
[tool.hatch.version]
|
|
42
|
+
path = "src/reprospec/__init__.py"
|
|
43
|
+
|
|
44
|
+
[tool.pytest.ini_options]
|
|
45
|
+
testpaths = ["tests"]
|
|
46
|
+
|
|
47
|
+
[tool.ruff]
|
|
48
|
+
target-version = "py39"
|
|
49
|
+
line-length = 100
|
|
50
|
+
|
|
51
|
+
[tool.ruff.lint]
|
|
52
|
+
select = ["E", "F", "W", "I", "UP", "B", "FA"]
|