Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Migrate to torch-cluster #54

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from
Open

Migrate to torch-cluster #54

wants to merge 25 commits into from

Conversation

JPXKQX
Copy link
Member

@JPXKQX JPXKQX commented Oct 2, 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).

@JPXKQX JPXKQX marked this pull request as draft October 4, 2024 10:47
@JPXKQX JPXKQX self-assigned this Oct 8, 2024
@JPXKQX JPXKQX added the enhancement New feature or request label Oct 8, 2024
@JPXKQX JPXKQX marked this pull request as ready for review October 8, 2024 15:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant