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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support complex torch.solve on the GPU #41084

Closed
boeddeker opened this issue Jul 7, 2020 · 3 comments
Closed

Support complex torch.solve on the GPU #41084

boeddeker opened this issue Jul 7, 2020 · 3 comments
Assignees
Labels
feature A request for a proper, new feature. module: complex Related to complex number support in PyTorch triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@boeddeker
Copy link
Contributor

boeddeker commented Jul 7, 2020

馃殌 Feature

Support torch.solve on the GPU

Motivation

In pytorch/audio#768 I asked about the complex support in torch for some linear algebra functions and
@anjali411 said, I should post here my feature request.

Pitch

It would be nice, when the following code would not fail in the last line:

>>> import numpy as np, torch
>>> torch.__version__
'1.7.0.dev20200705+cu101'
>>> t = torch.tensor(np.random.randn(2, 2))
>>> _ = torch.solve(t, t)
>>> _ = torch.solve(t.to(0), t.to(0))
>>> t = torch.tensor(1j * np.random.randn(2, 2))
>>> _ = torch.solve(t, t)
>>> _ = torch.solve(t.to(0), t.to(0))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: "solve_cuda" not implemented for 'ComplexDouble'

Alternatives

Currently, I am using
https://github.com/kamo-naoyuki/pytorch_complex/tree/master/torch_complex
but a native support would be faster, consume less memory and the code would contain fewer hacks to distinguish real and complex tensors.

Additional context

cc @ezyang @anjali411 @dylanbespalko

@anjali411 anjali411 added the module: complex Related to complex number support in PyTorch label Jul 7, 2020
@mruberry mruberry added feature A request for a proper, new feature. triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Jul 7, 2020
@mruberry mruberry changed the title Support torch.solve on the GPU Support complex torch.solve on the GPU Jul 7, 2020
@mruberry
Copy link
Collaborator

mruberry commented Jul 7, 2020

Thanks for the suggestion, @boeddeker! I updated the title to clarify the request is for complex solve.

@anjali411
Copy link
Contributor

@boeddeker Thanks for creating the issue! I agree that it would be super useful to have torch.solve supported for complex so that we won't need the hacks anymore. I or someone else will work on adding this once torch.matmul is supported for complex numbers (since it's used in the backwards).

@boeddeker
Copy link
Contributor Author

Thanks, that would be great

@anjali411 anjali411 self-assigned this Aug 11, 2020
tugsbayasgalan pushed a commit to tugsbayasgalan/pytorch that referenced this issue Nov 16, 2020
Summary:
`torch.solve` now works for complex inputs on GPU.
I moved the existing tests to `test_linalg.py` and modified them to test complex and float32 dtypes.
Differentiation also works correctly with complex inputs.

Fixes pytorch#41084
Ref. pytorch#33152

anjali411 I hope you don't mind that I took over pytorch#42737

Pull Request resolved: pytorch#47045

Reviewed By: nikithamalgifb

Differential Revision: D24921503

Pulled By: anjali411

fbshipit-source-id: 4c3fc4f193a84b6e28c43c08672d480715000923
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A request for a proper, new feature. module: complex Related to complex number support in PyTorch triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants