RGF_ACC: Reduce dead memory in RGF and Improve energy chunk size handling#35
Merged
Merged
Conversation
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.
This pull request introduces several memory management improvements and safeguards for the recursive Green's function (NEGF) calculations, particularly targeting CUDA out-of-memory (OOM) avoidance and better resource release. The changes focus on explicitly releasing large intermediate tensors and lists as soon as possible, tightening the automatic batch size calculation to be more conservative, and warning users when their manual settings exceed safe limits.
Memory management improvements:
sd,sl,su,temp_mat_d_list, etc.) immediately after their last use inrecursive_green_cal.pyto encourage earlier memory release and reduce peak usage. [1] [2] [3]Batch size calculation and OOM avoidance:
_auto_chunk_sizeby raising the constantCfrom 10 to 14 and lowering the free-memory budget from 0.7x to 0.5x, reflecting updated estimates of per-energy memory usage and real-world OOM observations. [1] [2]e_batch_sizemanually, log a warning if it exceeds the automatically determined safe cap for the current CUDA device. Also, always log the batch size being used for traceability.These changes collectively make the NEGF runner more robust against CUDA OOM errors and improve transparency for users adjusting batch sizes.