Skip to main content

Quantization report cards for PyTorch models headed to the edge

Project description

quantcard

Quantization report cards for PyTorch models headed to the edge.

You trained a model and you want it smaller and faster on-device. torchao gives you a dozen quantization configs; ExecuTorch consumes them; but nothing tells you, for your model, what each config costs in accuracy and buys in size and latency. quantcard answers that with one command:

pip install quantcard

quantcard report my_model.py
| config       | top-1 acc | acc delta | weights  | size ratio | latency (ms) | speedup |
|--------------|-----------|-----------|----------|------------|--------------|---------|
| fp32         | 98.44%    | +0.00%    | 100 KiB  | 1.00x      | 0.05         | 1.00x   |
| int8wo       | 98.44%    | +0.00%    | 33 KiB   | 0.33x      | 0.05         | 1.05x   |
| int8da-int8w | 98.24%    | -0.20%    | 33 KiB   | 0.33x      | 0.06         | 0.90x   |

Your model file just needs two functions:

# my_model.py
def get_model():          # -> torch.nn.Module (trained, ready for eval)
    ...

def get_eval_batches():   # -> iterable of (inputs, targets)
    ...

Configs

fp32 (baseline) · int8wo · int8da-int8w · int4wo · int8da-int4w (the classic ExecuTorch 8da4w recipe) · qat-int8da-int4w (QAT prepare step — what the fake-quant numerics cost before any training). Run quantcard report model.py --configs all for everything.

ExecuTorch export column

With the executorch package installed (pip install quantcard[pte]), --pte adds a column with the exported .pte program size — and tells you honestly when a config can't export yet:

| config | ... | .pte |
| fp32   | ... | 102 KiB |
| int8wo | ... | 32 KiB |
| int8da-int4w | ... | export failed (RuntimeError) |

Status

Early alpha, deliberately narrow: torchao configs, CPU accuracy/size/latency, .pte export size, markdown reports. Planned next: robustness rows (input noise, quantized-vs-float disagreement rate), QAT convert deltas after a training hook, and device latency via ExecuTorch runners.

Development

pip install -e .[dev]
pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quantcard-0.1.0a1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quantcard-0.1.0a1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file quantcard-0.1.0a1.tar.gz.

File metadata

  • Download URL: quantcard-0.1.0a1.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quantcard-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 c20f1ab9c13072c72de11a2e27b25c82c30460b5b8712c8a2f246d2a925d06b9
MD5 0b3ee81d517162624fc78bc04a54c917
BLAKE2b-256 37dd6a6f3aae0be41ae86ec0c9d6407cdf9d9655961fa686d07cc0bb29aa5a9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for quantcard-0.1.0a1.tar.gz:

Publisher: release.yml on JPL11/quantcard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quantcard-0.1.0a1-py3-none-any.whl.

File metadata

  • Download URL: quantcard-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quantcard-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 2ee5620cadea9090f68af4094ebc7e6802b0bc732f029edb83ff1f042db715e9
MD5 b967714a27416865fe02e1385a3597dc
BLAKE2b-256 92e78cc17b962b7fe12f40a32b1a0deaec6f5daf1940d73aa0142995ed0a627b

See more details on using hashes here.

Provenance

The following attestation bundles were made for quantcard-0.1.0a1-py3-none-any.whl:

Publisher: release.yml on JPL11/quantcard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page