Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor dual cone projections #237

Merged
merged 36 commits into from
Feb 4, 2025
Merged

Conversation

PierreQuinton
Copy link
Contributor

Both DualProj and UPGrad rely on projections onto the dual cone, this PR factorizes the computation of such projections into one utility in the aggregation package.

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
src/torchjd/aggregation/_dual_cone_utils.py 100.00% <100.00%> (ø)
src/torchjd/aggregation/_gramian_utils.py 90.90% <100.00%> (+3.40%) ⬆️
src/torchjd/aggregation/dualproj.py 100.00% <100.00%> (ø)
src/torchjd/aggregation/upgrad.py 100.00% <100.00%> (+1.96%) ⬆️

Base automatically changed from explicit_dtypes to main January 21, 2025 16:24
@PierreQuinton PierreQuinton force-pushed the factorize_dual_cone_projections branch from d9f60e3 to 5c15741 Compare January 21, 2025 17:15
@ValerianRey
Copy link
Contributor

I really like the idea! I'll make a proper review and probably merge later this week.

@ValerianRey
Copy link
Contributor

I think a5f562a is worth a changelog entry, with a vague explanation of what was done and how it may affect results. For instance

Changed

  • Refactored the underlying optimization problem that UPGrad and DualProj have to solve to project onto the dual cone. This may minimally affect the output of these aggregators.

- Change parameter order
- Change variable names
- Simplify operations
- Rename functions
- Improve documentation
- Always use G for the gramian
- Always use u and U for a vector / tensor of weights prior to projection
- Always use w and W for a vector / tensor of projection weights
- Add underscore to disambiguate with numpy version when necessary
- I think it's better to not name self.weighting(matrix) as u, because it doesn't have the same role as a single u afterwards. Therefore, I removed this variable name.
@ValerianRey
Copy link
Contributor

ValerianRey commented Feb 4, 2025

  • ✅ Code: LGTM
  • ✅ Correctness: Tests pass on cpu (in CI) and on gpu (on my machine).
  • ✅ Results: I ran the trajectories on the EWQ and CQF objective with this version, and the results are visually exactly the same as with v0.5.0.
  • ✅ Runtime: The tests on cpu gave very similar runtimes, and the tests on gpu gave slightly better (3 to 6% I would say) runtimes with this version.

@ValerianRey ValerianRey changed the title Factorize dual cone projections Refactor dual cone projections Feb 4, 2025
@ValerianRey ValerianRey merged commit 1d87f56 into main Feb 4, 2025
14 checks passed
@ValerianRey ValerianRey deleted the factorize_dual_cone_projections branch February 4, 2025 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants