Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add neg bit #56058

Closed
wants to merge 48 commits into from
Closed

Add neg bit #56058

wants to merge 48 commits into from

Conversation

anjali411
Copy link
Contributor

@anjali411 anjali411 commented Apr 14, 2021

Stack from ghstack:

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 _unsafe_view returns copy if self has conjugate bit set #60478 (caused due to Conjugate View #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.

Differential Revision:

Differential Revision: D29636403

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Apr 14, 2021

💊 CI failures summary and remediations

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


  • 3/3 failures possibly* introduced in this PR
    • 1/3 non-scanned failure(s)

🕵️ 2 new failures recognized by patterns

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

See CircleCI build pytorch_linux_xenial_cuda11_1_cudnn8_py3_gcc7_build (1/2)

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

Jul 12 20:05:55 rm: cannot remove '/var/lib/jenkins/sccache_error.log': No such file or directory
Jul 12 20:05:55 ++++ extract_trap_cmd
Jul 12 20:05:55 ++++ printf '%s\n' ''
Jul 12 20:05:55 +++ printf '%s\n' cleanup
Jul 12 20:05:55 ++ trap -- '
Jul 12 20:05:55 cleanup' EXIT
Jul 12 20:05:55 ++ [[ pytorch-linux-xenial-cuda11.1-cudnn8-py3-gcc7-build != *pytorch-win-* ]]
Jul 12 20:05:55 ++ which sccache
Jul 12 20:05:55 ++ sccache --stop-server
Jul 12 20:05:55 ++ true
Jul 12 20:05:55 ++ rm /var/lib/jenkins/sccache_error.log
Jul 12 20:05:55 rm: cannot remove '/var/lib/jenkins/sccache_error.log': No such file or directory
Jul 12 20:05:55 ++ true
Jul 12 20:05:55 ++ [[ -n '' ]]
Jul 12 20:05:55 ++ [[ pytorch-linux-xenial-cuda11.1-cudnn8-py3-gcc7-build == *rocm* ]]
Jul 12 20:05:55 ++ SCCACHE_ERROR_LOG=/var/lib/jenkins/sccache_error.log
Jul 12 20:05:55 ++ SCCACHE_IDLE_TIMEOUT=1200
Jul 12 20:05:55 ++ RUST_LOG=sccache::server=error
Jul 12 20:05:55 ++ sccache --start-server
Jul 12 20:05:55 sccache: Starting the server...
Jul 12 20:05:55 ++ sccache --zero-stats
Jul 12 20:05:55 Compile requests                      0

See GitHub Actions build Windows CI (pytorch-win-vs2019-cpu-py3) / test (default, 1, 2, windows.4xlarge) (2/2)

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

