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

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.1
File Size Uploaded Provenance
fastermodels-0.1.1.tar.gz 20.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 41.0 kB

Release files / fastermodels-0.1.1.tar.gz

Download URL fastermodels-0.1.1.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b1abfeed1402808a3488d2c0f0c1d85c21b7e680d566e9ccf36328a2b194d94b
BLAKE2b-256 checksum
How to use checksums
8788bf296f6da918a23fbe2f8b052cc29cc4bd69a5315675110dde10c23ce352
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.1-py3-none-any.whl

Download URL fastermodels-0.1.1-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5811e68c1b9fbd1ed7778d5c5604f4bd35a4d80a03e95abfa4aac69ca65ea91f
BLAKE2b-256 checksum
How to use checksums
54647b16abd1d723e50c481c32e616a27b4d3e956099d8aeeadae6680a6a2a4e
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.1

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