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

feat/migrate-graph-creation-to-torch #56

Draft
wants to merge 69 commits into
base: develop
Choose a base branch
from
Draft

Conversation

JPXKQX
Copy link
Member

@JPXKQX JPXKQX commented Dec 31, 2024

This PR improves the performance of creating a graph:

  • Update the KNNEdges & CutOffEdges to rely on torch-cluster. This method also supports moving the tensors to the GPU.
  • EdgeAttributeBuilder's are now implemented as message passing graphs. This method supports moving the tensors to the GPU.

The performance improvement for generating a graph n320 (~500k nodes) -> o96 (~40k nodes) -> n320 is:

version Device CutOffEdges(cutoff_factor=0.6) CutOffEdges attribute KNNEdges(num_nearest_neighbors=3) KNNEdges attributes
v3.0.0 CPU 2.25 s 0.55 s 11.83 s 1.21 s
torch-support CPU 0.45 s 0.31 s 0.30 s 0.54 s
torch-support. 1 GPU 0.19 s 0.14 s 0.15 s 0.00 s

The main difference is that the Haversine distance is not supported in the torch-cluster. To solve this problem, we transform the 2D coordinates into 3D coordinates (sphere) before calculating the Euclidean distance. The edge direction calculation has also been refactored to use torch.tensor's instead of np.array's & scipy (using Rodrigues' rotation formula).

bluefoxr and others added 26 commits November 27, 2024 14:46
@JPXKQX JPXKQX added enhancement New feature or request graphs labels Dec 31, 2024
@JPXKQX JPXKQX self-assigned this Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request graphs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants