Skip to content

feat: batched graph construction that also support GPU#138

Open
yanghan234 wants to merge 13 commits intomainfrom
gpu-graph
Open

feat: batched graph construction that also support GPU#138
yanghan234 wants to merge 13 commits intomainfrom
gpu-graph

Conversation

@yanghan234
Copy link
Collaborator

@yanghan234 yanghan234 commented Feb 4, 2026

Summary

This PR implements a batched graph generation pipeline that supports GPU acceleration, alongside general code cleanup and refactoring.

Key Changes

  • New Graph Converter: Introduced BatchGraphConverter in converter.py. This new converter leverages batch processing and can utilize CUDA for faster graph construction.
  • Three-Body Acceleration: Added threebody_indices_torch.py to compute three-body indices efficiently on the GPU, replacing the CPU-bound iteration.
  • Refactored build_dataloader
    • Updated build_dataloader in build.py to support the new pipeline.
    • Added a batch_converter flag (default: True) to easily switch between the new optimized batch converter and the legacy single-item converter.
  • Dependencies: Updated pyproject.toml to include torch-scatter and refine torch version.
  • Add a script scripts/benchmark_graph_converter.py to benchmark and compare the speed of the new graph implementation

@yanghan234 yanghan234 self-assigned this Feb 4, 2026
@yanghan234
Copy link
Collaborator Author

By running the benchmark script on the following structures: test_structures.xyz.zip, you should be able to see the following results:

----------------------------------------
Energy Error Summary (batch_converter=True vs False):
Number of structures: 1000
MAE:           7.675171e-06 eV
RMSE:          3.186059e-05 eV
Max Error:     4.882812e-04 eV
MAE/atom:      2.088059e-04 meV/atom
RMSE/atom:     4.678199e-04 meV/atom
Max Error/atom: 4.577637e-03 meV/atom
----------------------------------------
Timing Summary:
Graph conversion (ref):  1.8792s
Graph conversion (test): 0.9001s
Speedup (graph only):    2.09x
Total time (ref):        3.0376s
Total time (test):       1.3849s
Speedup (total):         2.19x
----------------------------------------

Also, the difference of the energy prediction and the time speedup are shown as plots:
energy_parity_plot
speedup_plot

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.

2 participants