Repository navigation
Conversation
Repeated eigenvalues make reciprocal gaps singular even when the eigenvector adjoint is zero. This contaminates eigenvalue-only losses, unrelated tape diagnostics and masked shared parameters. Eigenvalue-only derivatives do not require reciprocal gaps, and a fully unused decomposition must leave accumulated gradients intact. Signed-off-by: Moritz von Büren <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthrough
Changeseig3 Gradient Handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~15 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to This fix stops NaN gradients from wp.eig3() when eigenvectors receive no gradient and eigenvalues repeat. Regression tests are included. GPU testing was not performed, so run CI on CUDA before merging. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
|
Thanks @moritzvii for the contribution and the additional reproducer. #2010 was fixed separately in 109b6fa. The upstream fix covers eigenvalue-only losses and prevents unused |
What problem are you trying to solve?
Closes #2010.
At repeated eigenvalues,
wp.eig3()can produce NaN input gradients even when the loss uses only eigenvalues. An unrelated eigendecomposition diagnostic recorded on the same tape can also contaminate the gradient oftrace(A). Likewise, a zero-seeded sample can poison a shared parameter's gradient and make an otherwise valid optimization step NaN.Standalone reproducers demonstrate the unrelated diagnostic and masked shared parameter cases.
What does this change?
When
adj_Qis zero,adj_eig3accumulates the eigenvalue contributionQ diag(adj_d) Qᵀwithout forming reciprocal eigenvalue gaps. When both output adjoints are zero, it returns without modifying the accumulated input gradient.Add regression tests for eigenvalue sum and squared sum, accumulation with a direct trace gradient, unrelated diagnostics and masked shared parameters. Cover repeated eigenvalues in all pair positions, isotropic, zero, negative and rotated matrices, with separated-eigenvalue controls across
float16,float32andfloat64. Include a changelog entry.Existing pull requests
Validation
[0,1]and[0,0].test_mat.py, and applicable pre-commit checks passed. The tests are registered for CPU and CUDA devices across the three floating-point types.The CPU build and test results predate the latest base update; the fix itself is unchanged. They have not been rerun on the current base.
Test command:
Checklist
mainand contains one commit, unless a maintainer agreed to keep the change as multiple commits.+prefix only for changes that do not require a GitHub issue.Summary by CodeRabbit
Bug Fixes
wp.eig3()at repeated eigenvalues when eigenvector gradients are zero, including cases involving separate tape diagnostics and shared parameters with zero-seeded samples.Tests