Conversation
…stream type from int to int64_t because they are pointers
…id memory bugs when dropping madspace outputs before synchronising)
…off the main stream
…he currently required syncronize
Contributor
|
Hi Jonas, thanks a lot! There is another PR on the way which touches memory management, so I'll review this one in detail once the other one is merged. On the first glance, it looks good to me. I have one suggestion what could be improved: The DLPACK API defines a function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Several modifications to make the code more flexible for external users of the
madspacepackage, focusing on the application of https://arxiv.org/abs/2608.23022. Also tried to generally make the stream handling inmadspacecleaner/safer.On a NVIDIA RTX PRO 500 Blackwell GPU this made a batchsize=1k evaluation of 3-body
TPropagatorMapping.map_forward2x faster (384mus -> 177mus, becausecudaFreeAsync) and significantly reduced host occupation (3.21ms -> 0.37ms at batchsize=100k, because no stream sync). I didn't find any scenario that gets slower.I used claude for the code edits.
Bug fixes
cudaFreeAsyncinstead ofcudaFreeto fix thisstreamargumentstream,copy,max_version; now they are usedNew features
with madspace.stream(torch.cuda.current_stream().cuda_stream): ...; avoids overhead from stream syncsfork_streamsandjoin_streamskeep each stream clean until passing it back to the callerrelease_inputs()to give manual control about when tensors held inmadspaceare cleanedComments
dl_deviceraises an error_prev_caches,_prev_caches_backward,update_cached_tensors,MemPool::resetand_backward_wait_eventsfunctions are called only from commented-out code