This is one of a series of PRs to update us to PEP585 (changing Dict -> dict, List -> list, etc). Most of the PRs were completely automated with RUFF as follows:
Since RUFF UP006 is considered an "unsafe" fix first we need to enable unsafe fixes:
```
--- a/tools/linter/adapters/ruff_linter.py
+++ b/tools/linter/adapters/ruff_linter.py
@@ -313,6 +313,7 @@
"ruff",
"check",
"--fix-only",
+ "--unsafe-fixes",
"--exit-zero",
*([f"--config={config}"] if config else []),
"--stdin-filename",
```
Then we need to tell RUFF to allow UP006 (as a final PR once all of these have landed this will be made permanent):
```
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -40,7 +40,7 @@
[tool.ruff]
-target-version = "py38"
+target-version = "py39"
line-length = 88
src = ["caffe2", "torch", "torchgen", "functorch", "test"]
@@ -87,7 +87,6 @@
"SIM116", # Disable Use a dictionary instead of consecutive `if` statements
"SIM117",
"SIM118",
- "UP006", # keep-runtime-typing
"UP007", # keep-runtime-typing
]
select = [
```
Finally running `lintrunner -a --take RUFF` will fix up the deprecated uses.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/145101
Approved by: https://github.com/bobrenjc93
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| bench.py | ||
| cells.py | ||
| conftest.py | ||
| custom_lstms.py | ||
| factory.py | ||
| fuser.py | ||
| profile.py | ||
| README.md | ||
| runner.py | ||
| scratch.py | ||
| test.py | ||
| test_bench.py | ||
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 shieldwhen 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.