Skip to content

sparse gradcheck: retire gradcheck_semantics#99043

Closed
nikitaved wants to merge 39 commits intogh/nikitaved/38/basefrom
gh/nikitaved/38/head
Closed

sparse gradcheck: retire gradcheck_semantics#99043
nikitaved wants to merge 39 commits intogh/nikitaved/38/basefrom
gh/nikitaved/38/head

Conversation

@nikitaved
Copy link
Copy Markdown
Collaborator

@nikitaved nikitaved commented Apr 13, 2023

Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with masked=False implies success with masked=True, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.

Stack from ghstack (oldest at bottom):

cc @alexsamardzic @pearu @cpuhrsch @amjames @bhosmer @ezyang @albanD @zou3519 @gqchen @soulitzer @lezcano @Varal7

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Apr 13, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/99043

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure

As of commit 6f1678b:

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Apr 13, 2023
nikitaved added a commit that referenced this pull request Apr 13, 2023
ghstack-source-id: 80c43b5
Pull Request resolved: #99043
@nikitaved nikitaved added module: sparse Related to torch.sparse module: autograd Related to torch.autograd, and the autograd engine in general labels Apr 13, 2023
@pearu
Copy link
Copy Markdown
Collaborator

pearu commented Apr 14, 2023

@nikitaved I think you have missed the point of these tests that this PR removes and the previous PR modifies. These tests cover the functionality of gradcheck for masked being True or False. When removing masked=True checks, you essentially leave the corresponding paths in gradcheck untested.

Also, notice that if a test passes with masked=False, this does not always imply that the test will pass with masked=True. This implication is true only when the sparse inputs are full tensors (_nnz() == numel() when non-hybrid, for instance) because the densification (that is applied when masked=False) will be a no-op. Otherwise, when input tensors have unspecified elements, the gradcheck with masked=True has subtleties that are not covered with masked=False.

In fact, I think the general implication is: if a test passes with masked=True then it will pass with masked=False. So, I find this and the previous PR unacceptable from a point of view of reducing the test coverage of gradcheck.
From the operations point of view, indeed, checking with masked=False will be sufficient in the domain of non-masked semantics but we'll still need to test the masked semantics as this is what ops in torch.sparse namespace implement and a few operations in torch namespace support.

Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
@nikitaved
Copy link
Copy Markdown
Collaborator Author

nikitaved commented Apr 17, 2023

After an offline discussion with @pearu we did reach consensus. Namely, it would be great to have masked=True/False to test logic in gradcheck. It looks, like, @pearu , these cases are covered in test/test_autograd.py, so we should be safe here...

Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
@pearu
Copy link
Copy Markdown
Collaborator

pearu commented Apr 17, 2023

It looks, like, @pearu , these cases are covered in test/test_autograd.py, so we should be safe here...

Hmm, can you be more specific? AFAIK, test_autograd.py does not cover all the combinations of to_dense(masked_grad=...) and gradcheck(..., masked=..., fast_mode=...) usages (although ciflow/periodic will cover the fast_mode variations).

@nikitaved
Copy link
Copy Markdown
Collaborator Author

@pearu, for example, have a look at

def test_gradcheck_validates_inputs(self):
.

@pearu
Copy link
Copy Markdown
Collaborator

pearu commented Apr 17, 2023

@nikitaved

0157b2d

this covers only the COO layout but there are no tests with sparse compressed layouts.

@nikitaved
Copy link
Copy Markdown
Collaborator Author

nikitaved commented Apr 17, 2023

@pearu , none of the tests I modified in test_sparse.py concern any compressed formats IIRC...

Comment on lines +4484 to +4470
r = gradcheck(lambda x: torch.Tensor.to_dense(x, masked_grad=gradcheck.masked), t)
r = gradcheck(lambda x: torch.Tensor.to_dense(x, masked_grad=False), t)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ah, ok, this one touches compressed formats. Will update it, @pearu .

Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
nikitaved added 13 commits June 28, 2023 12:46
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
Once the tests are parametrized to properly reflect domains/co-domains of sparse functions, success with `masked=False` implies success with `masked=True`, so there is no need in running gradcheck twice.

This PR only affects the tests, it does not touch any gradcheck code.




cc alexsamardzic pearu cpuhrsch amjames bhosmer ezyang albanD zou3519 gqchen soulitzer Lezcano Varal7

[ghstack-poisoned]
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 1, 2023

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

@github-actions github-actions bot added the Stale label Sep 1, 2023
@github-actions github-actions bot closed this Oct 1, 2023
@facebook-github-bot facebook-github-bot deleted the gh/nikitaved/38/head branch November 1, 2023 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: autograd Related to torch.autograd, and the autograd engine in general module: sparse Related to torch.sparse open source Stale topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants