Skip to main content

fastermodels

Load, evaluate and publish models optimized by fasterai

A model optimized by fasterai no longer has the shapes its factory builds — a pruned ResNet has fewer channels than torchvision.models.resnet18 gives you, and a checkpoint alone will not load. fastermodels publishes the missing half: the factory, the rebuild spec of the layers that changed, and the weights, in one artifact that reloads anywhere with FasterModel.from_pretrained.

It also carries what a reader needs in order to trust the artifact:

  • FasterModel — rebuild the architecture from its spec, load the weights strictly, push to the Hub; load brings back whichever form a repo publishes — weights, TorchScript or ONNX
  • eval — the four criteria a card carries: top-1 (per-image correctness, Wilson intervals, paired deltas with an exact McNemar p), size, memory (peak live activations) and MACs
  • card — a model card written from measured values only, and a reader that flags what it should not say
  • gate — the ten conditions an artifact meets before it is published

Install

pip install fastermodels

How to use

Publish a model you just optimized:

from fastermodels import FasterModel

fm = FasterModel.wrap(pruned, 'torchvision.models.resnet18', {'num_classes': 10, 'weights': None},
                      recipe={'prune': 'ratio 0.3, local, round_to 8'})
fm.save_pretrained('artifact')            # config.json + model.safetensors

Load it back and measure it:

from fastermodels import load, correct_vector, wilson, paired_delta, params, macs, peak_activation_bytes

fm = load('artifact')                          # safetensors, else TorchScript, else the ONNX path
opt = correct_vector(fm, valid_dl)
k, n = int(opt.sum()), opt.size
wilson(k, n)                                   # the interval that belongs next to k/n
paired_delta(correct_vector(source, valid_dl), opt)
params(fm), macs(fm, sample), peak_activation_bytes(fm, sample)   # size, compute, memory at batch 1

Write its card and run the gate before publishing:

from fastermodels import render_card, check_card, run_gate, gate_passed

open('artifact/README.md', 'w').write(render_card(meta))
check_card(open('artifact/README.md').read())          # [] when the card is clean
gate_passed(run_gate('artifact', manifest))

Documentation

The API pages are at FasterAI-Labs.github.io/fastermodels: Model, Eval, Card, Gate.

Metadata

Release files for fastermodels 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastermodels 0.1.0
File Size Uploaded Provenance
fastermodels-0.1.0.tar.gz 19.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fastermodels 0.1.0
File Interpreter ABI Platform
fastermodels-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 40.3 kB

Release files / fastermodels-0.1.0.tar.gz

Download URL fastermodels-0.1.0.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
86fb97383fd2ed280b9a5a3c39b32158a4ab5847a2f02ade6da4ed5d1846891e
BLAKE2b-256 checksum
How to use checksums
45755ee9eb8f11087a619a89c85902c06b3ead423f05504769b8ab3537fefeb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / fastermodels-0.1.0-py3-none-any.whl

Download URL fastermodels-0.1.0-py3-none-any.whl
Size 20.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a4083e6c0007ef221fbf81f23cf96c855e917396eebda991e1e33e0c15d4839
BLAKE2b-256 checksum
How to use checksums
f7f1c7cd72fb923563ba2d3fabc732fcea5de08b6d189e1bb251fe6193f2e7ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Security for fastermodels 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page