KEMBAR78
resolve conjugate bit in `torch.testing.assert_close` by pmeier · Pull Request #60522 · pytorch/pytorch · GitHub
Skip to content

Conversation

@pmeier
Copy link
Collaborator

@pmeier pmeier commented Jun 23, 2021

We need to resolve the conjugate bit for complex tensors, because otherwise we may not be able to access the imaginary component:

>>> torch.tensor(complex(1, 1)).conj().imag
RuntimeError: view_as_real doesn't work on unresolved conjugated tensors.  To resolve the conjugate tensor so you can view it as real, use self.resolve_conj(); however, be warned that the resulting tensor will NOT alias the original.

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jun 23, 2021

💊 CI failures summary and remediations

As of commit a7e1b72 (more details on the Dr. CI page and at hud.pytorch.org/pr/60522):


  • 5/6 failures possibly* introduced in this PR
    • 1/5 non-scanned failure(s)
  • 1/6 broken upstream at merge base 00896cb from Jun 23 until Jun 24

🕵️ 3 new failures recognized by patterns

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

See CircleCI build pytorch_python_doc_build (1/3)

Step: "Doc Build and Push" (full log | diagnosis details | 🔁 rerun)

Jun 24 09:55:09 Makefile:38: recipe for target 'html' failed
Jun 24 09:55:07 
Jun 24 09:55:07 copying static files... ... done
Jun 24 09:55:07 copying extra files... done
Jun 24 09:55:08 dumping search index in English (code: en)... done
Jun 24 09:55:08 dumping object inventory... done
Jun 24 09:55:08 build finished with problems, 2 warnings.
Jun 24 09:55:08 /var/lib/jenkins/workspace/docs/src/pytorch-sphinx-theme/pytorch_sphinx_theme/search.html:21: RemovedInSphinx30Warning: To modify script_files in the theme is deprecated. Please insert a <script> tag directly in your theme instead.
Jun 24 09:55:08   <p class="last">
Jun 24 09:55:08 /var/lib/jenkins/workspace/docs/src/pytorch-sphinx-theme/pytorch_sphinx_theme/search.html:24: RemovedInSphinx30Warning: To modify script_files in the theme is deprecated. Please insert a <script> tag directly in your theme instead.
Jun 24 09:55:08   </p>
Jun 24 09:55:09 Makefile:38: recipe for target 'html' failed
Jun 24 09:55:09 make: *** [html] Error 1
Jun 24 09:55:09 ++ code=2
Jun 24 09:55:09 ++ '[' 2 -ne 0 ']'
Jun 24 09:55:09 ++ set +x
Jun 24 09:55:09 =========================
Jun 24 09:55:09 /var/lib/jenkins/workspace/docs/source/notes/cuda.rst:270: WARNING: Definition list ends without a blank line; unexpected unindent.
Jun 24 09:55:09 /var/lib/jenkins/workspace/docs/source/notes/cuda.rst:278: WARNING: Definition list ends without a blank line; unexpected unindent.
Jun 24 09:55:09 =========================
Jun 24 09:55:09 Docs build failed. If the failure is not clear, scan back in the log
Jun 24 09:55:09 for any WARNINGS or for the line build finished with problems

See CircleCI build pytorch_linux_bionic_py3_6_clang9_noarch_test (2/3)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Jun 24 10:16:25 AssertionError: False is not tr...3578871926744181), which occurred at index (5, 5).
Jun 24 10:16:25   File "test_linalg.py", line 271, in test_linalg_lstsq
Jun 24 10:16:25     check_correctness_scipy(a, b, res, driver, rcond)
Jun 24 10:16:25   File "test_linalg.py", line 218, in check_correctness_scipy
Jun 24 10:16:25     check_correctness_ref(a, b, res, scipy_ref, driver=driver)
Jun 24 10:16:25   File "test_linalg.py", line 177, in check_correctness_ref
Jun 24 10:16:25     self.assertEqual(sol, solution_3d.select(0, i), atol=1e-5, rtol=1e-5)
Jun 24 10:16:25   File "/opt/conda/lib/python3.6/site-packages/torch/testing/_internal/common_utils.py", line 1441, in assertEqual
Jun 24 10:16:25     x, y, atol=atol, rtol=rtol, msg=msg, exact_dtype=exact_dtype, exact_device=exact_device
Jun 24 10:16:25   File "/opt/conda/lib/python3.6/site-packages/torch/testing/_internal/common_utils.py", line 1418, in assertEqual
Jun 24 10:16:25     super().assertTrue(result, msg=self._get_assert_msg(msg, debug_msg=debug_msg))
Jun 24 10:16:25 AssertionError: False is not true : Tensors failed to compare as equal!With rtol=1e-05 and atol=1e-05, found 241 element(s) (out of 256) whose difference(s) exceeded the margin of error (including 0 nan comparisons). The greatest difference was 0.6182836257459527 (0.9761708184203709 vs. 0.3578871926744181), which occurred at index (5, 5).
Jun 24 10:16:25 
Jun 24 10:16:25 ----------------------------------------------------------------------
Jun 24 10:16:25 Ran 5020 tests in 125.103s
Jun 24 10:16:25 
Jun 24 10:16:25 FAILED (failures=1, skipped=1406)
Jun 24 10:16:25 
Jun 24 10:16:25 Generating XML reports...
Jun 24 10:16:25 Generated XML report: test-reports/dist-gloo/test_linalg/TEST-TestLinalgCPU-20210624101419.xml
Jun 24 10:16:25 Generated XML report: test-reports/dist-gloo/test_linalg/TEST-TestLinalgMETA-20210624101419.xml
Jun 24 10:16:26 Traceback (most recent call last):

See GitHub Actions build Linux CI (pytorch-linux-xenial-py3.6-gcc5.4) / pytorch_python_doc_build (3/3)

Step: "Build Python Doc in Docker" (full log | diagnosis details | 🔁 rerun)

2021-06-24T09:32:01.6408391Z error: could not l...modules/third_party/zstd/config: Permission denied
2021-06-24T09:32:01.6266379Z http.https://github.com/.extraheader
2021-06-24T09:32:01.6277721Z error: could not lock config file /home/ec2-user/actions-runner/_work/pytorch/pytorch/.git/modules/third_party/tensorpipe/modules/third_party/libuv/config: Permission denied
2021-06-24T09:32:01.6290369Z Entering 'third_party/tensorpipe/third_party/pybind11'
2021-06-24T09:32:01.6308707Z http.https://github.com/.extraheader
2021-06-24T09:32:01.6319753Z error: could not lock config file /home/ec2-user/actions-runner/_work/pytorch/pytorch/.git/modules/third_party/tensorpipe/modules/third_party/pybind11/config: Permission denied
2021-06-24T09:32:01.6332506Z Entering 'third_party/tensorpipe/third_party/pybind11/tools/clang'
2021-06-24T09:32:01.6351341Z http.https://github.com/.extraheader
2021-06-24T09:32:01.6362732Z error: could not lock config file /home/ec2-user/actions-runner/_work/pytorch/pytorch/.git/modules/third_party/tensorpipe/modules/third_party/pybind11/modules/tools/clang/config: Permission denied
2021-06-24T09:32:01.6378177Z Entering 'third_party/zstd'
2021-06-24T09:32:01.6397180Z http.https://github.com/.extraheader
2021-06-24T09:32:01.6408391Z error: could not lock config file /home/ec2-user/actions-runner/_work/pytorch/pytorch/.git/modules/third_party/zstd/config: Permission denied
2021-06-24T09:32:01.6470825Z Cleaning up orphan processes


1 failure not recognized by patterns:

Job Step Action
CircleCI pytorch_doc_test Doc test 🔁 rerun

🚧 1 fixed upstream failure:

These were probably caused by upstream breakages that were already fixed.

Please rebase on the viable/strict branch (expand for instructions)

If your commit is older than viable/strict, run these commands:

git fetch https://github.com/pytorch/pytorch viable/strict
git rebase FETCH_HEAD

ci.pytorch.org: 1 failed


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 to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@pmeier pmeier added module: complex Related to complex number support in PyTorch module: testing Issues related to the torch.testing module (not tests) labels Jun 23, 2021
Copy link
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

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

Good catch, @pmeier

@anjali411 -- does this look OK to you, too?

@facebook-github-bot
Copy link
Contributor

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

# Conflicts:
#	torch/testing/_asserts.py
@anjali411
Copy link
Contributor

yup looks good! although this won't be needed after #56058 is merged!

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@mruberry merged this pull request in 44b3dc4.

@pmeier pmeier deleted the assert-close-complex-conj branch June 30, 2021 08:35
@anjali411 anjali411 mentioned this pull request Jul 8, 2021
anjali411 added a commit that referenced this pull request Jul 8, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

TODO:
follow up on #60522 (comment)

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 8, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

TODO:
follow up on #60522 (comment)

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

[ghstack-poisoned]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged module: complex Related to complex number support in PyTorch module: testing Issues related to the torch.testing module (not tests) open source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants