bugfix: wrong initialization of ConsensusADMM#248
Merged
mrava87 merged 3 commits intoPyLops:devfrom Mar 12, 2026
Merged
Conversation
- fix initialization of y_1, ..., y_m to have a correct dimension
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug in the initialization of the dual variable y in the ConsensusADMM function. The variable was incorrectly initialized with dimension d instead of m × d, where m is the number of proximal operators and d is the dimension of the problem. This bug caused index out-of-bounds errors when m > d, though it went undetected in tests where m ≤ d due to numpy's broadcasting behavior in subsequent iterations that inadvertently corrected the shape.
Changes:
- Fixed initialization of dual variable
yfromncp.zeros_like(x0)toncp.zeros((m, x0.shape[0]))to correctly allocate space for m dual variables, each of dimension d
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Fix initialization of$y_1, \ldots, y_m \in R^d$ to have a correct dimension.
The variable$m \times d$ , where $d$ .
yshould have a dimension ofdis the dimension ofx0, but it was incorrectly initialized to a dimension ofBefore this change, the test passed incorrectly when$m \le d$ due to the following line;
But this will be an error when$m > d$ because out of index.$m=2$ proxfs with $d=$ $m=4$ proxfs and $d=2$ dimension of
The test code in
test_solver.pyuses onlypar["m"] == 10, so I missed this bug.I found this when I used
x0.Notet that, in the second iteration, the dimension of$m \times d$ as expected because of the following line, so that the test have passed after iterations even with the wrong initialization.
ybecome