You choose an outcome, not a technique.
Our optimization engine measures your model, picks the right per-layer strategy, applies it, recovers the accuracy, and proves what changed — from a single call.
from fasterai import optimize
result = optimize(model, sample, target='speed')
result.model # → compressed, ready to use
result.compression # → {'size': 8.1, 'latency': 3.4}
result.export('model.onnx') Optimize for an outcome.
Say what you want — lower latency, a smaller file, a specific device — and the engine selects the validated strategy: which allocator, which order, what to quantize. You express intent; it handles the mechanics.
optimize(m, x, target='speed', data=dls) # fastest on any hardware
optimize(m, x, target='size', data=dls) # smallest on disk
optimize(m, x, target='flops', data=dls) # to an explicit FLOP budget
optimize(m, x, target='speed', target_pct=50, data=dls) # dial the budget yourself | target | strategy | best for |
|---|---|---|
speed |
uniform prune → FLOP budget + INT8 | latency, any hardware |
size |
iterative prune → param budget | smallest model, storage |
flops |
uniform prune to a FLOP budget | an explicit FLOP target |
<profile> |
profile-tuned pipeline | a specific device (t4, stm32-h7…) |
Provides → compression, accuracy recovery, and measurement in one call across targets like speed · size · flops.
A before/after report you can trust.
Pass report=True and the engine benchmarks the model before and after — the numbers that turn “trust me” into a table you can put in front of a stakeholder.
result = optimize(m, x, target='speed', data=dls, report=True)
print(result.full_report()) | Parameters | 11.2M → 5.5M | −51% |
| Latency (CPU) | 3.76 → 1.10 ms | 3.4× |
| Model size | 44.6 → 5.4 MiB | −88% |
| Memory (CPU) | 0.54 → 0.20 MiB | −63% |
Provides → size, latency, throughput, memory, energy & CO₂, and accuracy — before and after, in one table. Also result.plot(), .summary(), and .to_dataframe().
Target real hardware, or a hard constraint.
Optimize for a specific device profile, or state a hard floor or ceiling and let the pipeline back off compression until it respects it — then tell you whether it could.
optimize(m, x, target='nvidia-t4') # tuned to a T4's capabilities
optimize(m, x, target='stm32-h7') # MCU: gradual pruning + QAT to fit SRAM
from fasterai import Constraints
optimize(m, x, data=dls, constraints=Constraints(
min_accuracy=90, # never drop below 90%
max_size_mb=10, # must fit in 10 MB
max_latency_ms=15,
)) # result.feasible → was the target met? Provides → built-in hardware profiles for capability-aware recipe selection, plus accuracy-floor enforcement with feasibility reporting.
Compose your own pipeline.
Recipes are just pre-wired sequences of steps. When you need full control, assemble your own pipeline from the same building blocks the engine uses internally.
from fasterai import Pipeline, Analyze, Prune, Recover, Quantize
pipe = Pipeline("my-recipe", [
Analyze(compression="pruning", mode="iterative", objective="params", target_pct=40),
Prune(sparsity="auto", context="local"),
Recover(method="bn_recalib"),
Recover(method="attention_transfer"), # knowledge-distillation recovery
Quantize(scheme="W8A8"),
])
optimize(model, sample, target=pipe, data=dls)
Provides → composable steps — Analyze · Prune · Sparsify · Quantize · Recover · Train — under one runner.
Built on tools you can inspect.
The engine orchestrates two open-source libraries, both Apache 2.0 licensed. Use them directly, or let the engine drive them for you.
fasterai
Pruning, sparsity, quantization, and knowledge distillation for any PyTorch model.
This is the first week of an engagement.
The same engine runs behind our Design Partner engagements. If your team is shipping a model to real hardware and wants the method applied end-to-end, let's talk.