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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove torch_scatter and torch_cluster from CI pipeline's dependencies #233

Merged
merged 27 commits into from
Oct 12, 2023

Conversation

dhpitt
Copy link
Collaborator

@dhpitt dhpitt commented Oct 9, 2023

We currently use the module torch_scatter on main for one function called segment_csr, which aggregates features across each neighborhood for the GINO model in neuralop.layers.integral_transform.py. This implements a simple python version of the same function to remove our dependence on torch_scatter and fix that annoying OSError in our CI.

Second note: the same error occurs with the CPU version of torch_cluster, so I wrote a neighborhood search for CPU runners only.

@dhpitt dhpitt changed the title Remove torch_scatter from dependencies Remove torch_scatter and torch_cluster from CI pipeline's dependencies Oct 9, 2023
@dhpitt
Copy link
Collaborator Author

dhpitt commented Oct 10, 2023

Small empirical tests show that my neighbor search function runs in about 1/3 the time of torch_cluster.radius.

Copy link
Member

@JeanKossaifi JeanKossaifi left a comment

Choose a reason for hiding this comment

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

Thanks for the changes @dhpitt -- should we have a small unit-test for the fallbacks?

neuralop/layers/neighbor_search.py Outdated Show resolved Hide resolved
device=neighbors_count.device)),
dim=0)
if not self.use_torch_cluster:
return_dict = self.search_fn(data, queries, radius)
Copy link
Member

Choose a reason for hiding this comment

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

@kovachki Should we just keep the manual implementation and just choose between open3d (fast) and fallback (slow)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Implemented.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I think this is best. Let's just remove cluster altogether.

if torch.backends.cuda.is_built():
"""only import torch_scatter when cuda is available"""
import torch_scatter.segment_csr as scatter_segment_csr
return scatter_segment_csr(src, indptr, reduce)
Copy link
Member

Choose a reason for hiding this comment

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

Hmm cuda being built doesn't necessarily mean torch_scatter will be available? Shouldn't we check for both?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For now I thought we would keep torch_scatter as a dependency, but only for GPU users. In that case is it reasonable to assume it's available whenever CUDA is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Logic is changed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@dhpitt could you please check that your segment_csr works with backwards. You're doing some inplace operations so I'm not sure.

@JeanKossaifi
Copy link
Member

@kovachki suggested also checking whether this works with backwards -- can you do add a simple sum loss and check for backward in the unit-test?

@JeanKossaifi JeanKossaifi merged commit f543775 into neuraloperator:main Oct 12, 2023
1 check passed
@JeanKossaifi
Copy link
Member

Awesome, thanks @dhpitt !

@dhpitt dhpitt deleted the segment_csr branch October 30, 2023 21:53
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.

None yet

3 participants