Replace async with non_blocking for Python 3.7#4999
Conversation
|
One question for the BC police: should we employ the following idiom to make legacy use of EDIT: Actually, we should probably also check that async is the only member of kwargs, to guard against mispellings. |
|
Thanks for undoing the C++ changes! The rest looks good. |
|
Good point, I will add those compatibility fixes. |
|
There's some trouble with CUDA tests, I am investigating. |
|
@ezyang I had to rename
I also don't know if some of the C++ code gets wrapped and exposed but just isn't called in the tests. Code also might get wrapped in the future, so I believe using |
| HANDLE_TH_ERRORS | ||
| static PythonArgParser parser({ | ||
| "copy_(Tensor other, bool async=False)" | ||
| "copy_(Tensor other, bool non_blocking=False)" |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/_utils.py
Outdated
| """ | ||
| if kwargs: | ||
| if len(kwargs) != 1 or 'async' not in kwargs: | ||
| raise ValueError("kwargs may only contain the key 'async'") |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
I believe onnx-fb-universe tests are currently broken, so @ezyang if you are happy, let's merge it (assuming other tests will not fail) |
Flake8 will produce different results on Python 2 and 3. Python 3.7 has __async__ as a reserved word pytorch#4999.
Summary: Flake8 will produce different results on Python 2 and 3. Python 3.7 has __async__ as a reserved word pytorch#4999. Pull Request resolved: pytorch#9953 Differential Revision: D9035415 Pulled By: soumith fbshipit-source-id: 8a46e028a2e20a7e3f6d90137020268d65a7cc64
Summary: Flake8 will produce different results on Python 2 and 3. Python 3.7 has __async__ as a reserved word pytorch#4999. Pull Request resolved: pytorch#9953 Differential Revision: D9035415 Pulled By: soumith fbshipit-source-id: 8a46e028a2e20a7e3f6d90137020268d65a7cc64
Fixes catalyst-team#3 The Dockerfiles are pip installing PyTorch=0.41 so this change is appropriate to match with pytorch/pytorch#4999
Modify the docs to match the changes made in pytorch#4999
__async__ is now a reserved word in Python 3.7 and later. To fix this pytorch/pytorch#4999 changed __cuda(async)__ to __cuda(non_blocking)__ so this PR tracks with that change. That fix landed in PyTourch 0.4.1.
Fixes CSAILVision#125 __async__ is a reserved word in Python 3.7 and later. To fix this pytorch/pytorch#4999 changed __cuda(async=True)__ to __cuda(non_blocking=True)__ so this PR tracks with that change which landed in PyTourch 0.4.1.
Fixes a __syntax error__ when running on Python >= 3.7 in alignment with pytorch/pytorch#4999 [flake8](http://flake8.pycqa.org) testing of https://github.com/ialhashim/DenseDepth on Python 3.7.1 $ __flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics__ ``` ./PyTorch/train.py:58:78: E999 SyntaxError: invalid syntax depth = torch.autograd.Variable(sample_batched['depth'].cuda(async=True)) ^ 1 E999 SyntaxError: invalid syntax 1 ``` __E901,E999,F821,F822,F823__ are the "_showstopper_" [flake8](http://flake8.pycqa.org) issues that can halt the runtime with a SyntaxError, NameError, etc. These 5 are different from most other flake8 issues which are merely "style violations" -- useful for readability but they do not effect runtime safety. * F821: undefined name `name` * F822: undefined name `name` in `__all__` * F823: local variable name referenced before assignment * E901: SyntaxError or IndentationError * E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree
__async__ is now a reserved word in Python 3.7 and later. To fix this pytorch/pytorch#4999 changed __cuda(async=True)__ to __cuda(non_blocking=True)__ so this PR tracks with that change. That fix landed in PyTourch 0.4.1.
__async__ is a reserved word in Python 3.7 and later. To fix this pytorch/pytorch#4999 changed __cuda(async=True)__ to __cuda(non_blocking=True)__ so this PR tracks with that change. That fix landed in PyTourch 0.4.1.
Using __async__ in this way is a Syntax Error in Python >= 3.7. This change tracks with the changes made in pytorch/pytorch#4999
Fixes CSAILVision#125 __async__ is a reserved word in Python 3.7 and later. To fix this pytorch/pytorch#4999 changed __cuda(async=True)__ to __cuda(non_blocking=True)__ so this PR tracks with that change which landed in PyTourch 0.4.1.
Fixes a __syntax error__ when running on Python >= 3.7 in alignment with pytorch/pytorch#4999 [flake8](http://flake8.pycqa.org) testing of https://github.com/ialhashim/DenseDepth on Python 3.7.1 $ __flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics__ ``` ./PyTorch/train.py:58:78: E999 SyntaxError: invalid syntax depth = torch.autograd.Variable(sample_batched['depth'].cuda(async=True)) ^ 1 E999 SyntaxError: invalid syntax 1 ``` __E901,E999,F821,F822,F823__ are the "_showstopper_" [flake8](http://flake8.pycqa.org) issues that can halt the runtime with a SyntaxError, NameError, etc. These 5 are different from most other flake8 issues which are merely "style violations" -- useful for readability but they do not effect runtime safety. * F821: undefined name `name` * F822: undefined name `name` in `__all__` * F823: local variable name referenced before assignment * E901: SyntaxError or IndentationError * E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree
Since
asyncwill become a keyword in Python 3.7, I replaced all occurences of the wordasyncwithnon_blockingin our Python files. Proof:copy_wrapper.pygenerates C++ code, so theasyncwill not be a problem. I also did not modify mentions ofasyncin any other C++ files.@ezyang @colesbury
Fixes #3431