Repository navigation
made distributions agnostic of the distributed object - #1026
Merged
Merged
Conversation
Moved the distributions from sisl/_core/mpi to sisl/mpi/_distribute.py and exposed them through sisl.mpi. The SparseCSR specifics now live in sisl/_core/_sparse_distribute.py, and sisl/_core/mpi is removed. A Distribution now only holds the communicator and the indices it distributes, so it can be re-used on any object of the same length: dist = BlockCyclicDistribution(n, blocksize=1, comm=None) dist(obj, *args, **kwargs) # -> obj.__sisl_distribute__(dist, *args, **kwargs) The object decides what distributing means (in-place assembly for SparseCSR, a generator could serve batches of k-points). The comm is keyword-only and defaults to sisl.mpi.get_comm(), so basic distributions need no communicator; size and the default rank in range/indices/count follow from the communicator. Renames: - Partition -> Distribution - BlockCyclicPartition -> BlockCyclicDistribution - old Distribution (epoch/assembled) -> DistributionState, stored on the object in SparseCSR._dist_state (was _distribution) Other changes: - distribute(csr, dist=None, op="single") accepts a distribution; a different distribution than the attached one re-ships all elements to their new owners. - distribute's default op was "insert", which its own check rejected; now "single". - Distribution equality also compares the communicator. - removed Distribution.__len__ (ambiguous between n and size), use .n or .size. - removed Partition.from_comm and the partition/comm size check, the size now comes from the communicator. Added documentation: a guide on distributing work under "Advanced usage" (docs/distribution.rst), the sisl.mpi API page (docs/api/mpi.rst), and SISL_MPI in docs/environment.rst. Tests split into sisl/mpi/tests/test_distribute.py (distributions) and sisl/_core/tests/test_sparse_distribute.py (SparseCSR), including a parallel redistribution check. Signed-off-by: Nick Papior <nickpapior@gmail.com> Assisted-by: claude-code:claude-opus-5-5
| from sisl.mpi._distribute import Distribution, DistributionState | ||
|
|
||
| from .distribute import Partition | ||
| from .sparse import SparseCSR |
| distribute : the implementation, and the details | ||
| """ | ||
| from .mpi.sparse_distribute import distribute | ||
| from ._sparse_distribute import distribute |
| distribute, | ||
| local_rows, | ||
| ) | ||
| from sisl._core._sparse_distribute import distribute, local_rows |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1026 +/- ##
==========================================
+ Coverage 85.89% 86.45% +0.56%
==========================================
Files 421 419 -2
Lines 55593 55495 -98
==========================================
+ Hits 47751 47979 +228
+ Misses 7842 7516 -326 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Moved the distributions from sisl/_core/mpi to sisl/mpi/_distribute.py and exposed them through sisl.mpi. The SparseCSR specifics now live in sisl/_core/_sparse_distribute.py, and sisl/_core/mpi is removed.
A Distribution now only holds the communicator and the indices it distributes, so it can be re-used on any object of the same length:
dist = BlockCyclicDistribution(n, blocksize=1, comm=None)
dist(obj, *args, **kwargs) # -> obj.sisl_distribute(dist, *args, **kwargs)
The object decides what distributing means (in-place assembly for SparseCSR, a generator could serve batches of k-points). The comm is keyword-only and defaults to sisl.mpi.get_comm(), so basic distributions need no communicator; size and the default rank in range/indices/count follow from the communicator.
Renames:
Other changes:
Added documentation: a guide on distributing work under "Advanced usage" (docs/distribution.rst), the sisl.mpi API page (docs/api/mpi.rst), and SISL_MPI in docs/environment.rst.
Tests split into sisl/mpi/tests/test_distribute.py (distributions) and sisl/_core/tests/test_sparse_distribute.py (SparseCSR), including a parallel redistribution check.
Assisted-by: claude-code:claude-opus-5-5
docs/changes/<num>.<type>.rst