Skip to content

Pass the missed "non_blocking" argument for to() - #35144

Closed
xwang233 wants to merge 4 commits into
pytorch:masterfrom
xwang233:non-blocking-copy
Closed

xwang233 wants to merge 4 commits into
pytorch:masterfrom
xwang233:non-blocking-copy

Conversation

@xwang233

Copy link
Copy Markdown
Collaborator

The following code

a = torch.randn(42,) 
b = a.cuda(non_blocking=True)

will be blocked in the current master, and will not be blocked in pytorch 1.4 release. This can be verified by a nvprof --print-api-trace python script.py profiling. It is causing performance issue.

I isolated the problem, and @jjsjann123 & @ptrblck pointed out the fix. Thanks!

cc @csarofeen @ptrblck @jjsjann123 @VitalyFedyunin @ngimel

@dr-ci

dr-ci Bot commented Mar 21, 2020 •

Copy link
Copy Markdown

💊 CircleCI build failures summary and remediations

As of commit ed8a018 (more details on the Dr. CI page):


  • 5/5 failures introduced in this PR

🕵️ 1 new failure recognized by patterns

The following build failures do not appear to be due to upstream breakages:

See CircleCI build pytorch_xla_linux_xenial_py3_6_clang7_build (1/1)

Step: "Build" (full log | pattern match details) <confirmed not flaky by 2 failures>

Mar 23 17:53:17 torch_xla/csrc/aten_xla_type_default.cpp:11446:8: error: no matching member function for call to 'impl_unboxedOnlyKernel'
Mar 23 17:53:17       ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
Mar 23 17:53:17 /opt/conda/lib/python3.6/site-packages/torch/include/ATen/core/op_registration/op_registration.h:294:74: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'kernel_func' 
Mar 23 17:53:17     std::enable_if_t<guts::is_function_type<FuncType>::value, Options&&> impl_unboxedOnlyKernel(DispatchKey dispatch_key) && { 
Mar 23 17:53:17                                                                          ^ 
Mar 23 17:53:17 torch_xla/csrc/aten_xla_type_default.cpp:11185:8: error: no matching member function for call to 'impl_unboxedOnlyKernel' 
Mar 23 17:53:17       .impl_unboxedOnlyKernel<at::Tensor &(at::Tensor &, double, double, at::Generator *), &AtenXlaType::normal_>(at::DispatchKey::XLATensorId) 
Mar 23 17:53:17       ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
Mar 23 17:53:17 /opt/conda/lib/python3.6/site-packages/torch/include/ATen/core/op_registration/op_registration.h:294:74: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'kernel_func' 
Mar 23 17:53:17     std::enable_if_t<guts::is_function_type<FuncType>::value, Options&&> impl_unboxedOnlyKernel(DispatchKey dispatch_key) && { 
Mar 23 17:53:17                                                                          ^ 
Mar 23 17:53:17 torch_xla/csrc/aten_xla_type_default.cpp:11446:8: error: no matching member function for call to 'impl_unboxedOnlyKernel' 
Mar 23 17:53:17       .impl_unboxedOnlyKernel<at::Tensor(const at::Tensor &, const at::Tensor &, at::Scalar, at::Scalar, bool, at::Generator *), &AtenXlaType::rrelu_with_noise>(at::DispatchKey::XLATensorId) 
Mar 23 17:53:17       ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
Mar 23 17:53:17 /opt/conda/lib/python3.6/site-packages/torch/include/ATen/core/op_registration/op_registration.h:294:74: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'kernel_func' 
Mar 23 17:53:17     std::enable_if_t<guts::is_function_type<FuncType>::value, Options&&> impl_unboxedOnlyKernel(DispatchKey dispatch_key) && { 
Mar 23 17:53:17                                                                          ^ 
ackages/torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I/opt/conda/include/python3.6m -c torch_xla/csrc/batch_norm.cpp -o build/temp.linux-x86_64-3.6/torch_xla/csrc/batch_norm.o -std=c++14 -Wno-sign-compare -Wno-deprecated-declarations -Wno-return-type -Wno-macro-redefined -Wno-return-std-move -DNDEBUG -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_XLAC -D_GLIBCXX_USE_CXX11_ABI=1 
Mar 23 17:53:24 11 errors generated. 
torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I/opt/conda/include/python3.6m -c torch_xla/csrc/layout_manager.cpp -o build/temp.linux-x86_64-3.6/torch_xla/csrc/layout_manager.o -std=c++14 -Wno-sign-compare -Wno-deprecated-declarations -Wno-return-type -Wno-macro-redefined -Wno-return-std-move -DNDEBUG -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_XLAC -D_GLIBCXX_USE_CXX11_ABI=1 
on3.6/site-packages/torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I/opt/conda/include/python3.6m -c torch_xla/csrc/view.cpp -o build/temp.linux-x86_64-3.6/torch_xla/csrc/view.o -std=c++14 -Wno-sign-compare -Wno-deprecated-declarations -Wno-return-type -Wno-macro-redefined -Wno-return-std-move -DNDEBUG -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_XLAC -D_GLIBCXX_USE_CXX11_ABI=1 
te-packages/torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I/opt/conda/include/python3.6m -c torch_xla/csrc/nll_loss.cpp -o build/temp.linux-x86_64-3.6/torch_xla/csrc/nll_loss.o -std=c++14 -Wno-sign-compare -Wno-deprecated-declarations -Wno-return-type -Wno-macro-redefined -Wno-return-std-move -DNDEBUG -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_XLAC -D_GLIBCXX_USE_CXX11_ABI=1 

4 failures not recognized by patterns:

Job Step Status
CircleCI caffe2_onnx_main_py3_6_clang7_ubuntu16_04_build Build
CircleCI binary_linux_libtorch_2_7m_cpu_devtoolset7_shared-with-deps_build Checkout pytorch/builder repo
CircleCI binary_linux_manywheel_2_7mu_cpu_devtoolset7_build Checkout pytorch/builder repo
CircleCI caffe2_onnx_py2_gcc5_ubuntu16_04_build Build

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker.

This comment has been revised 12 times.

@VitalyFedyunin VitalyFedyunin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please add tests.

@VitalyFedyunin VitalyFedyunin added this to the 1.5.0 milestone Mar 21, 2020
@xwang233

Copy link
Copy Markdown
Collaborator Author

@VitalyFedyunin Thanks for the comment. I have added tests.

@ngimel

ngimel commented Mar 21, 2020

Copy link
Copy Markdown
Collaborator

@VitalyFedyunin @xwang233 unfortunately tests like this tend to be flaky, we already had to disable a similar one (because there's no guarantee that python interpreter will be fast enough to query the stream while the stream has work), and also unfortunately there's no robust way to write a test for this behavior, so I suggest merging this PR w/o a test.

@xwang233

Copy link
Copy Markdown
Collaborator Author

@ngimel @VitalyFedyunin Thanks for the comments. I skipped the test, and kept the test code. People can refer to the test code and test it locally.

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ngimel has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@ngimel merged this pull request in 37e3556.

xwang233 added a commit to xwang233/pytorch that referenced this pull request Mar 25, 2020
gchanan pushed a commit that referenced this pull request Mar 25, 2020
facebook-github-bot pushed a commit that referenced this pull request Oct 29, 2020
…46878)

Summary:
Fixes #39694.

[`torch.cuda._sleep(int(100 * get_cycles_per_ms()))`](https://github.com/pytorch/pytorch/pull/46878/files#diff-893b1eea27352f336f4cd832919e48d721e4e90186e63400b8596db6b82e7450R511-R513) in the test helps avoid flakiness noted by ngimel (#35144 (comment)).

Pull Request resolved: #46878

Reviewed By: izdeby

Differential Revision: D24550403

Pulled By: xw285cornell

fbshipit-source-id: 1ecc35ef75f9a38ab332aacdf4835955105edafc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants