Skip to content

Conversation

nikitaved
Copy link
Collaborator

Fixes #80948.

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jul 12, 2022

🔗 Helpful links

✅ No Failures (0 Pending)

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

Expand to see more

💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@nikitaved nikitaved added the module: linear algebra Issues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmul label Jul 12, 2022
Copy link
Collaborator

@lezcano lezcano left a comment

Choose a reason for hiding this comment

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

There was the pesky squeeze that was missing. Thank you @nikitaved!

Could you add a short test to make sure that we're fixing the issue?

@nikitaved
Copy link
Collaborator Author

nikitaved commented Jul 12, 2022

The cases that trigger this warning are already in test_linalg.py. In fact, any valid input would have triggered them :)

@lezcano
Copy link
Collaborator

lezcano commented Jul 12, 2022

Yup, could you add one of those wrappers that make the test fail if a warning is thrown around those operations?

@nikitaved
Copy link
Collaborator Author

nikitaved commented Jul 12, 2022

I seem to fail to capture this warning with OpInfo, for example:

================================================================================= FAILURES ==================================================================================
_______________________________________________________________ TestCommonCPU.test_out_warning_matrix_exp_cpu _______________________________________________________________
Unexpected success
______________________________________________________________ TestCommonCUDA.test_out_warning_matrix_exp_cuda ______________________________________________________________
Unexpected success
============================================================================= warnings summary ==============================================================================
...
  /home/nik/git/Quansight/pytorch/torch/testing/_internal/common_methods_invocations.py:953: UserWarning: An output with one or more elements was resized since it had shape [1, 3, 3], which does not match the required output shape [1, 1, 3, 3]. This behavior is deprecated, and in a future PyTorch release outputs will not be resized unless they have zero elements. You can explicitly reuse an out tensor t by resizing it, inplace, to zero elements with t.resize_(0). (Triggered internally at /home/nik/git/Quansight/pytorch/aten/src/ATen/native/Resize.cpp:17.)
    return self.op(*args, **kwargs)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================== short test summary info ==========================================================================
FAILED test/test_ops.py::TestCommonCPU::test_out_warning_matrix_exp_cpu
FAILED test/test_ops.py::TestCommonCUDA::test_out_warning_matrix_exp_cuda

This is done with expectedFailure. Am I missing something, @mruberry ?

@lezcano
Copy link
Collaborator

lezcano commented Jul 12, 2022

test_out_warning just tests for some warnings, like:

            # Case Zero: out= with the correct dtype and device, but the wrong shape
            #   Expected behavior: if nonempty, resize with a warning.

What I was suggesting was to add a short test in test_linalg.py using something like https://stackoverflow.com/questions/45671803/how-to-use-pytest-to-assert-no-warning-is-raised. Doing so for the matrix example in the issue would be enough.

@nikitaved nikitaved force-pushed the nikitaved/matrix_exp_warning branch from 6aefb35 to 49bbc36 Compare July 12, 2022 18:06
@nikitaved nikitaved force-pushed the nikitaved/matrix_exp_warning branch from 49bbc36 to 036e1ab Compare July 12, 2022 18:08
Comment on lines +6198 to +6199
with freeze_rng_state():
torch.manual_seed(42)
Copy link
Collaborator Author

@nikitaved nikitaved Jul 12, 2022

Choose a reason for hiding this comment

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

Not sure this is strictly necessary, but decided to play it extra safe.

Copy link
Collaborator

@lezcano lezcano left a comment

Choose a reason for hiding this comment

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

Good stuff. Thank you Nik!

@lezcano
Copy link
Collaborator

lezcano commented Jul 12, 2022

@pytorchbot merge -g

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a merge job. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Merge failed due to Matched rule superuser, but PR #81330 was not reviewed yet by any of: nimin98, fbbradheintz, kavoor, lc0, shz117, ...
Raised by https://github.com/pytorch/pytorch/actions/runs/2658887357

@lezcano
Copy link
Collaborator

lezcano commented Jul 12, 2022

No one can say I didn't try. cc @mruberry

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.

Stamped!

@lezcano
Copy link
Collaborator

lezcano commented Jul 12, 2022

@pytorchbot merge -g

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a merge job. Check the current status here

@github-actions
Copy link
Contributor

Hey @nikitaved.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

@malfet
Copy link
Contributor

malfet commented Jul 13, 2022

Merge failed due to Matched rule superuser, but PR #81330 was not reviewed yet by any of: nimin98, fbbradheintz, kavoor, lc0, shz117, ... Raised by https://github.com/pytorch/pytorch/actions/runs/2658887357

I think the problem here is how we parse merge rules. I.e. following line

"aten/src/ATen/native/**/*LinearAlgebra*",

would match any LinearAlgebra file in native/ subfolder, but not LinearAlgebra in the folder itself

facebook-github-bot pushed a commit that referenced this pull request Jul 13, 2022
…es dim of the input. (#81330) (#81330)

Summary:
Fixes #80948.

Pull Request resolved: #81330
Approved by: https://github.com/Lezcano, https://github.com/mruberry

Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/85144e63a92b4a7df0c49bfc5797f24c4eeb831c

Reviewed By: DanilBaibak

Differential Revision: D37813332

Pulled By: DanilBaibak

fbshipit-source-id: f9bccbbd57fb7eea586ce3f564023879e16c29d6
pytorchmergebot pushed a commit that referenced this pull request Jul 19, 2022
#81330 (comment) shouldn't have happened and should have matched the linalg rule.

The reason it happened is cuz we don't treat the patterns like globs.

We may follow this up with a BE change to make the patterns be treated more like globs, which I expected originally.
Pull Request resolved: #81414
Approved by: https://github.com/malfet
facebook-github-bot pushed a commit that referenced this pull request Jul 20, 2022
…81414)

Summary:
#81330 (comment) shouldn't have happened and should have matched the linalg rule.

The reason it happened is cuz we don't treat the patterns like globs.

We may follow this up with a BE change to make the patterns be treated more like globs, which I expected originally.

Pull Request resolved: #81414
Approved by: https://github.com/malfet

Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/c67a4d8a65ade60eff0f394c74c33b55d9419741

Reviewed By: jeanschmidt

Differential Revision: D37990686

Pulled By: janeyx99

fbshipit-source-id: 89cd472c2b3bc352937906bbd27d883e0317d290
@github-actions github-actions bot deleted the nikitaved/matrix_exp_warning branch February 18, 2024 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Merged module: linear algebra Issues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmul open source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weird warning using matrix exp for complex tensors
7 participants