pytorch/benchmarks/fastrnns
Yuanyuan Chen 0e083942cc Enable PLW0127 in ruff (#165851)
This PR enables `PLW0127` in ruff, which checks self-assignment of variables with the form `var=var`.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/165851
Approved by: https://github.com/Lucaskabela
2025-10-21 03:30:57 +00:00
..
__init__.py [BE][Easy][3/19] enforce style for empty lines in import segments in benchmarks/ (#129754) 2024-07-17 14:34:42 +00:00
bench.py Enable PLW0127 in ruff (#165851) 2025-10-21 03:30:57 +00:00
cells.py Migrate from Tuple -> tuple in benchmarks (#144259) 2025-01-07 04:09:52 +00:00
conftest.py [BE][Easy][3/19] enforce style for empty lines in import segments in benchmarks/ (#129754) 2024-07-17 14:34:42 +00:00
custom_lstms.py [BE]: Enable ruff rule SIM113 (#147290) 2025-02-16 22:41:16 +00:00
factory.py [BE] fix typos in benchmarks/ (#156077) 2025-06-17 13:12:18 +00:00
fuser.py Apply UFMT to all files in benchmarks/ (#105928) 2023-07-26 01:18:48 +00:00
profile.py Apply UFMT to all files in benchmarks/ (#105928) 2023-07-26 01:18:48 +00:00
README.md Lint trailing newlines (#54737) 2021-03-30 13:09:52 -07:00
runner.py [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
scratch.py [BE][Easy][3/19] enforce style for empty lines in import segments in benchmarks/ (#129754) 2024-07-17 14:34:42 +00:00
test_bench.py Enable PLW0127 in ruff (#165851) 2025-10-21 03:30:57 +00:00
test.py [BE] fix typos in benchmarks/ (#156077) 2025-06-17 13:12:18 +00:00

Fast RNN benchmarks

Benchmarks for TorchScript models

For most stable results, do the following:

  • Set CPU Governor to performance mode (as opposed to energy save)
  • Turn off turbo for all CPUs (assuming Intel CPUs)
  • Shield cpus via cset shield when running benchmarks.

Some of these scripts accept command line args but most of them do not because I was lazy. They will probably be added sometime in the future, but the default sizes are pretty reasonable.

Test fastrnns (fwd + bwd) correctness

Test the fastrnns benchmarking scripts with the following: python -m fastrnns.test or run the test independently: python -m fastrnns.test --rnns jit

Run benchmarks

python -m fastrnns.bench

should give a good comparison, or you can specify the type of model to run

python -m fastrnns.bench --rnns cudnn aten jit --group rnns

Run model profiling, calls nvprof

python -m fastrnns.profile

should generate nvprof file for all models somewhere. you can also specify the models to generate nvprof files separately:

python -m fastrnns.profile --rnns aten jit

Caveats

Use Linux for the most accurate timing. A lot of these tests only run on CUDA.