Skip to content

refactor!: Add DualConeProjector#678

Open
PierreQuinton wants to merge 5 commits into
mainfrom
add-weight-projector
Open

refactor!: Add DualConeProjector#678
PierreQuinton wants to merge 5 commits into
mainfrom
add-weight-projector

Conversation

@PierreQuinton
Copy link
Copy Markdown
Contributor

No description provided.

@PierreQuinton PierreQuinton added package: aggregation cc: refactor Conventional commit type for any refactoring, not user-facing, and not typing or perf improvements package: linalg labels May 11, 2026
@PierreQuinton PierreQuinton marked this pull request as ready for review May 11, 2026 08:30
@PierreQuinton PierreQuinton requested review from a team and ValerianRey as code owners May 11, 2026 08:30
@ValerianRey
Copy link
Copy Markdown
Contributor

Need to make these projectors public and documented. I think the public linalg package would be a nice fit, but maybe an aggregation subpackage would also be cool (torchjd.aggregation.dual_cone_projection).

Copy link
Copy Markdown
Contributor

@ValerianRey ValerianRey left a comment

Choose a reason for hiding this comment

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

Need changelog entry. This will be a breaking change especially if we move the norm_eps and reg_eps params to the projector. Otherwise it's breaking just for people specifying the solver (still breaking but to very few people).


class DualConeProjector(ABC):
@abstractmethod
def project_weights(self, U: Tensor, G: PSDMatrix) -> Tensor:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rename to __call__?


def projector_or_default(projector: DualConeProjector | None) -> DualConeProjector:
if projector is None:
return QPSolverBased("quadprog")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think quadprog should be a subclass of QPSolverBased.

If we don't do that, we'll be unable to use solver-specific extra parameters.


def forward(self, gramian: PSDMatrix, /) -> Tensor:
u = self.weighting(gramian)
G = regularize(normalize(gramian, self.norm_eps), self.reg_eps)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the regularization and normalization should become part of the projector, because the requiered amount of regularization or projection may vary per solver. Norm_eps and reg_eps should thus also be given to the projector directly I think.

@ValerianRey ValerianRey added breaking-change This PR introduces a breaking change. and removed package: linalg labels May 11, 2026
@github-actions github-actions Bot changed the title refactor: Add DualConeProjector refactor(aggregation)!: Add DualConeProjector May 11, 2026
@github-actions github-actions Bot changed the title refactor(aggregation)!: Add DualConeProjector refactor!: Add DualConeProjector May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change This PR introduces a breaking change. cc: refactor Conventional commit type for any refactoring, not user-facing, and not typing or perf improvements package: aggregation package: linalg

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants