infer-check 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.
- infer_check-0.1.0/.github/workflows/coverage.yml +36 -0
- infer_check-0.1.0/.github/workflows/release.yml +70 -0
- infer_check-0.1.0/.gitignore +62 -0
- infer_check-0.1.0/.pre-commit-config.yaml +66 -0
- infer_check-0.1.0/CHANGELOG.md +9 -0
- infer_check-0.1.0/LICENSE +201 -0
- infer_check-0.1.0/Makefile +29 -0
- infer_check-0.1.0/PKG-INFO +210 -0
- infer_check-0.1.0/README.md +167 -0
- infer_check-0.1.0/prompt-suites/adversarial-numerics.jsonl +30 -0
- infer_check-0.1.0/prompt-suites/code.jsonl +49 -0
- infer_check-0.1.0/prompt-suites/determinism.jsonl +50 -0
- infer_check-0.1.0/prompt-suites/long-context.jsonl +10 -0
- infer_check-0.1.0/prompt-suites/reasoning.jsonl +50 -0
- infer_check-0.1.0/pyproject.toml +76 -0
- infer_check-0.1.0/src/infer_check/__init__.py +23 -0
- infer_check-0.1.0/src/infer_check/analysis/__init__.py +3 -0
- infer_check-0.1.0/src/infer_check/analysis/clustering.py +118 -0
- infer_check-0.1.0/src/infer_check/analysis/determinism.py +201 -0
- infer_check-0.1.0/src/infer_check/analysis/divergence.py +292 -0
- infer_check-0.1.0/src/infer_check/backends/__init__.py +17 -0
- infer_check-0.1.0/src/infer_check/backends/base.py +87 -0
- infer_check-0.1.0/src/infer_check/backends/llama_cpp.py +119 -0
- infer_check-0.1.0/src/infer_check/backends/mlx_lm.py +237 -0
- infer_check-0.1.0/src/infer_check/backends/openai_compat.py +220 -0
- infer_check-0.1.0/src/infer_check/backends/vllm_mlx.py +81 -0
- infer_check-0.1.0/src/infer_check/cli.py +597 -0
- infer_check-0.1.0/src/infer_check/prompt_suites/__init__.py +50 -0
- infer_check-0.1.0/src/infer_check/prompt_suites/adversarial-numerics.jsonl +30 -0
- infer_check-0.1.0/src/infer_check/prompt_suites/code.jsonl +49 -0
- infer_check-0.1.0/src/infer_check/prompt_suites/determinism.jsonl +50 -0
- infer_check-0.1.0/src/infer_check/prompt_suites/long-context.jsonl +10 -0
- infer_check-0.1.0/src/infer_check/prompt_suites/reasoning.jsonl +50 -0
- infer_check-0.1.0/src/infer_check/py.typed +0 -0
- infer_check-0.1.0/src/infer_check/reporting/__init__.py +2 -0
- infer_check-0.1.0/src/infer_check/reporting/github_issue.py +226 -0
- infer_check-0.1.0/src/infer_check/reporting/html.py +908 -0
- infer_check-0.1.0/src/infer_check/reporting/json_export.py +193 -0
- infer_check-0.1.0/src/infer_check/runner.py +435 -0
- infer_check-0.1.0/src/infer_check/suites/__init__.py +1 -0
- infer_check-0.1.0/src/infer_check/suites/loader.py +60 -0
- infer_check-0.1.0/src/infer_check/types.py +105 -0
- infer_check-0.1.0/tests/unit/test_cli.py +95 -0
- infer_check-0.1.0/tests/unit/test_clustering.py +175 -0
- infer_check-0.1.0/tests/unit/test_divergence.py +71 -0
- infer_check-0.1.0/tests/unit/test_loader.py +38 -0
- infer_check-0.1.0/tests/unit/test_mlx_backend.py +69 -0
- infer_check-0.1.0/tests/unit/test_openai_compat.py +93 -0
- infer_check-0.1.0/tests/unit/test_runner.py +116 -0
- infer_check-0.1.0/tests/unit/test_types.py +71 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Run tests and upload coverage
|
|
2
|
+
|
|
3
|
+
on: push
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
name: Run tests and collect coverage
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- name: Checkout code
|
|
11
|
+
uses: actions/checkout@v6
|
|
12
|
+
with:
|
|
13
|
+
fetch-depth: 2
|
|
14
|
+
|
|
15
|
+
- name: Set up uv
|
|
16
|
+
uses: astral-sh/setup-uv@v7
|
|
17
|
+
with:
|
|
18
|
+
activate-environment: "true"
|
|
19
|
+
python-version: "3.13"
|
|
20
|
+
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: uv pip install -e .[dev]
|
|
23
|
+
|
|
24
|
+
- name: Run tests with coverage
|
|
25
|
+
run: uv run pytest --cov=src --cov-branch --cov-report=xml
|
|
26
|
+
|
|
27
|
+
- name: Run Mypy
|
|
28
|
+
run: uv run mypy src --cobertura-xml-report mypy_report
|
|
29
|
+
|
|
30
|
+
- name: Upload coverage to Codecov
|
|
31
|
+
uses: codecov/codecov-action@v5
|
|
32
|
+
with:
|
|
33
|
+
files: ./coverage.xml, ./mypy_report/cobertura.xml
|
|
34
|
+
flags: pytest,mypy
|
|
35
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
36
|
+
slug: ${{ github.repository }}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
name: Release to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
name: Build distribution
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v6
|
|
14
|
+
- name: Set up uv
|
|
15
|
+
uses: astral-sh/setup-uv@v7
|
|
16
|
+
with:
|
|
17
|
+
activate-environment: "true"
|
|
18
|
+
python-version: "3.13"
|
|
19
|
+
|
|
20
|
+
- name: Install build tools
|
|
21
|
+
run: uv pip install build
|
|
22
|
+
|
|
23
|
+
- name: Build sdist and wheel
|
|
24
|
+
run: uv build
|
|
25
|
+
|
|
26
|
+
- name: Store the distribution packages
|
|
27
|
+
uses: actions/upload-artifact@v6
|
|
28
|
+
with:
|
|
29
|
+
name: infer-check
|
|
30
|
+
path: dist/
|
|
31
|
+
|
|
32
|
+
publish-to-testpypi:
|
|
33
|
+
name: Publish to TestPyPI
|
|
34
|
+
needs: build
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
environment:
|
|
37
|
+
name: testpypi
|
|
38
|
+
url: https://test.pypi.org
|
|
39
|
+
permissions:
|
|
40
|
+
id-token: write
|
|
41
|
+
steps:
|
|
42
|
+
- name: Download all the dists
|
|
43
|
+
uses: actions/download-artifact@v6
|
|
44
|
+
with:
|
|
45
|
+
name: infer-check
|
|
46
|
+
path: dist/
|
|
47
|
+
|
|
48
|
+
- name: Publish to TestPyPI
|
|
49
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
50
|
+
with:
|
|
51
|
+
repository-url: https://test.pypi.org/legacy/
|
|
52
|
+
|
|
53
|
+
publish-to-pypi:
|
|
54
|
+
name: Publish to PyPI
|
|
55
|
+
needs: publish-to-testpypi
|
|
56
|
+
runs-on: ubuntu-latest
|
|
57
|
+
environment:
|
|
58
|
+
name: pypi
|
|
59
|
+
url: https://pypi.org
|
|
60
|
+
permissions:
|
|
61
|
+
id-token: write
|
|
62
|
+
steps:
|
|
63
|
+
- name: Download all the dists
|
|
64
|
+
uses: actions/download-artifact@v6
|
|
65
|
+
with:
|
|
66
|
+
name: infer-check
|
|
67
|
+
path: dist/
|
|
68
|
+
|
|
69
|
+
- name: Publish to TestPyPI
|
|
70
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
*.egg
|
|
7
|
+
*.egg-info/
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
.eggs/
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
# uv
|
|
18
|
+
uv.lock
|
|
19
|
+
|
|
20
|
+
# Type checking / linting / testing
|
|
21
|
+
.mypy_cache/
|
|
22
|
+
.ruff_cache/
|
|
23
|
+
.pytest_cache/
|
|
24
|
+
.coverage
|
|
25
|
+
htmlcov/
|
|
26
|
+
.test_cache/
|
|
27
|
+
|
|
28
|
+
# infer-check results and caches (generated)
|
|
29
|
+
results/
|
|
30
|
+
*.report.html
|
|
31
|
+
*.report.json
|
|
32
|
+
.infer_check_cache/
|
|
33
|
+
|
|
34
|
+
# Model weights (never commit)
|
|
35
|
+
*.safetensors
|
|
36
|
+
*.gguf
|
|
37
|
+
*.bin
|
|
38
|
+
*.pt
|
|
39
|
+
*.pth
|
|
40
|
+
*.onnx
|
|
41
|
+
*.mlpackage
|
|
42
|
+
|
|
43
|
+
# mlx model cache
|
|
44
|
+
~/.cache/huggingface/
|
|
45
|
+
|
|
46
|
+
# IDE
|
|
47
|
+
.vscode/
|
|
48
|
+
.idea/
|
|
49
|
+
*.swp
|
|
50
|
+
*.swo
|
|
51
|
+
*~
|
|
52
|
+
|
|
53
|
+
# OS
|
|
54
|
+
.DS_Store
|
|
55
|
+
Thumbs.db
|
|
56
|
+
|
|
57
|
+
# Secrets
|
|
58
|
+
.env
|
|
59
|
+
.env.local
|
|
60
|
+
|
|
61
|
+
# Internal planning
|
|
62
|
+
ROADMAP.md
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
# General file hygiene
|
|
3
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
4
|
+
rev: v5.0.0
|
|
5
|
+
hooks:
|
|
6
|
+
- id: trailing-whitespace
|
|
7
|
+
- id: end-of-file-fixer
|
|
8
|
+
- id: check-yaml
|
|
9
|
+
- id: check-json
|
|
10
|
+
- id: check-toml
|
|
11
|
+
- id: check-added-large-files
|
|
12
|
+
args: ["--maxkb=500"]
|
|
13
|
+
- id: check-merge-conflict
|
|
14
|
+
- id: detect-private-key
|
|
15
|
+
|
|
16
|
+
# Ruff โ lint + format in one pass
|
|
17
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
18
|
+
rev: v0.11.4
|
|
19
|
+
hooks:
|
|
20
|
+
- id: ruff
|
|
21
|
+
args: ["--fix", "--exit-non-zero-on-fix"]
|
|
22
|
+
types_or: [python, pyi]
|
|
23
|
+
- id: ruff-format
|
|
24
|
+
types_or: [python, pyi]
|
|
25
|
+
|
|
26
|
+
# Type checking
|
|
27
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
28
|
+
rev: v1.15.0
|
|
29
|
+
hooks:
|
|
30
|
+
- id: mypy
|
|
31
|
+
additional_dependencies:
|
|
32
|
+
- pydantic>=2.5.0
|
|
33
|
+
- numpy>=1.26.0
|
|
34
|
+
- click>=8.1.0
|
|
35
|
+
- httpx>=0.27.0
|
|
36
|
+
- types-jinja2
|
|
37
|
+
args: ["--strict", "--ignore-missing-imports"]
|
|
38
|
+
pass_filenames: false
|
|
39
|
+
entry: mypy src/infer_check/
|
|
40
|
+
|
|
41
|
+
# Validate JSONL prompt suites
|
|
42
|
+
- repo: local
|
|
43
|
+
hooks:
|
|
44
|
+
- id: validate-prompt-suites
|
|
45
|
+
name: validate prompt suite JSONL
|
|
46
|
+
entry: python
|
|
47
|
+
args:
|
|
48
|
+
- -c
|
|
49
|
+
- |
|
|
50
|
+
import json, sys, pathlib
|
|
51
|
+
errors = []
|
|
52
|
+
for f in pathlib.Path('prompt-suites').glob('*.jsonl'):
|
|
53
|
+
for i, line in enumerate(f.read_text().splitlines(), 1):
|
|
54
|
+
if not line.strip():
|
|
55
|
+
continue
|
|
56
|
+
try:
|
|
57
|
+
obj = json.loads(line)
|
|
58
|
+
assert 'text' in obj, 'missing text field'
|
|
59
|
+
except Exception as e:
|
|
60
|
+
errors.append(f'{f}:{i}: {e}')
|
|
61
|
+
if errors:
|
|
62
|
+
print('\n'.join(errors), file=sys.stderr)
|
|
63
|
+
sys.exit(1)
|
|
64
|
+
language: python
|
|
65
|
+
files: 'prompt-suites/.*\.jsonl$'
|
|
66
|
+
pass_filenames: false
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# 0.1.0 (2026-03-11)
|
|
2
|
+
|
|
3
|
+
- Initial release
|
|
4
|
+
- Commands: sweep, diff, stress, determinism, report
|
|
5
|
+
- Backends: mlx-lm, llama.cpp, vllm-mlx, openai-compat
|
|
6
|
+
- Baseline self-check (run-twice determinism validation)
|
|
7
|
+
- Severity tiers: identical / minor / moderate / severe
|
|
8
|
+
- Chat template auto-detection for instruct models
|
|
9
|
+
- Comprehensive error handling across all backends
|
|
@@ -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 text 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 format. We also 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 Karan Kunal Mohindroo
|
|
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,29 @@
|
|
|
1
|
+
.PHONY: install dev lint format test test-unit test-integration clean
|
|
2
|
+
|
|
3
|
+
install:
|
|
4
|
+
uv sync
|
|
5
|
+
|
|
6
|
+
dev:
|
|
7
|
+
uv sync --all-extras
|
|
8
|
+
uv run pre-commit install
|
|
9
|
+
|
|
10
|
+
lint:
|
|
11
|
+
uv run ruff check src/ tests/
|
|
12
|
+
|
|
13
|
+
format:
|
|
14
|
+
uv run ruff format src/ tests/
|
|
15
|
+
|
|
16
|
+
typecheck:
|
|
17
|
+
uv run mypy src/infer_check/
|
|
18
|
+
|
|
19
|
+
test: test-unit
|
|
20
|
+
|
|
21
|
+
test-unit:
|
|
22
|
+
uv run pytest tests/unit -v --tb=short
|
|
23
|
+
|
|
24
|
+
test-integration:
|
|
25
|
+
uv run pytest tests/integration -v --tb=short
|
|
26
|
+
|
|
27
|
+
clean:
|
|
28
|
+
rm -rf build/ dist/ *.egg-info .mypy_cache .ruff_cache .pytest_cache results/
|
|
29
|
+
find . -type d -name __pycache__ -exec rm -rf {} +
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: infer-check
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Correctness and reliability testing for LLM inference engines
|
|
5
|
+
Project-URL: Repository, https://github.com/nullpointerdepressivedisorder/infer-check
|
|
6
|
+
Author-email: Karan Kunal Mohindroo <karan@karankm.com>
|
|
7
|
+
License: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: correctness,llm,quantization,reliability,testing
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
12
|
+
Classifier: Topic :: Software Development :: Testing
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Requires-Dist: click>=8.3.1
|
|
15
|
+
Requires-Dist: httpx>=0.28.1
|
|
16
|
+
Requires-Dist: jinja2>=3.1.6
|
|
17
|
+
Requires-Dist: numpy>=2.4.3
|
|
18
|
+
Requires-Dist: pydantic>=2.12.5
|
|
19
|
+
Requires-Dist: rich>=14.3.3
|
|
20
|
+
Requires-Dist: scipy>=1.17.1
|
|
21
|
+
Requires-Dist: tqdm>=4.67.3
|
|
22
|
+
Provides-Extra: all
|
|
23
|
+
Requires-Dist: matplotlib>=3.10.8; extra == 'all'
|
|
24
|
+
Requires-Dist: mlx-lm<0.31.0; extra == 'all'
|
|
25
|
+
Requires-Dist: mlx>=0.31.0; extra == 'all'
|
|
26
|
+
Requires-Dist: scikit-learn>=1.8.0; extra == 'all'
|
|
27
|
+
Provides-Extra: analysis
|
|
28
|
+
Requires-Dist: matplotlib>=3.10.8; extra == 'analysis'
|
|
29
|
+
Requires-Dist: scikit-learn>=1.8.0; extra == 'analysis'
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: matplotlib>=3.10.8; extra == 'dev'
|
|
32
|
+
Requires-Dist: mlx-lm<0.31.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: mlx>=0.31.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: mypy>=1.19.1; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest-cov>=7.0.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest>=9.0.2; extra == 'dev'
|
|
37
|
+
Requires-Dist: ruff>=0.15.5; extra == 'dev'
|
|
38
|
+
Requires-Dist: scikit-learn>=1.8.0; extra == 'dev'
|
|
39
|
+
Provides-Extra: mlx
|
|
40
|
+
Requires-Dist: mlx-lm<0.31.0; extra == 'mlx'
|
|
41
|
+
Requires-Dist: mlx>=0.31.0; extra == 'mlx'
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
|
|
44
|
+
# infer-check
|
|
45
|
+
|
|
46
|
+
**Correctness and reliability testing for LLM inference engines.**
|
|
47
|
+
|
|
48
|
+
`infer-check` is a CLI tool that tests whether LLM inference backends produce correct, stable, and deterministic output. It catches the bugs that benchmarks miss โ quantization-induced failures, cross-backend divergence, KV cache corruption under load, and non-determinism at temperature=0.
|
|
49
|
+
|
|
50
|
+
## Key findings
|
|
51
|
+
|
|
52
|
+
Tested across Llama-3.1-8B-Instruct and Qwen3.5-4B (MoE) on Apple Silicon using mlx-lm and vllm-mlx.
|
|
53
|
+
|
|
54
|
+
**4-bit quantization degrades task-dependently.** Numerical tasks break worst:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
Llama-3.1-8B: bf16 vs 4bit
|
|
58
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโณโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโ
|
|
59
|
+
โ prompt suite โ identical โ severe โ mean_similarity โ
|
|
60
|
+
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
|
|
61
|
+
โ adversarial-numerics โ 0/30 โ 23/30 โ 0.311 โ
|
|
62
|
+
โ reasoning โ 1/50 โ 35/50 โ 0.384 โ
|
|
63
|
+
โ code โ 0/49 โ 30/49 โ 0.452 โ
|
|
64
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโ
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Dense and MoE architectures degrade similarly at 4-bit.** Qwen3.5-4B (Gated Delta Networks + sparse MoE) shows 35/50 severe on reasoning โ the same rate as dense Llama-3.1-8B.
|
|
68
|
+
|
|
69
|
+
**vllm-mlx's serving layer is perfectly faithful.** mlx-lm vs vllm-mlx at temperature=0 on Llama-3.1-8B-4bit: 50/50 identical (reasoning) and 30/30 identical (numerics). The serving layer introduces zero divergence.
|
|
70
|
+
|
|
71
|
+
**Both engines are deterministic at temperature=0.** Llama-3.1-8B-4bit and Qwen3.5-4B both scored 50/50 perfect determinism across 20 runs per prompt.
|
|
72
|
+
|
|
73
|
+
**vllm-mlx handles concurrent load without corruption.** Stress test at concurrency 1/2/4/8: zero errors, 100% output consistency at all levels.
|
|
74
|
+
|
|
75
|
+
## Installation
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install infer-check
|
|
79
|
+
|
|
80
|
+
# With MLX backend support (Apple Silicon)
|
|
81
|
+
pip install "infer-check[mlx]"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
### Quantization sweep
|
|
87
|
+
|
|
88
|
+
Compare pre-quantized models against a baseline. Each model is a separate HuggingFace repo.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
infer-check sweep \
|
|
92
|
+
--models "bf16=mlx-community/Meta-Llama-3.1-8B-Instruct-bf16,\
|
|
93
|
+
8bit=mlx-community/Meta-Llama-3.1-8B-Instruct-8bit,\
|
|
94
|
+
4bit=mlx-community/Meta-Llama-3.1-8B-Instruct-4bit" \
|
|
95
|
+
--backend mlx-lm \
|
|
96
|
+
--prompts reasoning \
|
|
97
|
+
--output ./results/sweep/
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`--prompts` accepts either a bundled suite name (`reasoning`, `code`, `adversarial-numerics`, `determinism`, `long-context`) or a path to any `.jsonl` file.
|
|
101
|
+
|
|
102
|
+
The baseline is automatically run twice as a self-check โ if it's not 50/50 identical, your comparison data is unreliable.
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
Sweep Summary
|
|
106
|
+
โโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโณโโโโโโโโณโโโโโโโโโโโณโโโโโโโโโณโโโโโโโโโโโโโโโโโโ
|
|
107
|
+
โ quant_level โ identical โ minor โ moderate โ severe โ mean_similarity โ
|
|
108
|
+
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
|
|
109
|
+
โ bf16 (self-check) โ 50/50 โ 0/50 โ 0/50 โ 0/50 โ 1.0000 โ
|
|
110
|
+
โ 8bit โ 20/50 โ 9/50 โ 12/50 โ 9/50 โ 0.8067 โ
|
|
111
|
+
โ 4bit โ 1/50 โ 3/50 โ 11/50 โ 35/50 โ 0.3837 โ
|
|
112
|
+
โโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโโโโ
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Cross-backend diff
|
|
116
|
+
|
|
117
|
+
Same model, same quant, different inference paths. Catches serving-layer bugs.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Start vllm-mlx in another terminal:
|
|
121
|
+
# vllm-mlx serve mlx-community/Meta-Llama-3.1-8B-Instruct-4bit --port 8000
|
|
122
|
+
|
|
123
|
+
infer-check diff \
|
|
124
|
+
--model mlx-community/Meta-Llama-3.1-8B-Instruct-4bit \
|
|
125
|
+
--backends "mlx-lm,openai-compat" \
|
|
126
|
+
--base-urls ",http://localhost:8000" \
|
|
127
|
+
--prompts reasoning \
|
|
128
|
+
--output ./results/diff/
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Uses `/v1/chat/completions` by default (`--chat`) so server-side chat templates match the local backend. Pass `--no-chat` for raw `/v1/completions`.
|
|
132
|
+
|
|
133
|
+
### Determinism
|
|
134
|
+
|
|
135
|
+
Same prompt N times at temperature=0. Output should be bit-identical every run.
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
infer-check determinism \
|
|
139
|
+
--model mlx-community/Meta-Llama-3.1-8B-Instruct-4bit \
|
|
140
|
+
--backend mlx-lm \
|
|
141
|
+
--prompts determinism \
|
|
142
|
+
--runs 20 \
|
|
143
|
+
--output ./results/determinism/
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Stress test
|
|
147
|
+
|
|
148
|
+
Concurrent requests through a serving backend. Tests KV cache correctness under load.
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
infer-check stress \
|
|
152
|
+
--model mlx-community/Meta-Llama-3.1-8B-Instruct-4bit \
|
|
153
|
+
--backend openai-compat \
|
|
154
|
+
--base-url http://localhost:8000 \
|
|
155
|
+
--prompts reasoning \
|
|
156
|
+
--concurrency 1,2,4,8 \
|
|
157
|
+
--output ./results/stress/
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Report
|
|
161
|
+
|
|
162
|
+
Generate an HTML report from all saved results.
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
infer-check report ./results/ --format html
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Prompt suites
|
|
169
|
+
|
|
170
|
+
Curated prompts targeting known quantization failure modes:
|
|
171
|
+
|
|
172
|
+
| Suite | Count | Purpose |
|
|
173
|
+
|---|---|---|
|
|
174
|
+
| `reasoning.jsonl` | 50 | Multi-step math and logic |
|
|
175
|
+
| `code.jsonl` | 49 | Python, JSON, SQL generation |
|
|
176
|
+
| `adversarial-numerics.jsonl` | 30 | IEEE 754 edge cases, overflow, precision |
|
|
177
|
+
| `long-context.jsonl` | 10 | Tables and transcripts with recall questions |
|
|
178
|
+
| `determinism.jsonl` | 50 | High-entropy continuations for determinism testing |
|
|
179
|
+
|
|
180
|
+
All suites ship with the package โ no need to clone the repo. Custom suites are JSONL files: `{"id": "...", "text": "...", "category": "...", "max_tokens": N}` per line.
|
|
181
|
+
|
|
182
|
+
## Supported backends
|
|
183
|
+
|
|
184
|
+
| Backend | Type | Use case |
|
|
185
|
+
|---|---|---|
|
|
186
|
+
| **mlx-lm** | In-process | Local Apple Silicon inference with logprobs |
|
|
187
|
+
| **llama.cpp** | HTTP | `llama-server` via `/completion` endpoint |
|
|
188
|
+
| **vllm-mlx** | HTTP | Continuous batching on Apple Silicon |
|
|
189
|
+
| **openai-compat** | HTTP | Any OpenAI-compatible server (vLLM, SGLang, Ollama) |
|
|
190
|
+
|
|
191
|
+
## Why this exists
|
|
192
|
+
|
|
193
|
+
Every LLM inference engine has correctness bugs that benchmarks don't catch:
|
|
194
|
+
|
|
195
|
+
- **KV cache NaN pollution** in vLLM-Ascend permanently corrupts all subsequent requests
|
|
196
|
+
- **FP8 KV quantization** in vLLM causes repeated garbage output
|
|
197
|
+
- **32.5% element mismatches** in SGLang's FP8 DeepGEMM kernels on Blackwell GPUs
|
|
198
|
+
- **Batch-size-dependent output** where tokens change depending on concurrent request count
|
|
199
|
+
|
|
200
|
+
These aren't model quality problems โ they're engine correctness failures. Benchmarks like lm-evaluation-harness test whether models are smart. `infer-check` tests whether engines are correct.
|
|
201
|
+
|
|
202
|
+
## Requirements
|
|
203
|
+
|
|
204
|
+
- Python >= 3.11
|
|
205
|
+
- macOS with Apple Silicon (for mlx-lm backend) or Linux
|
|
206
|
+
- At least one backend installed
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
Apache 2.0
|