Skip to content

refactor!: Remove generalized gramians#692

Draft
ValerianRey wants to merge 1 commit into
mainfrom
remove-generalized-gramians
Draft

refactor!: Remove generalized gramians#692
ValerianRey wants to merge 1 commit into
mainfrom
remove-generalized-gramians

Conversation

@ValerianRey
Copy link
Copy Markdown
Contributor

Closes #690.

Summary

  • Engine.compute_gramian now always returns a flat [m, m] PSD matrix where m = output.numel(), regardless of the output shape
  • Removed PSDTensor, GeneralizedWeighting, and Flattening — they are no longer needed
  • Updated the IWMTL example to use UPGradWeighting directly and reshape the weights before calling backward
  • Added a migration guide in CHANGELOG.md

Migration guide

# Before
weighting = Flattening(UPGradWeighting())
gramian = engine.compute_gramian(losses)  # shape: [m1, m2, m2, m1]
weights = weighting(gramian)              # shape: [m1, m2]
losses.backward(weights)

# After
weighting = UPGradWeighting()
gramian = engine.compute_gramian(losses)           # shape: [m1*m2, m1*m2]
weights = weighting(gramian).reshape(losses.shape) # shape: [m1, m2]
losses.backward(weights)

🤖 Generated with Claude Code

Simplify `Engine.compute_gramian` to always return a flat `[m, m]` PSD matrix
where `m = output.numel()`, removing the concepts of generalized Gramians,
`PSDTensor`, `GeneralizedWeighting`, and `Flattening`.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@ValerianRey ValerianRey added package: aggregation cc: refactor Conventional commit type for any refactoring, not user-facing, and not typing or perf improvements breaking-change This PR introduces a breaking change. package: autogram labels May 20, 2026
@github-actions github-actions Bot changed the title feat(autogram): Remove generalized gramians refactor!: Remove generalized gramians May 20, 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: autogram

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove generalized gramians

1 participant