A once-for-all network, also called an OFA network, is a large neural network trained a single time so that it contains many smaller subnetworks that work without retraining. Each subnetwork can be extracted to fit a specific device, latency target or energy budget. In edge AI, this solves a costly problem: phones, embedded boards and microcontrollers differ widely in compute power, and designing and training a separate model for each of them is slow and expensive.
The approach was introduced in 2019 by researchers at MIT and presented at ICLR 2020. Its central idea is to decouple training from architecture search. The expensive training happens once; finding a model for a new device becomes a fast search over already trained subnetworks, typically measured in minutes or hours instead of GPU weeks.
How a once-for-all network works
An OFA network is a weight-sharing supernet: smaller subnetworks reuse parts of the weights of the largest network instead of having their own. A subnetwork is defined by choosing how many layers each stage keeps, how wide each layer is, which convolution kernel size it uses and what input resolution it processes.
The original design builds on a MobileNetV3-style backbone with five stages of inverted residual blocks. Four dimensions are made elastic, which means they can be reduced at deployment time. The table shows the typical choices used in the reference implementation.
| Dimension | Typical choices | Effect when reduced |
|---|---|---|
| Elastic depth | 2, 3 or 4 blocks per stage | Fewer layers, lower latency |
| Elastic width | Expansion ratio 3, 4 or 6 | Fewer channels, fewer operations |
| Elastic kernel size | 3×3, 5×5 or 7×7 | Smaller receptive field, faster convolutions |
| Elastic resolution | Input from about 128 to 224 pixels | Fewer activations to process |
Combining these choices across all stages yields more than 10^19 possible subnetworks. Smaller subnetworks are not separate copies: a shallower stage keeps the first layers of the full stage, a narrower layer keeps the most important channels, and a smaller kernel uses the center of the larger kernel after a learned transformation.
Progressive shrinking during training
Training all subnetworks together naively causes interference: updates that help a small subnetwork can hurt a large one. OFA addresses this with progressive shrinking, a schedule that first trains the largest network and then gradually enables smaller options.
| Phase | What becomes elastic | Key technique |
|---|---|---|
| Full network training | Nothing, largest model only | Standard training with variable resolution |
| Elastic kernel | Kernel sizes 7, 5 and 3 | Kernel transformation matrices |
| Elastic depth | Number of blocks per stage | Keep first blocks, skip the rest |
| Elastic width | Channel expansion ratio | Channel sorting by importance |
Throughout these phases, the largest network acts as a teacher through knowledge distillation, and small subnetworks are sampled and fine-tuned alongside it. Channel importance sorting, based on the magnitude of weights, ensures that the channels kept by narrow subnetworks are the most useful ones.
The total training cost is substantial, often comparable to training several conventional models, but it is paid only once and then amortized across every deployment target.
Specializing a subnetwork for a device
Selecting a subnetwork for a new device is a search problem with fast evaluation. Instead of training candidates, the system estimates their quality and speed with lightweight models and then extracts the winner.
- Accuracy predictor: a small network trained on measured subnetwork accuracies predicts the accuracy of any architecture encoding.
- Latency lookup table or predictor: per-layer latencies measured on the target hardware estimate end-to-end inference time.
- Evolutionary search: candidates are mutated and recombined, keeping those with the best predicted accuracy within the latency or energy limit.
- Optional fine-tuning: the chosen subnetwork can receive a short additional training run, although it is usually accurate without it.
In the published results, OFA subnetworks reached about 80 percent top-1 accuracy on ImageNet under a budget of roughly 600 million multiply-accumulate operations, and the approach performed strongly in low-power computer vision challenges. The exact gains depend on hardware, latency target and baseline.
OFA compared with other efficiency methods
The once-for-all approach belongs to hardware-aware neural architecture search, but it differs from earlier methods in where the cost falls. The table compares it with neighboring techniques in edge AI.
| Approach | Cost per new device | Main output |
|---|---|---|
| Once-for-all network | Search only, no retraining | Specialized subnetwork from a shared supernet |
| Conventional hardware-aware NAS | Search plus full retraining | One architecture per target |
| Manual design such as MobileNet | Expert effort and training | Fixed family with width multipliers |
| Neural network pruning | Pruning plus fine-tuning | Smaller version of one trained model |
| Post-training quantization | Calibration only | Lower-precision version of a model |
These methods are complementary, not competing. A typical edge pipeline extracts an OFA subnetwork, then applies INT8 quantization and possibly pruning before converting it to an edge inference runtime. The same supernet idea later influenced MCUNet, which targets microcontrollers with very small memory.
Limitations and practical considerations
OFA networks bring significant engineering complexity. Training requires large GPU budgets and careful hyperparameters, and the design space is tied to a specific backbone family, so adapting the method to transformers or new operator types requires new elastic dimensions and new training schedules.
Latency predictions are only as good as the measurements on the real device; runtime versions, operator fusion and memory bandwidth can make predicted and actual speed diverge. Finally, a subnetwork optimized for one dataset is not automatically optimal for another task, so transfer learning may still be needed.
Put simply
A once-for-all network is like a set of nesting dolls made from one block. One big model is trained very carefully. Inside it are countless smaller models that already know their job.
When a new phone or sensor needs a model, nobody trains from scratch. Engineers simply pick the smaller model that fits the device’s speed and battery limits. This saves time, energy and money, and each device still gets a model that is sized for its hardware.
In practice
A company that makes smart security cameras sells three hardware versions: a premium model with a neural accelerator, a mid-range model with a mobile processor and a budget model with a small embedded chip. Each needs a person detector that answers within about 30 milliseconds.
Instead of designing three separate networks, the engineering team trains one OFA supernet on its labeled camera footage. For each camera version, it measures per-layer latency on the real chip, runs an evolutionary search for a few hours and extracts the best subnetwork within the latency limit. After INT8 quantization, all three models meet the target, and adding a fourth camera later requires only a new search, not a new training run.