pytorch/benchmarks
James Wu bfe9e60ffb Simplify PrecompileContext to no longer be a CacheArtifactManager (#162886)
Summary:
This diff does a big refactor of PrecompileContext to make it considerably simpler: instead of being a CacheArtifactManager and managing a bunch of bytes, it simply stores two things: dynamo cache entries and backend cache entries. When asked, it stitches them together into PrecompileCacheEntries, which are stored by DynamoCache.

This structure then allows us to register DynamoCache to the regular Megacache API, instead of having two separate APIs that are confusing. It also lets us remove the autotune cache integration, since MegaCache API will automatically store autotune cache entries.

The intent here is that users who want to use caching precompile will simply be able to use torch.compiler.save_cache_artifacts as before, just with `torch.dynamo.config.caching_precompile` set to True. They can also directly interact with PrecompileContext if they wish to specifically only load Precompile entries, using PrecompileContext.create_cache_entries().

Saving single entries and such with DynamoCache still works normally.

Test Plan:
All existing unit tests pass.

Rollback Plan:

Differential Revision: D82380307

Pull Request resolved: https://github.com/pytorch/pytorch/pull/162886
Approved by: https://github.com/zhxchen17
2025-09-20 01:24:37 +00:00
..
data Dataloader benchmark script (#159432) 2025-08-06 19:05:19 +00:00
distributed/ddp [BE] Remove outdated RPC benchmark (#146716) 2025-03-29 04:44:36 +00:00
dynamo Simplify PrecompileContext to no longer be a CacheArtifactManager (#162886) 2025-09-20 01:24:37 +00:00
fastrnns [BE] fix typos in benchmarks/ (#156077) 2025-06-17 13:12:18 +00:00
framework_overhead_benchmark Fix unused Python variables outside torch/ and test/ (#136359) 2024-12-11 17:10:23 +00:00
functional_autograd_benchmark [build] modernize build-frontend: python setup.py develop/install -> [uv ]pip install --no-build-isolation [-e ]. (#156027) 2025-07-09 11:24:27 +00:00
fuser Fix unused Python variables outside torch/ and test/ (#136359) 2024-12-11 17:10:23 +00:00
gpt_fast [BE] fix typos in benchmarks/ (#156077) 2025-06-17 13:12:18 +00:00
inductor_backends Rename inductor cache (#156128) 2025-06-17 03:57:18 +00:00
inference [BE] fix typos in benchmarks/ (#156077) 2025-06-17 13:12:18 +00:00
instruction_counts [BE] add noqa for flake8 rule B036: found except BaseException without re-raising (#159043) 2025-07-25 02:56:34 +00:00
nested Fix unused Python variables outside torch/ and test/ (#136359) 2024-12-11 17:10:23 +00:00
operator_benchmark update the baseline data for the operator benchmark (#162693) 2025-09-12 20:53:29 +00:00
overrides_benchmark
profiler_benchmark Apply TorchFix TOR203 fixes (#143691) 2024-12-23 18:21:03 +00:00
record_function_benchmark
serialization Fix unused Python variables outside torch/ and test/ (#136359) 2024-12-11 17:10:23 +00:00
sparse [build] modernize build-frontend: python setup.py develop/install -> [uv ]pip install --no-build-isolation [-e ]. (#156027) 2025-07-09 11:24:27 +00:00
static_runtime [3/N] Use internal linkage in C++ files (#151297) 2025-05-05 17:48:39 +00:00
tensorexpr [BE] fix typos in benchmarks/ (#156077) 2025-06-17 13:12:18 +00:00
transformer [BE] fix typos in benchmarks/ (#156077) 2025-06-17 13:12:18 +00:00
compare-fastrnn-results.py
compare.sh
README.md [build] modernize build-frontend: python setup.py develop/install -> [uv ]pip install --no-build-isolation [-e ]. (#156027) 2025-07-09 11:24:27 +00:00
upload_scribe.py Fix broken URLs (#152237) 2025-04-27 09:56:42 +00:00

PyTorch Benchmarks

This folder contains scripts that produce reproducible timings of various PyTorch features.

It also provides mechanisms to compare PyTorch with other frameworks.

Setup environment

Make sure you're on a machine with CUDA, torchvision, and pytorch installed. Install in the following order:

# Install torchvision. It comes with the pytorch stable release binary
python -m pip install torch torchvision

# Install the latest pytorch master from source.
# It should supersede the installation from the release binary.
cd $PYTORCH_HOME
python -m pip install --no-build-isolation -v -e .

# Check the pytorch installation version
python -c "import torch; print(torch.__version__)"

Benchmark List

Please refer to each subfolder to discover each benchmark suite. Links are provided where descriptions exist: