aphex-ml 0.1.0a1__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.
Files changed (90) hide show
  1. aphex_ml-0.1.0a1/.github/workflows/ci.yml +86 -0
  2. aphex_ml-0.1.0a1/.gitignore +236 -0
  3. aphex_ml-0.1.0a1/.python-version +1 -0
  4. aphex_ml-0.1.0a1/CONTRIBUTING.md +102 -0
  5. aphex_ml-0.1.0a1/LICENSE +21 -0
  6. aphex_ml-0.1.0a1/PKG-INFO +467 -0
  7. aphex_ml-0.1.0a1/README.md +389 -0
  8. aphex_ml-0.1.0a1/docs/logo/lockup-dark.svg +66 -0
  9. aphex_ml-0.1.0a1/docs/logo/lockup-light.svg +66 -0
  10. aphex_ml-0.1.0a1/docs/logo/mark-dark.svg +50 -0
  11. aphex_ml-0.1.0a1/docs/logo/mark.svg +55 -0
  12. aphex_ml-0.1.0a1/eval/__init__.py +0 -0
  13. aphex_ml-0.1.0a1/eval/cases.py +156 -0
  14. aphex_ml-0.1.0a1/eval/report.py +136 -0
  15. aphex_ml-0.1.0a1/eval/run.py +116 -0
  16. aphex_ml-0.1.0a1/eval/runner.py +172 -0
  17. aphex_ml-0.1.0a1/examples/optimize_tiny_mlp.py +115 -0
  18. aphex_ml-0.1.0a1/examples/tcn_model.pkl +0 -0
  19. aphex_ml-0.1.0a1/examples/transformer_model.pkl +0 -0
  20. aphex_ml-0.1.0a1/infermap/__init__.py +3 -0
  21. aphex_ml-0.1.0a1/infermap/benchmark.py +1061 -0
  22. aphex_ml-0.1.0a1/infermap/candidates.py +319 -0
  23. aphex_ml-0.1.0a1/infermap/checker.py +105 -0
  24. aphex_ml-0.1.0a1/infermap/cli.py +1923 -0
  25. aphex_ml-0.1.0a1/infermap/cloud/__init__.py +0 -0
  26. aphex_ml-0.1.0a1/infermap/cloud/config.py +36 -0
  27. aphex_ml-0.1.0a1/infermap/cloud/instances.py +192 -0
  28. aphex_ml-0.1.0a1/infermap/cloud/registry.py +112 -0
  29. aphex_ml-0.1.0a1/infermap/cloud/remote.py +173 -0
  30. aphex_ml-0.1.0a1/infermap/cloud/storage.py +189 -0
  31. aphex_ml-0.1.0a1/infermap/converter.py +391 -0
  32. aphex_ml-0.1.0a1/infermap/cost_model.py +212 -0
  33. aphex_ml-0.1.0a1/infermap/deployment.py +216 -0
  34. aphex_ml-0.1.0a1/infermap/distillation.py +301 -0
  35. aphex_ml-0.1.0a1/infermap/evaluator.py +865 -0
  36. aphex_ml-0.1.0a1/infermap/inspector.py +456 -0
  37. aphex_ml-0.1.0a1/infermap/pareto.py +63 -0
  38. aphex_ml-0.1.0a1/infermap/plugin.py +56 -0
  39. aphex_ml-0.1.0a1/infermap/plugins/__init__.py +0 -0
  40. aphex_ml-0.1.0a1/infermap/plugins/llm.py +472 -0
  41. aphex_ml-0.1.0a1/infermap/plugins/pytorch.py +63 -0
  42. aphex_ml-0.1.0a1/infermap/plugins/sklearn.py +571 -0
  43. aphex_ml-0.1.0a1/infermap/preflight.py +180 -0
  44. aphex_ml-0.1.0a1/infermap/profiler.py +225 -0
  45. aphex_ml-0.1.0a1/infermap/pruning.py +175 -0
  46. aphex_ml-0.1.0a1/infermap/recommender.py +118 -0
  47. aphex_ml-0.1.0a1/infermap/registry.py +59 -0
  48. aphex_ml-0.1.0a1/infermap/report.py +195 -0
  49. aphex_ml-0.1.0a1/infermap/selector.py +204 -0
  50. aphex_ml-0.1.0a1/infermap/serving/__init__.py +32 -0
  51. aphex_ml-0.1.0a1/infermap/serving/base.py +14 -0
  52. aphex_ml-0.1.0a1/infermap/serving/bentoml.py +82 -0
  53. aphex_ml-0.1.0a1/infermap/serving/fastapi.py +86 -0
  54. aphex_ml-0.1.0a1/infermap/serving/torchserve.py +79 -0
  55. aphex_ml-0.1.0a1/infermap/serving/triton.py +111 -0
  56. aphex_ml-0.1.0a1/infermap/system_recommender.py +137 -0
  57. aphex_ml-0.1.0a1/pyproject.toml +140 -0
  58. aphex_ml-0.1.0a1/scripts/download_test_model.py +170 -0
  59. aphex_ml-0.1.0a1/tests/__init__.py +0 -0
  60. aphex_ml-0.1.0a1/tests/conftest.py +19 -0
  61. aphex_ml-0.1.0a1/tests/integration/__init__.py +0 -0
  62. aphex_ml-0.1.0a1/tests/integration/test_real_models.py +251 -0
  63. aphex_ml-0.1.0a1/tests/test_benchmark.py +219 -0
  64. aphex_ml-0.1.0a1/tests/test_candidates.py +137 -0
  65. aphex_ml-0.1.0a1/tests/test_checker.py +247 -0
  66. aphex_ml-0.1.0a1/tests/test_cloud.py +311 -0
  67. aphex_ml-0.1.0a1/tests/test_converter.py +441 -0
  68. aphex_ml-0.1.0a1/tests/test_cost_model.py +298 -0
  69. aphex_ml-0.1.0a1/tests/test_deployment.py +284 -0
  70. aphex_ml-0.1.0a1/tests/test_distillation.py +246 -0
  71. aphex_ml-0.1.0a1/tests/test_evaluator.py +505 -0
  72. aphex_ml-0.1.0a1/tests/test_fixes.py +449 -0
  73. aphex_ml-0.1.0a1/tests/test_inspector.py +76 -0
  74. aphex_ml-0.1.0a1/tests/test_instances.py +191 -0
  75. aphex_ml-0.1.0a1/tests/test_llm_plugin.py +428 -0
  76. aphex_ml-0.1.0a1/tests/test_multi_gpu.py +224 -0
  77. aphex_ml-0.1.0a1/tests/test_pareto.py +71 -0
  78. aphex_ml-0.1.0a1/tests/test_pipeline.py +129 -0
  79. aphex_ml-0.1.0a1/tests/test_preflight.py +65 -0
  80. aphex_ml-0.1.0a1/tests/test_profiler.py +26 -0
  81. aphex_ml-0.1.0a1/tests/test_pruning.py +243 -0
  82. aphex_ml-0.1.0a1/tests/test_pytorch_plugin.py +189 -0
  83. aphex_ml-0.1.0a1/tests/test_recommender.py +146 -0
  84. aphex_ml-0.1.0a1/tests/test_registry.py +118 -0
  85. aphex_ml-0.1.0a1/tests/test_remote.py +277 -0
  86. aphex_ml-0.1.0a1/tests/test_selector.py +275 -0
  87. aphex_ml-0.1.0a1/tests/test_serving.py +317 -0
  88. aphex_ml-0.1.0a1/tests/test_sklearn_plugin.py +260 -0
  89. aphex_ml-0.1.0a1/tests/test_system_recommender.py +325 -0
  90. aphex_ml-0.1.0a1/uv.lock +2197 -0
@@ -0,0 +1,86 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ tags:
7
+ - "v*"
8
+ pull_request:
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ python-version: ["3.12"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Install uv
21
+ uses: astral-sh/setup-uv@v4
22
+ with:
23
+ version: "latest"
24
+
25
+ - name: Set up Python
26
+ run: uv python install ${{ matrix.python-version }}
27
+
28
+ - name: Install dependencies
29
+ run: uv sync --all-extras --dev
30
+
31
+ - name: Lint
32
+ run: uv run ruff check infermap/ tests/
33
+
34
+ - name: Type check
35
+ run: uv run mypy infermap/ --ignore-missing-imports
36
+
37
+ - name: Test
38
+ run: uv run pytest tests/ -v --cov=infermap --cov-report=term-missing
39
+
40
+ publish-test:
41
+ if: startsWith(github.ref, 'refs/tags/v')
42
+ needs: test
43
+ runs-on: ubuntu-latest
44
+ environment: testpypi
45
+ permissions:
46
+ id-token: write
47
+
48
+ steps:
49
+ - uses: actions/checkout@v4
50
+
51
+ - name: Install uv
52
+ uses: astral-sh/setup-uv@v4
53
+
54
+ - name: Build
55
+ run: uv build
56
+
57
+ - name: Publish to TestPyPI
58
+ run: uv publish --publish-url https://test.pypi.org/legacy/
59
+
60
+ - name: Verify install from TestPyPI
61
+ run: |
62
+ pip install \
63
+ --index-url https://test.pypi.org/simple/ \
64
+ --extra-index-url https://pypi.org/simple/ \
65
+ aphex-ml
66
+ aphex --help
67
+
68
+ publish:
69
+ if: startsWith(github.ref, 'refs/tags/v')
70
+ needs: publish-test
71
+ runs-on: ubuntu-latest
72
+ environment: pypi
73
+ permissions:
74
+ id-token: write
75
+
76
+ steps:
77
+ - uses: actions/checkout@v4
78
+
79
+ - name: Install uv
80
+ uses: astral-sh/setup-uv@v4
81
+
82
+ - name: Build
83
+ run: uv build
84
+
85
+ - name: Publish to PyPI
86
+ run: uv publish
@@ -0,0 +1,236 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+ idea.txt
191
+ aphex.txt
192
+ # Abstra
193
+ # Abstra is an AI-powered process automation framework.
194
+ # Ignore directories containing user credentials, local state, and settings.
195
+ # Learn more at https://abstra.io/docs
196
+ .abstra/
197
+
198
+ # Visual Studio Code
199
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
200
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
201
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
202
+ # you could uncomment the following to ignore the entire vscode folder
203
+ # .vscode/
204
+ # Temporary file for partial code execution
205
+ tempCodeRunnerFile.py
206
+
207
+ # Ruff stuff:
208
+ .ruff_cache/
209
+
210
+ # PyPI configuration file
211
+ .pypirc
212
+
213
+ # Marimo
214
+ marimo/_static/
215
+ marimo/_lsp/
216
+ __marimo__/
217
+
218
+ # Streamlit
219
+ .streamlit/secrets.toml
220
+ .claude/*
221
+
222
+
223
+ ALPHA_ROADMAP.md
224
+ idea.txt
225
+ note.txt
226
+
227
+ # Model artifacts and test data
228
+ model.pt
229
+ calib_data.pt
230
+ eval_data.pt
231
+ infer.py
232
+ *.engine
233
+ *.onnx
234
+ resnet18.pt
235
+ *.pth
236
+ deployment.yaml
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,102 @@
1
+ # Contributing to aphex
2
+
3
+ ## Setup
4
+
5
+ aphex uses [uv](https://docs.astral.sh/uv/) for dependency management.
6
+
7
+ ```bash
8
+ git clone https://github.com/<your-fork>/aphex
9
+ cd aphex
10
+ uv sync --all-extras --dev
11
+ ```
12
+
13
+ This installs all optional extras (torch, sklearn, onnx, aws, gcp) plus the dev tools (pytest, ruff, mypy).
14
+
15
+ ## Running tests
16
+
17
+ ```bash
18
+ # Fast suite — no network, no real models (~7 s)
19
+ uv run pytest tests/
20
+
21
+ # Include CUDA-specific tests (requires a GPU)
22
+ uv run pytest tests/ -m requires_cuda
23
+
24
+ # Integration tests — download real model weights
25
+ uv run pytest tests/ -m integration
26
+ ```
27
+
28
+ Integration tests are excluded by default because they pull weights from the internet. They are the right regression test to run before opening a PR that touches the benchmark or plugin layer.
29
+
30
+ ## Code style
31
+
32
+ ```bash
33
+ uv run ruff check infermap/ tests/ # lint
34
+ uv run ruff format infermap/ tests/ # auto-format
35
+ uv run mypy infermap/ # type check
36
+ ```
37
+
38
+ CI runs all three. A PR that fails lint or type-check won't be merged.
39
+
40
+ Line length is 100. Target is Python 3.12+.
41
+
42
+ ## Project layout
43
+
44
+ ```
45
+ infermap/
46
+ cli.py # Typer CLI — entry point for all commands
47
+ benchmark.py # timing loop, BenchmarkResult
48
+ candidates.py # DeploymentCandidate generation
49
+ evaluator.py # accuracy/F1/MAE/RMSE measurement, cloud eval data download
50
+ recommender.py # Pareto filtering + objective ranking → Recommendation
51
+ pareto.py # build_pareto_frontier(), rank_by_objective()
52
+ profiler.py # HardwareProfile — CPU, CUDA, MPS, CoreML
53
+ preflight.py # feasibility check before benchmarking
54
+ inspector.py # ModelInfo — parameter count, memory, family
55
+ converter.py # export to .pt / .onnx / .engine / .xml
56
+ selector.py # candidate fingerprint-based pre-selection
57
+ cost_model.py # prune candidates predicted >10× slower than best
58
+ checker.py # regression check against a saved deployment.yaml
59
+ deployment.py # deployment.yaml read/write
60
+ report.py # HTML benchmark report
61
+ serving/ # serving config generators (Triton, TorchServe, BentoML, FastAPI)
62
+ cloud/
63
+ remote.py # SSH-based remote execution
64
+ storage.py # S3 + GCS backends
65
+ registry.py # push/pull versioned model artifacts
66
+ instances.py # cloud instance profiles for --target
67
+ plugins/ # per-framework ModelPlugin implementations
68
+ pytorch.py
69
+ sklearn.py
70
+ tensorflow.py
71
+ llm.py
72
+ registry.py # plugin auto-detection from file extension / magic bytes
73
+ tests/
74
+ integration/ # real-model tests; excluded from default run
75
+ ```
76
+
77
+ ## Adding a backend
78
+
79
+ 1. Add a `DeploymentCandidate` entry in `candidates.py` for the appropriate hardware path (`_cuda_candidates`, `_mps_candidates`, `_cpu_candidates`).
80
+ 2. Add a benchmark branch in `benchmark.py` (`_benchmark_candidate`) that runs the backend and returns latency/throughput numbers.
81
+ 3. Add the backend key to `ALL_CONVERTIBLE` in `converter.py` and implement the export branch if the backend produces a file artifact.
82
+ 4. Add accuracy evaluation support in `evaluator.py` (`_PYTORCH_EVAL_BACKENDS` or the sklearn equivalent) if the backend can degrade quality.
83
+ 5. Cover all four steps with tests.
84
+
85
+ ## Adding a model family (plugin)
86
+
87
+ Implement the `ModelPlugin` abstract class in `infermap/plugin.py`:
88
+
89
+ - `can_handle(path)` — return True if this plugin owns the file
90
+ - `inspect(path)` → `ModelInfo`
91
+ - `load(path)` → model object
92
+ - `generate_candidates(info, hw)` → `list[DeploymentCandidate]`
93
+ - `benchmark(candidate, model, info, shape, batch_size, ...)` → `BenchmarkResult`
94
+
95
+ Register the plugin in `infermap/registry.py`.
96
+
97
+ ## Pull requests
98
+
99
+ - Keep PRs focused - one feature or fix per PR.
100
+ - New behaviour needs a test. Bug fixes should include a regression test.
101
+ - Update `README.md` if you change the CLI interface or add a supported backend.
102
+ - CI must pass (lint + type check + tests) before review.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rayansh Singh
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.