enable torch compile with cudagraphs #20
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed by @giadefa This PR adds the necessary changes to AIMNet2 so that the model can be torch.compile'd with cudagraphs enabled.
This speeds up small molecule MD significantly. The new example
ase_md.pyscript demonstrates the speedup.The original runs 10000 steps in 76 seconds, the new version runs in 15 seconds.
Original:
New with
torch.compile(self.model, fullgraph=True, options={'triton.cudagraphs':True}):It is currently only implemented for nb_mode=0 and a single molecule.
The key required changes are to replace data dependent control flow with compile time constant control flow. Therefore, I have added a
setup_for_compile_cudagraphsmethod to some modules to do this.The feature is supported by the ASE calculator interface.