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

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.2
File Size Uploaded Provenance
fastermodels-0.1.2.tar.gz 19.9 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 40.8 kB

Release files / fastermodels-0.1.2.tar.gz

Download URL fastermodels-0.1.2.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0b9d9c3fd6001d2eebbbac600fb5658fbf73e512bc6d931f41d15b87702583a3
BLAKE2b-256 checksum
How to use checksums
d560a3e50ab3175c19ec0f3728cc63d1c6a86844b34be8f9a209b212e3eac4cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.11

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

Download URL fastermodels-0.1.2-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36d74d43f956617564c82d68a4da23f5018ff9fe6c72a341207e48c91523361b
BLAKE2b-256 checksum
How to use checksums
6497465f67ecde84fcf4a0c710a559b17a10e222ec8ee7a02fc1800ec98de00c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.11

Security for fastermodels 0.1.2

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