Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
README.md | H A D | 25-Apr-2025 | 2.5 KiB | 68 | 49 | |
audio_text_models.py | H A D | 25-Apr-2025 | 4.9 KiB | 158 | 114 | |
compare.py | H A D | 25-Apr-2025 | 2.1 KiB | 76 | 65 | |
functional_autograd_benchmark.py | H A D | 25-Apr-2025 | 10.4 KiB | 343 | 264 | |
ppl_models.py | H A D | 25-Apr-2025 | 3.4 KiB | 104 | 64 | |
torchaudio_models.py | H A D | 25-Apr-2025 | 25.8 KiB | 699 | 611 | |
torchvision_models.py | H A D | 25-Apr-2025 | 34.2 KiB | 958 | 733 | |
utils.py | H A D | 25-Apr-2025 | 4 KiB | 119 | 81 | |
vision_models.py | H A D | 25-Apr-2025 | 4 KiB | 141 | 104 |
README.md
1# Benchmarking tool for the autograd API 2 3This folder contain a set of self-contained scripts that allows you to benchmark autograd with different common models. 4It is designed to run the benchmark before and after your change and will generate a table to share on the PR. 5 6To do so, you can use `functional_autograd_benchmark.py` to run the benchmarks before your change (using as output `before.txt`) and after your change (using as output `after.txt`). 7You can then use `compare.py` to get a markdown table comparing the two runs. 8 9The default arguments of `functional_autograd_benchmark.py` should be used in general. You can change them though to force a given device or force running even the (very) slow settings. 10 11### Sample usage 12 13```bash 14# Make sure you compile pytorch in release mode and with the same flags before/after 15export DEBUG=0 16# When running on CPU, it might be required to limit the number of cores to avoid oversubscription 17export OMP_NUM_THREADS=10 18 19# Compile pytorch with the base revision 20git checkout master 21python setup.py develop 22 23# Install dependencies: 24# Scipy is required by detr 25pip install scipy 26 27# Run the benchmark for the base 28# This will use the GPU if available. 29pushd benchmarks/functional_autograd_benchmark 30python functional_autograd_benchmark.py --output before.txt 31 32# Compile pytorch with your change 33popd 34git checkout your_feature_branch 35python setup.py develop 36 37# Run the benchmark for the new version 38pushd benchmarks/functional_autograd_benchmark 39python functional_autograd_benchmark.py --output after.txt 40 41# Get the markdown table that you can paste in your github PR 42python compare.py 43 44popd 45 46``` 47 48### Files in this folder: 49- `functional_autograd_benchmark.py` is the main entry point to run the benchmark. 50- `compare.py` is the entry point to run the comparison script that generates a markdown table. 51- `torchaudio_models.py` and `torchvision_models.py` contains code extracted from torchaudio and torchvision to be able to run the models without having a specific version of these libraries installed. 52- `ppl_models.py`, `vision_models.py` and `audio_text_models.py` contain all the getter functions used for the benchmark. 53 54 55### Benchmarking against `functorch` 56 57```bash 58# Install stable functorch: 59pip install functorch 60# or install from source: 61pip install git+https://github.com/pytorch/functorch 62 63# Run the benchmark for the base 64# This will use the GPU if available. 65pushd benchmarks/functional_autograd_benchmark 66python functional_autograd_benchmark.py --output bench-with-functorch.txt 67``` 68