Skip to content

feat(aggregation): Add FairGrad#688

Merged
ValerianRey merged 14 commits into
mainfrom
feat/fairgrad
May 20, 2026
Merged

feat(aggregation): Add FairGrad#688
ValerianRey merged 14 commits into
mainfrom
feat/fairgrad

Conversation

@ValerianRey
Copy link
Copy Markdown
Contributor

@ValerianRey ValerianRey commented May 18, 2026

Summary

  • Adds FairGrad and FairGradWeighting implementing the step decision of Algorithm 1 from Fair Resource Allocation in Multi-Task Learning
  • Handles alpha=0 as a closed-form special case returning uniform weights (matching the paper: "w_i = 1 for all i when α = 0"), avoiding division by zero in the general formula
  • Adds a fairgrad optional dependency group (pip install "torchjd[fairgrad]") backed by scipy

Adapted by claude code from the implementation we started a while ago: https://github.com/ValerianRey/torchjd_private/commit/3bb76b0ca807a2929f059facc2e3c50e76154a69#diff-c532e502689e02a8fc7f2f75712294f9db73c5fefc842b8d66df36c4eb4b3507

TODO:

Implements the step decision of Algorithm 1 from "Fair Resource Allocation
in Multi-Task Learning" (https://arxiv.org/pdf/2402.15638). The alpha=0
case is handled as a closed-form special case returning uniform weights,
matching the paper's statement that w_i=1 for all i when alpha=0.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ValerianRey ValerianRey requested review from a team and PierreQuinton as code owners May 18, 2026 17:17
@ValerianRey ValerianRey added cc: feat Conventional commit type for new features. package: aggregation labels May 18, 2026
@ValerianRey ValerianRey changed the title feat(aggregation): Add FairGrad and FairGradWeighting feat(aggregation): Add FairGrad May 18, 2026
ValerianRey and others added 5 commits May 18, 2026 19:29
…e except

- Short-circuit forward() when alpha=0, returning uniform weights per the
  paper (Section 3: "w_i=1 for all i when alpha=0"), avoiding division by zero
- Remove the ValueError catch around least_squares: huge-gramian overflow is
  not a case we need to handle gracefully
- Allow all real-valued alpha (negative alpha is valid per the paper)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@PierreQuinton PierreQuinton left a comment

Choose a reason for hiding this comment

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

I didn't review the tests.

Comment thread src/torchjd/aggregation/_fairgrad.py
Comment thread src/torchjd/aggregation/_fairgrad.py Outdated
Comment thread src/torchjd/aggregation/_fairgrad.py Outdated
Comment thread src/torchjd/aggregation/_fairgrad.py Outdated
@ValerianRey ValerianRey merged commit cb1c680 into main May 20, 2026
15 checks passed
@ValerianRey ValerianRey deleted the feat/fairgrad branch May 20, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc: feat Conventional commit type for new features. package: aggregation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants