Skip to content

Conversation

@j-c-c
Copy link
Collaborator

@j-c-c j-c-c commented Apr 28, 2025

Port of the common lines method using IRLS.

@j-c-c j-c-c added the enhancement New feature or request label Apr 28, 2025
@j-c-c j-c-c self-assigned this Apr 28, 2025
@codecov
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 97.36842% with 4 lines in your changes missing coverage. Please review.

Project coverage is 90.60%. Comparing base (04c9c04) to head (f7e8851).
Report is 26 commits behind head on develop.

Files with missing lines Patch % Lines
src/aspire/abinitio/commonline_lud.py 88.46% 3 Missing ⚠️
src/aspire/abinitio/commonline_irls.py 99.18% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1263      +/-   ##
===========================================
+ Coverage    90.53%   90.60%   +0.06%     
===========================================
  Files          132      133       +1     
  Lines        14219    14346     +127     
===========================================
+ Hits         12873    12998     +125     
- Misses        1346     1348       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@j-c-c j-c-c force-pushed the IRLS branch 2 times, most recently from 58af01b to 92c14f7 Compare May 21, 2025 18:06
@j-c-c j-c-c changed the title [WIP] IRLS IRLS May 21, 2025
@j-c-c j-c-c requested a review from garrettwrong May 21, 2025 19:43
Copy link
Collaborator

@garrettwrong garrettwrong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay getting this back to you. Not too much to do, it looks like you were able to get a lot of code re-use from prior work so I guess that paid off :).

Some of the items here we chatted about. For those just add a short response or code comment if necessary so it's documented with the PR/code. Thanks

garrettwrong
garrettwrong previously approved these changes Jun 17, 2025
Copy link
Collaborator

@garrettwrong garrettwrong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Very exciting to complete the MATLAB symmetric CL methods. Nice job.

@j-c-c j-c-c marked this pull request as ready for review June 17, 2025 18:29
@j-c-c j-c-c requested a review from janden as a code owner June 17, 2025 18:29
Copy link
Collaborator

@janden janden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just a few things.

logger = logging.getLogger(__name__)


class CommonlineIRLS(CommonlineLUD):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a form of LUD, should that be part of the name? If I understand correctly, CommonlineLUD uses the SDP solver, while this uses IRLS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. Yes, it is a form of LUD. Figuring out what to call these classes will be part of the project to reorganizing all of the commonline classes.

CommonlineLUD uses an implementation of ADMM with or without a spectral norm constraint to solve the LUD problem. CommonlineIRLS uses an SDP solver when there is no spectral norm constraint and ADMM when there is a spectral norm constraint to solve the least squares problem for each reweighting iteration.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

A, b = self._sdp_prep()
for _ in trange(self.num_itrs, desc="Performing iterative re-weighting."):
S_weighted = weights * self.S
gram = self._compute_gram_matrix(S_weighted, A, b)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between _compute_gram_matrix and _compute_Gram? Why is one used with spectral norm constraint and one without?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_compute_gram_matrix is calling the SDP solver in CommonlineSDP and _compute_Gram is calling the ADMM implementation in this file.

Maybe these should be renamed to indicate this. What do you think of _compute_gram_SDP and _compute_gram_IRLS?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!



class CommonlineLUD(CLOrient3D):
class CommonlineLUD(CommonlineSDP):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of weird, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a little weird. CommonlineLUD does use at least one method from CommonlineSDP (ie. _deterministic_rounding) and passes _compute_Gram and _construct_S to CommonlineIRLS via class hierarchy. It might be better for those methods to be utility functions that can be called independent of class hierarchy. This is another topic that I planned on addressing with the overall commonline class restructure.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better for those methods to be utility functions that can be called independent of class hierarchy. This is another topic that I planned on addressing with the overall commonline class restructure.

Right. I think that might be a better approach.

@garrettwrong
Copy link
Collaborator

I think this was good to go after the name update, fire when ready :) 🚀

@j-c-c j-c-c merged commit 52d3ce6 into develop Jul 2, 2025
35 checks passed
@j-c-c j-c-c mentioned this pull request Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants