2021-01-26 17:01:03 +00:00
|
|
|
# This is the PyTorch mypy-strict.ini file (note: don't change this line! -
|
|
|
|
|
# test_run_mypy in test/test_type_hints.py uses this string)
|
|
|
|
|
|
|
|
|
|
# Unlike mypy.ini, it enforces very strict typing rules. The intention is for
|
|
|
|
|
# this config file to be used to ENFORCE that people are using mypy on codegen
|
|
|
|
|
# files.
|
|
|
|
|
|
More Timer refinement (#46023)
Summary:
This PR just adds more polish to the benchmark utils:
1) `common.py`, `timer.py`, and `valgrind_wrapper/timer_interface.py` are now MyPy strict compliant. (except for three violations due to external deps.) Compare and Fuzzer will be covered in a future PR.
2) `CallgrindStats` now uses `TaskSpec` rather than accepting the individual fields which brings it closer to `Measurement`.
3) Some `__repr__` logic has been moved into `TaskSpec` (which `Measurement` and `CallgrindStats` use in their own `__repr__`s) for a more unified feel and less horrible f-string hacking, and the repr's have been given a cleanup pass.
4) `Tuple[FunctionCount, ...]` has been formalized as the `FunctionCounts` class, which has a much nicer `__repr__` than just the raw tuple, as well as some convenience methods (`__add__`, `__sub__`, `filter`, `transform`) for easier DIY stat exploration. (I find myself using the latter two a lot now.) My personal experience is that manipulating `FunctionCounts` is massively more pleasant than the raw tuples of `FunctionCount`. (Though it's still possible to get at the raw data if you want.)
5) Better support for multi-line `stmt` and `setup`.
6) Compare now also supports rowwise coloring, which is often the more natural layout for A/B testing.
7) Limited support for `globals` in `collect_callgrind`. This should make it easier to benchmark JIT models. (CC ZolotukhinM)
8) More unit tests, including extensive tests for the Callgrind stats manipulation APIs.
9) Mitigate issue with `MKL_THREADING_LAYER` when run in Jupyter. (https://github.com/pytorch/pytorch/issues/37377)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/46023
Test Plan: changes should be covered by existing and new unit tests.
Reviewed By: navahgar, malfet
Differential Revision: D24313911
Pulled By: robieta
fbshipit-source-id: 835d4b5cde336fb7ff0adef3c0fd614d64df0f77
2020-10-15 23:30:49 +00:00
|
|
|
# For now, only code_template.py and benchmark utils Timer are covered this way
|
2020-08-05 19:25:10 +00:00
|
|
|
|
|
|
|
|
[mypy]
|
|
|
|
|
python_version = 3.6
|
2021-02-08 23:34:53 +00:00
|
|
|
plugins = mypy_plugins/check_mypy_version.py
|
2020-08-05 19:25:10 +00:00
|
|
|
|
2021-01-19 18:03:04 +00:00
|
|
|
cache_dir = .mypy_cache/strict
|
2020-08-05 19:25:10 +00:00
|
|
|
strict_optional = True
|
|
|
|
|
show_column_numbers = True
|
|
|
|
|
warn_no_return = True
|
|
|
|
|
disallow_any_unimported = True
|
|
|
|
|
|
|
|
|
|
# Across versions of mypy, the flags toggled by --strict vary. To ensure
|
|
|
|
|
# we have reproducible type check, we instead manually specify the flags
|
|
|
|
|
warn_unused_configs = True
|
|
|
|
|
disallow_any_generics = True
|
|
|
|
|
disallow_subclassing_any = True
|
|
|
|
|
disallow_untyped_calls = True
|
|
|
|
|
disallow_untyped_defs = True
|
|
|
|
|
disallow_incomplete_defs = True
|
|
|
|
|
check_untyped_defs = True
|
|
|
|
|
disallow_untyped_decorators = True
|
|
|
|
|
no_implicit_optional = True
|
|
|
|
|
warn_redundant_casts = True
|
|
|
|
|
warn_unused_ignores = True
|
|
|
|
|
warn_return_any = True
|
|
|
|
|
implicit_reexport = False
|
|
|
|
|
strict_equality = True
|
|
|
|
|
|
2021-03-17 19:30:21 +00:00
|
|
|
files =
|
2021-01-19 07:51:50 +00:00
|
|
|
tools/autograd/*.py,
|
2021-03-17 19:30:21 +00:00
|
|
|
tools/codegen/gen.py,
|
|
|
|
|
tools/print_test_stats.py,
|
2021-01-19 07:51:50 +00:00
|
|
|
tools/pyi/*.py,
|
2021-03-17 19:30:21 +00:00
|
|
|
tools/stats_utils/*.py,
|
2021-02-11 21:11:32 +00:00
|
|
|
tools/test_history.py,
|
2021-03-15 23:31:47 +00:00
|
|
|
torch/testing/_internal/framework_utils.py,
|
2021-01-26 17:01:03 +00:00
|
|
|
torch/testing/_internal/mypy_wrapper.py,
|
More Timer refinement (#46023)
Summary:
This PR just adds more polish to the benchmark utils:
1) `common.py`, `timer.py`, and `valgrind_wrapper/timer_interface.py` are now MyPy strict compliant. (except for three violations due to external deps.) Compare and Fuzzer will be covered in a future PR.
2) `CallgrindStats` now uses `TaskSpec` rather than accepting the individual fields which brings it closer to `Measurement`.
3) Some `__repr__` logic has been moved into `TaskSpec` (which `Measurement` and `CallgrindStats` use in their own `__repr__`s) for a more unified feel and less horrible f-string hacking, and the repr's have been given a cleanup pass.
4) `Tuple[FunctionCount, ...]` has been formalized as the `FunctionCounts` class, which has a much nicer `__repr__` than just the raw tuple, as well as some convenience methods (`__add__`, `__sub__`, `filter`, `transform`) for easier DIY stat exploration. (I find myself using the latter two a lot now.) My personal experience is that manipulating `FunctionCounts` is massively more pleasant than the raw tuples of `FunctionCount`. (Though it's still possible to get at the raw data if you want.)
5) Better support for multi-line `stmt` and `setup`.
6) Compare now also supports rowwise coloring, which is often the more natural layout for A/B testing.
7) Limited support for `globals` in `collect_callgrind`. This should make it easier to benchmark JIT models. (CC ZolotukhinM)
8) More unit tests, including extensive tests for the Callgrind stats manipulation APIs.
9) Mitigate issue with `MKL_THREADING_LAYER` when run in Jupyter. (https://github.com/pytorch/pytorch/issues/37377)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/46023
Test Plan: changes should be covered by existing and new unit tests.
Reviewed By: navahgar, malfet
Differential Revision: D24313911
Pulled By: robieta
fbshipit-source-id: 835d4b5cde336fb7ff0adef3c0fd614d64df0f77
2020-10-15 23:30:49 +00:00
|
|
|
torch/utils/benchmark/utils/common.py,
|
|
|
|
|
torch/utils/benchmark/utils/timer.py,
|
Add utilities to support handling of nested python data structures (#46287)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/46287
This adds a lightweight `pytree` implementation that is similar to and
inspired by JAX pytrees, tensorflow.nest, deepmind/tree,
TorchBeast's TensorNest, etc.
A *pytree* is Python nested data structure. It is a tree in the sense
that nodes are Python collections (e.g., list, tuple, dict) and the leaves
are Python values. Furthermore, a pytree should not contain reference
cycles.
This PR:
- adds support for flattening and unflattening nested Python list/dict/tuples
Context: nested Tensor inputs for vmap
--------------------------------------
Right now, vmap is restricted to taking in flat lists of tensors. This
is because vmap needs to be able to convert every tensor in the input
that is being vmapped over into a BatchedTensor.
With a pytree library, we can simply flatten the input data structure
(returning the leaves), map all of the Tensors in the flat input to
BatchedTensors, and unflatten the flat list of BatchedTensors into a new
input. Or equivalently, with a `tree_map` function, we can map a nested
python data structure containing Tensors into one containing
BatchedTensors.
Future work
-----------
In some future PRs, we'll add nested input support for vmap. The
prerequisites for that are:
- a `broadcast_to(small, big)` that broadcasts `small` up to `big`.
This is for handling the in_dims to vmap: the in_dims structure must
be compatible with the structure of the inputs.
Test Plan
---------
- New tests in test/test_pytree.py
Test Plan: Imported from OSS
Reviewed By: heitorschueroff
Differential Revision: D24392890
Pulled By: zou3519
fbshipit-source-id: 7daf7430c5a38354e7d203a72882bd7a9b24cfb1
2020-10-20 14:42:20 +00:00
|
|
|
torch/utils/benchmark/utils/valgrind_wrapper/*.py,
|
|
|
|
|
torch/utils/_pytree.py
|
More Timer refinement (#46023)
Summary:
This PR just adds more polish to the benchmark utils:
1) `common.py`, `timer.py`, and `valgrind_wrapper/timer_interface.py` are now MyPy strict compliant. (except for three violations due to external deps.) Compare and Fuzzer will be covered in a future PR.
2) `CallgrindStats` now uses `TaskSpec` rather than accepting the individual fields which brings it closer to `Measurement`.
3) Some `__repr__` logic has been moved into `TaskSpec` (which `Measurement` and `CallgrindStats` use in their own `__repr__`s) for a more unified feel and less horrible f-string hacking, and the repr's have been given a cleanup pass.
4) `Tuple[FunctionCount, ...]` has been formalized as the `FunctionCounts` class, which has a much nicer `__repr__` than just the raw tuple, as well as some convenience methods (`__add__`, `__sub__`, `filter`, `transform`) for easier DIY stat exploration. (I find myself using the latter two a lot now.) My personal experience is that manipulating `FunctionCounts` is massively more pleasant than the raw tuples of `FunctionCount`. (Though it's still possible to get at the raw data if you want.)
5) Better support for multi-line `stmt` and `setup`.
6) Compare now also supports rowwise coloring, which is often the more natural layout for A/B testing.
7) Limited support for `globals` in `collect_callgrind`. This should make it easier to benchmark JIT models. (CC ZolotukhinM)
8) More unit tests, including extensive tests for the Callgrind stats manipulation APIs.
9) Mitigate issue with `MKL_THREADING_LAYER` when run in Jupyter. (https://github.com/pytorch/pytorch/issues/37377)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/46023
Test Plan: changes should be covered by existing and new unit tests.
Reviewed By: navahgar, malfet
Differential Revision: D24313911
Pulled By: robieta
fbshipit-source-id: 835d4b5cde336fb7ff0adef3c0fd614d64df0f77
2020-10-15 23:30:49 +00:00
|
|
|
|
|
|
|
|
# Specifically enable imports of benchmark utils. As more of `torch` becomes
|
|
|
|
|
# strict compliant, those modules can be enabled as well.
|
|
|
|
|
[mypy-torch.utils.benchmark.utils.*]
|
|
|
|
|
follow_imports = normal
|
|
|
|
|
|
|
|
|
|
# Don't follow imports as much of `torch` is not strict compliant.
|
|
|
|
|
[mypy-torch]
|
|
|
|
|
follow_imports = skip
|
|
|
|
|
|
|
|
|
|
[mypy-torch.*]
|
|
|
|
|
follow_imports = skip
|
|
|
|
|
|
2021-01-26 17:01:03 +00:00
|
|
|
# Missing stubs.
|
|
|
|
|
|
More Timer refinement (#46023)
Summary:
This PR just adds more polish to the benchmark utils:
1) `common.py`, `timer.py`, and `valgrind_wrapper/timer_interface.py` are now MyPy strict compliant. (except for three violations due to external deps.) Compare and Fuzzer will be covered in a future PR.
2) `CallgrindStats` now uses `TaskSpec` rather than accepting the individual fields which brings it closer to `Measurement`.
3) Some `__repr__` logic has been moved into `TaskSpec` (which `Measurement` and `CallgrindStats` use in their own `__repr__`s) for a more unified feel and less horrible f-string hacking, and the repr's have been given a cleanup pass.
4) `Tuple[FunctionCount, ...]` has been formalized as the `FunctionCounts` class, which has a much nicer `__repr__` than just the raw tuple, as well as some convenience methods (`__add__`, `__sub__`, `filter`, `transform`) for easier DIY stat exploration. (I find myself using the latter two a lot now.) My personal experience is that manipulating `FunctionCounts` is massively more pleasant than the raw tuples of `FunctionCount`. (Though it's still possible to get at the raw data if you want.)
5) Better support for multi-line `stmt` and `setup`.
6) Compare now also supports rowwise coloring, which is often the more natural layout for A/B testing.
7) Limited support for `globals` in `collect_callgrind`. This should make it easier to benchmark JIT models. (CC ZolotukhinM)
8) More unit tests, including extensive tests for the Callgrind stats manipulation APIs.
9) Mitigate issue with `MKL_THREADING_LAYER` when run in Jupyter. (https://github.com/pytorch/pytorch/issues/37377)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/46023
Test Plan: changes should be covered by existing and new unit tests.
Reviewed By: navahgar, malfet
Differential Revision: D24313911
Pulled By: robieta
fbshipit-source-id: 835d4b5cde336fb7ff0adef3c0fd614d64df0f77
2020-10-15 23:30:49 +00:00
|
|
|
[mypy-numpy]
|
|
|
|
|
ignore_missing_imports = True
|
2021-01-26 17:01:03 +00:00
|
|
|
|
|
|
|
|
[mypy-mypy.*]
|
|
|
|
|
ignore_missing_imports = True
|