Refactor and test vectorized BTD#25
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the block-tridiagonalization utilities in dpnegf/negf/split_btd.py to reduce duplicated logic and improve performance via vectorization and Numba JIT, while adding regression tests that validate equivalence with the legacy implementations across a range of sparsity patterns.
Changes:
- Vectorize
compute_edgeusingnp.maximum.at+np.maximum.accumulate. - Introduce Numba JIT cores for
compute_blocksandfind_optimal_cutand route public APIs through them. - Add new equivalence test suites covering dense/sparse inputs, docstring examples, and NEGF-like sparsity patterns.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
dpnegf/negf/split_btd.py |
Reworks edge/profile computation and block computation/cut selection to use vectorized + Numba-accelerated cores. |
dpnegf/tests/test_split_btd_compute_edge.py |
Adds new-vs-legacy equivalence tests for the vectorized compute_edge. |
dpnegf/tests/test_split_btd_compute_blocks.py |
Adds extensive equivalence coverage for compute_blocks, find_optimal_cut, and optimized subblock splitting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+471
to
+474
| new = compute_blocks_optimized(edge, edge1, left=1, right=1) | ||
| old = _compute_blocks_optimized_legacy(edge, edge1, left=1, right=1) | ||
| assert new == old | ||
| assert sum(new) == n |
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.
Remove duplicated code and vectorize the
compute_edgesfunctions. Add equivalence tests to ensure the new vectorized implementation matches the legacy version for various matrix configurations. Update related functions to utilize JIT compilation for improved performance.