Refactor selfEnergy implementation and lead matrices#39
Merged
Conversation
Collaborator
Author
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 performance optimizations and code refactoring to the surface Green's function calculation in the NEGF module. The main improvements are the precomputation and reuse of matrix conjugate-transposes, efficient conversion of tensors to NumPy arrays, and a more consistent interface for the surface Green's function core routines. These changes reduce redundant computations and improve compatibility with Numba and multiprocessing.
Performance and Memory Optimizations
_pack_lead_matricesutility inlead_property.pyto precompute and storeconj(HLLk.T)andconj(SLLk.T)ash10ands10, and to convert relevant matrices to C-contiguousnp.complex128arrays. This minimizes repeated torch→numpy conversions and avoids recomputing conjugate-transposes per energy. (dpnegf/negf/lead_property.pydpnegf/negf/lead_property.pyR911-R948)_pack_lead_matrices, ensuring all workers receive efficiently packed data. (dpnegf/negf/lead_property.py[1] [2]API and Interface Changes
selfEnergyandsurface_greenfunctions to accept optionalh10ands10arguments for the precomputed conjugate-transposes, defaulting to on-the-fly computation if not provided. (dpnegf/negf/surface_green.py[1] [2]dpnegf/negf/surface_green.py[1] [2] [3]Algorithmic Refactoring
dpnegf/negf/surface_green.py[1] [2]Compatibility and Reliability
dpnegf/negf/lead_property.py[1] [2]fastmath=Falsefor validation purposes. (dpnegf/negf/surface_green.pydpnegf/negf/surface_green.pyR171-R176)These changes should yield a noticeable speedup in NEGF calculations, especially in parallel or high-throughput scenarios, by avoiding redundant computation and memory layout conversions.