Skip to content

Avoid stream sync in softmax#10499

Open
spinjo wants to merge 4 commits intopyg-team:masterfrom
spinjo:softmax-nosync
Open

Avoid stream sync in softmax#10499
spinjo wants to merge 4 commits intopyg-team:masterfrom
spinjo:softmax-nosync

Conversation

@spinjo
Copy link

@spinjo spinjo commented Oct 13, 2025

Bug in `torch_geometric.utils.softmax

If the output_size argument is not provided in torch.repeat_interleave, then the output_size is calculated on the fly, at the cost of a stream synchronization, see https://docs.pytorch.org/docs/stable/generated/torch.repeat_interleave.html. But if the torch_geometric.utils.softmax function gets the index argument in addition to ptr, we get output_size for free - so we should use it.

Proposed fix

When ptr and index are both provided in torch_geometric.utils.softmax, use index to set the output_size in torch.repeat_interleave. Added a unit test for this case.

@spinjo
Copy link
Author

spinjo commented Mar 19, 2026

PR was open for 5 months, but should be an easy one to merge. Let me know if I can help with anything.

@akihironitta @rusty1s @wsad1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant