quant-regress
Fail CI when quantization costs you task accuracy.
If you pinned
@v1before 2026-10-07, re-sync. That tag has moved to pick up five correctness fixes, including one where the gate reported PASS for a model it had never actually quantized. SeeCHANGELOG.md.
Token-level proxies — perplexity, KL divergence — routinely report that a quantized model is fine. Task accuracy does not, provided you actually measure it. This action measures a task eval at each precision and fails the build when accuracy drops past a threshold you set.
Why
On a cross-encoder claim verifier, dynamic INT8 quantization left aggregate accuracy looking survivable while destroying the capability that mattered:
| precision | accuracy | correct |
|---|---|---|
| fp32 (baseline) | 100.0% | 20/20 |
| int8 | 0.0% | 0/20 |
Regenerate with python scripts/regen_int8_collapse.py — every figure above
comes from that script, and tests/test_claims_are_reproducible.py fails the
build if a number in this file stops matching it. The run's output is committed at
results/int8_collapse.json, so the table above can be
audited without running anything.
The pattern that matters: the quantized model still runs, still returns a valid answer, and still looks like a working model. It is simply wrong every time. That is why a token-level proxy can clear it and a task eval cannot.
Usage
As a GitHub Action:
- uses: DawnofGenX/quant-regress@v1
with:
eval: evals/tasks.jsonl
model: meta-llama/Llama-3.2-1B-Instruct
max-drop-points: 2
min-accuracy: 0.5 # optional; see "Change is not quality" below
@v1 is a moving tag — it tracks the current release line, and has been re-pointed once
(to pick up the fixes in CHANGELOG.md). Pin a commit SHA if you need immutability.
Or from the command line / your own CI:
pip install quant-regress
quant-regress --eval evals/tasks.jsonl \
--model meta-llama/Llama-3.2-1B-Instruct \
--max-drop-points 2 \
--min-accuracy 0.5 \
--report quant-regress-report.json
Exit codes: 0 within tolerance, 1 accuracy regressed, 2 bad configuration.
Outputs
--report writes JSON containing every arm's accuracy, the drop in points, and the
misclassified case ids — so a red build names the cases that got worse instead of
only saying that something did. --output-format junit --junit-path results.xml
additionally writes JUnit XML with one <testcase> per precision, each failing arm
carrying a <failure> naming the drop and the cases. That is what Jenkins, GitLab
and the GitHub test-results pane render.
--progress-every 25 prints a progress line to stderr every N cases. Stdout
stays a parseable table, so a workflow that greps the summary line is unaffected.
Matching a chatty model
--scorer contains matches when expected appears anywhere in the prediction, for
a model that answers in a sentence. The default is exact — normalised equality,
which is what makes a marginal-decision drop visible in the first place. Only those
two are exposed on the CLI; a scorer that needs real logic belongs in the library,
via QuantHarness(..., scorer=fn). Deliberately not an arbitrary expression: this
tool runs on arbitrary PRs, and evaluating one would be code execution.
--labels "no,yes" names the classes for a logits-only model with no id2label.
--system-prompt prepends a prompt to every case. --hf-token (or $HF_TOKEN)
authenticates a gated model.
--min-accuracy is worth setting. Without it the gate only measures change, so a
model that is wrong at every precision yields a zero-point drop and passes — a green build
for a model that cannot do the task at all. --min-accuracy is a fraction (0.5 = half) and
fails the build when the baseline is that weak. It is a quality failure, so it exits 1,
not 2: the tool measured correctly and the answer is no. See
change is not quality.
Constraints worth knowing
- CPU only.
quantize_dynamicemits CPU-only quantized kernels; moving the model to CUDA raises at forward time. GitHub-hosted runners have no GPU, so this is not a limitation in CI — but it does mean GPU-only quantizers (AWQ/GPTQ/GGUF) are out of scope for v1. - Not every architecture can be quantized by this method, and the action
refuses rather than lying.
quantize_dynamiconly replaces module types in torch's own mapping table, which coversnn.Linear. Architectures whose blocks use something else — GPT-2 and GPT-J usetransformers.Conv1D— would have their transformer body left in fp32, so the "int8" arm would really be fp32 and the tool would report a 0.00-point drop and PASS for a model it never quantized. That architecture now exits2(misconfigured) with an actionable message instead. Use annn.Linear-based architecture: BERT, DeBERTa, Llama, Mistral. - Only the model's continuation is scored.
generate()returns the prompt followed by the new tokens, so the prediction is what the model added — not the question you asked it. Prompts should ask for a short, exact answer, andexpectedshould be that answer. A chatty model will not exact-match: use--scorer contains, or pass a scorer viaQuantHarness(..., scorer=fn)when using the library. - The threshold unit is accuracy points, not a ratio.
--max-drop-points: 2means "fail if any candidate is more than 2 points below the baseline". - The two gates use different units, deliberately.
--max-drop-pointsis in percentage points;--min-accuracyis a fraction —0.5, not50. A percentage-style value is rejected with an explanatory error rather than silently clamped, because a typo there would disable the floor instead of tightening it. - Comparison is exact-after-normalisation by default. Pass a scorer if you need semantic equivalence.
- Models are downloaded at run time. A 1B model is ~2 GB; check runner disk.
Honest limits
- Only
fp32and dynamicint8are supported in v1. - The library runs generation, so it needs a task whose success is checkable in code. It is not an LLM-judge harness.
- The bundled
evals/fixtures/collapse.jsonlis model-specific, and it does not exercise the generate path. Its cases expect the answeryes, so it only demonstrates a collapse for a model that answersyeswhen unquantized. Pointed at an untuned tiny LM it scores 0/N at both precisions, produces no drop, and the gate correctly reports PASS. It is also driven by a stub model exposing.answer(), so it tells you nothing about real decoding. Use it to see the output format; bring your own eval for a real check.
Change is not quality — read this before trusting a PASS
The gate's default judgement is about change: it fails when quantization costs
accuracy. That means a model that is equally bad at both precisions produces a
zero-point drop and passes. Measured on a ten-case set:
a model answering nothing correctly at either precision reports
worst drop: +0.00 pts -> PASS and exit 0 , and the same
model with --min-accuracy 0.5 reports FAIL. Regenerate with
python scripts/regen_quiet_model.py; the run's output is committed at
results/quiet_model.json.
That is correct for the tool's purpose — quantization did not cause it — but it means a green build is not evidence that the model works. Two options:
- Pass
--min-accuracy 0.5(or your own floor) so the baseline is gated too. This turns the case above intoFAIL/ exit1, with the reason printed. - Read the baseline accuracy in the report (
results/*.json, or thebaseline accuracy:line) before trusting a PASS. The number has always been recorded; nothing enforced it.
A floor breach is reported as a quality failure (exit 1), not a configuration
error (exit 2), because the tool measured correctly and the answer is simply no.
- What the repo's own CI pins is the exit-code contract (0 holds, 1 regressed,
2 misconfigured), not any particular model's accuracy — see
tests/test_selftest_gate.py. - No published adoption yet. If you use it, an issue saying what you quantized and what broke is genuinely useful.
Metadata
Release files for quant-regress 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| quant_regress-1.0.3.tar.gz | 47.5 kB | With provenance | Details for quant_regress-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quant_regress-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for quant_regress-1.0.3-py3-none-any.whl |
Total release size: 69.2 kB
Release files / quant_regress-1.0.3.tar.gz
| Download URL | quant_regress-1.0.3.tar.gz |
|---|---|
| Size | 47.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
952df1d1a07f0436e811b7bd188dd2f8ce111066d62a1e07ebaf08ea479d0078
|
|
BLAKE2b-256 checksum How to use checksums |
5c3bf4d7ba80dfa7697375c9626b99250fec6e47d7b871ca9b16138b7d8f67c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / quant_regress-1.0.3-py3-none-any.whl
| Download URL | quant_regress-1.0.3-py3-none-any.whl |
|---|---|
| Size | 21.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa2aaae617c29a6b1f38ab3fbe99349ce6194db435335543c59e1cbc2f3377e2
|
|
BLAKE2b-256 checksum How to use checksums |
9570094b8e5575190b511b214bd85812a7d89f45559ac9436f279e62558892f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logSecurity for quant-regress 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for quant_regress-1.0.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.