How facebookresearch/levit works
LeViT is a PyTorch image-classification project providing model variants and pretrained weights, plus ImageNet-style training and evaluation. The principal workflow starts at main.py: it builds and transforms datasets, creates a LeViT model and training configuration, then delegates epochs or evaluation to engine.py, which computes losses and metrics. Distillation adds teacher predictions to training supervision; distributed helpers support multi-process runs. README documents several dataset/model and single-node/multinode capabilities. Some main-program wiring is unsampled, so uncertain links are omitted.
Main entry points: main.py Train/eval entry · engine.py Epoch/eval engine · run_with_submitit.py Multinode launcher · hubconf.py Hub model exports
Components 16
Run orchestration
- Train/eval entry
main.py - Multinode launcher
run_with_submitit.py
Image data
- Dataset builders
datasets.py - Repeated sampler
samplers.py
LeViT models
- LeViT variants
levit.py - Conv LeViT
levit_c.py - Hub model exports
hubconf.py
Training and evaluation
- Epoch/eval engine
engine.py - Distillation loss
losses.py - Metrics and logs
utils.py
Distributed runtime
- Distributed helpers
utils.py
Other components
- CLI user
- Image datasets
- Slurm/Submitit
- Model checkpoints
- Teacher model
Connections 18
- CLI user → Train/eval entry: starts run
- CLI user → Multinode launcher: submits run
- Multinode launcher → Slurm/Submitit: submits job
- Multinode launcher → Train/eval entry: invokes
- Train/eval entry → Dataset builders: builds data
- Dataset builders → Image datasets: loads images
- Train/eval entry → Repeated sampler: samples data
- Train/eval entry → LeViT variants: creates model
- Train/eval entry → Conv LeViT: selects variant
- Hub model exports → LeViT variants: exports models
- Hub model exports → Conv LeViT: exports models
- Train/eval entry → Epoch/eval engine: runs epochs
- Epoch/eval engine → Distillation loss: computes loss
- Distillation loss → Teacher model: gets predictions
- Train/eval entry → Model checkpoints: loads/saves
- Epoch/eval engine → Metrics and logs: logs metrics
- Train/eval entry → Distributed helpers: initializes
- Epoch/eval engine → Distributed helpers: synchronizes