feat(scalarization): Add cosmos#745
Open
ppraneth wants to merge 1 commit into
Open
Conversation
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.
Adds
COSMOSfrom Scalable Pareto Front Approximation for Deep Multi-Objective Learning (Ruchte & Grabocka, ICDM 2021).It is a stateless scalarizer (loss values only), so it fits
Scalarizer.forward(values)directly, likeSTCH.Working
COSMOS combines a linear scalarization with a cosine-similarity penalty that pulls the vector of values toward a preference direction:
where$L_i$ is the $i$ -th value, $r$ is the preference vector, and $\lambda$ is the penalty coefficient. The subtracted term is $\lambda \cos(r, L)$ : minimizing the objective rewards aligning the values with the preference direction, which is what spreads the approximated Pareto front.
Design
lambda_(the paper's0reduces COSMOS to a plain linear scalarization. The paper uses values from0.01to8depending on the dataset, with no single best, so there is no default (same choice asSTCH'smu). The name follows theSDMGradprecedent for the reserved word.weights(the preferenceSTCH.nan; this is documented and locked by a test.Notes on the formula
I followed the paper's Equation 5 (and the official$r^\top L$ . The libmoon reference normalizes that term by $\lVert r \rVert$ , which differs for non-uniform preferences; this is noted in the docstring. Only the scalarization is implemented here. The full COSMOS method also conditions the model on the preference vector by concatenating it to the input, which is a modeling choice left to the user.
ruchtem/cosmosimplementation), where the linear term is the raw weighted sumTests
The cosine-aligned zero case (
COSMOS(1.0)([1, 1]) == 0),lambda_ = 0as linear scalarization, custom weights, the full formula with non-uniform weights, structure and gradient flow over all input shapes, permutation invariance with uniform weights,nanon all-zero values, negativelambda_raising, weights-shape-mismatch raising, and the representations.