2021-07-12T20:59:57.9248423Z RuntimeError: test_cpp_extensions_jit failed!
2021-07-12T20:59:57.5342135Z 
2021-07-12T20:59:57.5342453Z FAILED (errors=4, skipped=8)
2021-07-12T20:59:57.5342676Z 
2021-07-12T20:59:57.5342992Z Generating XML reports...
2021-07-12T20:59:57.5343919Z Generated XML report: test-reports\python-unittest\test_cpp_extensions_jit\TEST-TestCppExtensionJIT-20210712205750.xml
2021-07-12T20:59:57.9246021Z Traceback (most recent call last):
2021-07-12T20:59:57.9246747Z   File "run_test.py", line 1088, in <module>
2021-07-12T20:59:57.9247130Z     main()
2021-07-12T20:59:57.9247496Z   File "run_test.py", line 1067, in main
2021-07-12T20:59:57.9247929Z     raise RuntimeError(err_message)
2021-07-12T20:59:57.9248423Z RuntimeError: test_cpp_extensions_jit failed!
2021-07-12T20:59:58.1242737Z 
2021-07-12T20:59:58.1243503Z (base) C:\actions-runner\_work\pytorch\pytorch\test>if ERRORLEVEL 1 exit /b 1 
2021-07-12T20:59:58.1268208Z + cleanup
2021-07-12T20:59:58.1268532Z + retcode=1
2021-07-12T20:59:58.1268790Z + set +x
2021-07-12T20:59:58.1300535Z ##[error]Process completed with exit code 1.
2021-07-12T20:59:58.1577841Z ##[group]Run # -ir => recursive include all files in pattern
2021-07-12T20:59:58.1578484Z �[36;1m# -ir => recursive include all files in pattern�[0m
2021-07-12T20:59:58.1579021Z �[36;1m7z a "test-reports-$Env:TEST_CONFIG.zip" -ir'!test\*.xml'�[0m
2021-07-12T20:59:58.1603823Z shell: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.EXE -command ". '{0}'"

1 job timed out:

  • pytorch_linux_xenial_cuda11_1_cudnn8_py3_gcc7_build

Preview docs built from this PR

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.

anjali411 added a commit that referenced this pull request Apr 14, 2021
ghstack-source-id: 113de6e3ce6534aa134da5ab61cc095e72bc804f
Pull Request resolved: #56058
anjali411 added a commit that referenced this pull request Apr 19, 2021
ghstack-source-id: d778447171e67dbac31a3a233452a4ef2fd9361e
Pull Request resolved: #56058
anjali411 added a commit that referenced this pull request Apr 22, 2021
ghstack-source-id: 9a8ccf2c1a7a675853e0edaa2fa0c6c77fc03231
Pull Request resolved: #56058
anjali411 added a commit that referenced this pull request Apr 22, 2021
ghstack-source-id: 6514659a16e66a9baa55f7a03e5c0a901e252f2d
Pull Request resolved: #56058
anjali411 added a commit that referenced this pull request Apr 23, 2021
ghstack-source-id: 005f9e256a574f32eadb2b465962e9395a58745f
Pull Request resolved: #56058
@anjali411 anjali411 changed the title Make negative operation a view Add neg bit Apr 23, 2021
[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 26, 2021
ghstack-source-id: 893a1949f88a4d23cbbbedae26ecc10c3d926a56
Pull Request resolved: #56058
[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 26, 2021
ghstack-source-id: 4551a588df0f7de5e2bce8e7e3e79c0fc48812a2
Pull Request resolved: #56058
[ghstack-poisoned]
[ghstack-poisoned]
TODO: 
1. remove view_as_real_physical
2. reuse ConjugateFallback code

bc breaking: sparse_tensor.conj().imag doesn't work anymore.
Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

[ghstack-poisoned]
@anjali411 anjali411 added module: complex Related to complex number support in PyTorch and removed module: bc-breaking Related to a BC-breaking change labels Jun 24, 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]
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`. 

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

[ghstack-poisoned]
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`. 

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

[ghstack-poisoned]
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`. 

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

[ghstack-poisoned]
@anjali411
Copy link
Contributor Author

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

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`. 

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

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

[ghstack-poisoned]
@anjali411
Copy link
Contributor Author

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

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`. 

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

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

[ghstack-poisoned]
@anjali411
Copy link
Contributor Author

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

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`. 

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

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

[ghstack-poisoned]
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`. 

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

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

[ghstack-poisoned]
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`. 

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

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

[ghstack-poisoned]
@@ -233,10 +233,15 @@ def _tensor_str(self, indent):
self = self.rename(None)

summarize = self.numel() > PRINT_OPTS.threshold

# handle the negative bit
self = self.resolve_neg()
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's this.

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`. 

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

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

[ghstack-poisoned]
@anjali411
Copy link
Contributor Author

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

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`. 

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

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

[ghstack-poisoned]
@anjali411
Copy link
Contributor Author

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

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 30e48bb.

@facebook-github-bot facebook-github-bot deleted the gh/anjali411/122/head branch July 17, 2021 14:17
QYP-842653 pushed a commit to QYP-842653/Pytorch that referenced this pull request Jul 27, 2021
ghstack-source-id: 17da0267e28fc58810d439cae643fe4e6de2024d
Pull Request resolved: pytorch/pytorch#56058
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants