Skip to content

feat(aggregation): Add GradVac aggregator#638

Open
rkhosrowshahi wants to merge 1 commit intoSimplexLab:mainfrom
rkhosrowshahi:feature/gradvac
Open

feat(aggregation): Add GradVac aggregator#638
rkhosrowshahi wants to merge 1 commit intoSimplexLab:mainfrom
rkhosrowshahi:feature/gradvac

Conversation

@rkhosrowshahi
Copy link
Copy Markdown
Contributor

@rkhosrowshahi rkhosrowshahi commented Apr 9, 2026

Summary

Adds Gradient Vaccine (GradVac) from ICLR 2021 as a stateful Aggregator on the full task Jacobian.

Behavior

  • Per-block cosine statistics and EMA targets \bar{\rho}, with the closed-form vaccine update when \rho < \bar{\rho}.
  • group_type: 0 whole model (single block); 1 all_layer via encoder (leaf modules with parameters); 2 all_matrix via shared_params (one block per tensor, iteration order = Jacobian column order).
  • DEFAULT_GRADVAC_EPS and configurable eps (constructor + mutable attribute).
  • Autogram not supported (needs full rows and per-block inner products). Task shuffle uses torch.randperm; use torch.manual_seed for reproducibility.

Files

  • src/torchjd/aggregation/_gradvac.py, export in __init__.py
  • docs/source/docs/aggregation/gradvac.rst + index toctree
  • tests/unit/aggregation/test_gradvac.py

Verification

  • ruff format / ruff check on touched paths
  • ty check on _gradvac.py
  • pytest tests/unit/aggregation/test_gradvac.py tests/unit/aggregation/test_values.py -W error
  • Sphinx HTML build for docs

Implement Gradient Vaccine (ICLR 2021) as a stateful Jacobian aggregator.
Support group_type 0 (whole model), 1 (all_layer via encoder), and 2
(all_matrix via shared_params), with DEFAULT_GRADVAC_EPS and configurable
eps. Add Sphinx page and unit tests. Autogram is not supported; use
torch.manual_seed for reproducible task shuffle order.

Made-with: Cursor
@ValerianRey ValerianRey added cc: feat Conventional commit type for new features. package: aggregation labels Apr 9, 2026
@rkhosrowshahi
Copy link
Copy Markdown
Contributor Author

Hey @ValerianRey :
Could you please add cc: feat and package: aggregation labels to this PR?

@github-actions github-actions bot changed the title feat(aggregation): add GradVac aggregator feat(aggregation): Add GradVac aggregator Apr 9, 2026
@ValerianRey
Copy link
Copy Markdown
Contributor

I think the link check action failed because of bad luck, re-running the job fixed it.

@ValerianRey
Copy link
Copy Markdown
Contributor

Thanks a lot for the PR, I'll look at it tonight or tomorrow!

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