Skip to content

Conversation

@nikitaved
Copy link
Collaborator

@nikitaved nikitaved commented Dec 9, 2024

As per title.

The following implementation removes the usage of repeat_interleave, tile and full_coo_indices and replaces them with broadcasting. That way we reduce memory traffic (and are likely to hit cache a lot) and the total number of launched kernels.

cc @alexsamardzic @pearu @cpuhrsch @amjames @bhosmer @jcaip

@pytorch-bot
Copy link

pytorch-bot bot commented Dec 9, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 1c535d6 with merge base c29b4ed (image):
💚 Looks good so far! There are no failures yet. 💚

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

@nikitaved nikitaved added module: sparse Related to torch.sparse release notes: sparse release notes category labels Dec 9, 2024
@nikitaved nikitaved force-pushed the nikitaved/coo_broadcast_less_memory branch 3 times, most recently from 9db7b0a to fae893d Compare December 9, 2024 13:32
@janeyx99 janeyx99 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Dec 9, 2024
Copy link
Collaborator

@amjames amjames left a comment

Choose a reason for hiding this comment

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

Nice! This looks good, minor nit in the CHECK message.


for (int64_t i = 0; i < self.dim(); ++i) {
TORCH_CHECK(self_size[i] == 1 || self_size[i] == size[i + new_sparse_dims],
"The input's lenght ", self_size[i], " at dimension ", i,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"The input's lenght ", self_size[i], " at dimension ", i,
"The input's length ", self_size[i], " at dimension ", i,

for (int64_t i = 0; i < self.dim(); ++i) {
TORCH_CHECK(self_size[i] == 1 || self_size[i] == size[i + new_sparse_dims],
"The input's lenght ", self_size[i], " at dimension ", i,
" does not broadcast over the requested shape of lenght ", size[i + new_sparse_dims],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
" does not broadcast over the requested shape of lenght ", size[i + new_sparse_dims],
" does not broadcast over the requested shape of length ", size[i + new_sparse_dims],

Copy link
Contributor

@cpuhrsch cpuhrsch left a comment

Choose a reason for hiding this comment

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

Awesome!

@nikitaved nikitaved force-pushed the nikitaved/coo_broadcast_less_memory branch from fae893d to 1c535d6 Compare December 11, 2024 11:19
@nikitaved
Copy link
Collaborator Author

Thank you for your reviews, guys!

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Dec 11, 2024
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@github-actions github-actions bot deleted the nikitaved/coo_broadcast_less_memory branch January 11, 2025 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged module: sparse Related to torch.sparse open source release notes: sparse release notes category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants