Repository navigation
Allow auto-registration to fall back to function outputs when no loss tags are registered. - #423
Merged
Merged
Conversation
copybara-service
Bot
force-pushed
the
test_982154613
branch
2 times, most recently
from
September 17, 2026 21:45
c3a9381 to
bae96ed
Compare
copybara-service
Bot
force-pushed
the
test_982154613
branch
2 times, most recently
from
September 18, 2026 16:18
640f033 to
45f96c2
Compare
… tags are registered. Currently, KFAC graph matching and curvature estimation rely on registered LossTags as anchor points for backward reachability pruning and for computing loss VJPs. However, certain estimation modes—specifically "fisher_empirical_direct" and "fisher_empirical_direct_synced"—do not require loss VJPs and only need layer tags to compute empirical Fisher blocks directly from gradients. This change: 1. Adds `fallback_to_outputs_if_no_losses` to `auto_register_tags` and `make_jax_graph`. When enabled and no LossTags are present, graph reachability pruning anchors to the primary function output (`outvars[:1]`), ignoring auxiliary outputs (`aux`). 2. Updates `tracer.py` to allow tracing without LossTags when `fallback_to_outputs_if_no_losses` is specified in `auto_registration_kwargs`. 3. Defers `_compute_losses_vjp()` in `BlockDiagonalCurvature.update_curvature_matrix_estimate()` to only the specific estimation modes that require it (`fisher_gradients`, `fisher_empirical`, curvature propagation, and exact modes), raising a descriptive ValueError if no loss tags are found for those modes. 4. Adds unit tests in `test_graph_matcher.py` and `test_estimator.py` covering fallback auto-registration, curvature updates, unsupported mode guards, and end-to-end Optimizer execution. PiperOrigin-RevId: 983909653
copybara-service
Bot
force-pushed
the
test_982154613
branch
from
September 18, 2026 16:38
45f96c2 to
086619d
Compare
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.
Allow auto-registration to fall back to function outputs when no loss tags are registered.
Currently, KFAC graph matching and curvature estimation rely on registered LossTags as anchor points for backward reachability pruning and for computing loss VJPs. However, certain estimation modes—specifically "fisher_empirical_direct" and "fisher_empirical_direct_synced"—do not require loss VJPs and only need layer tags to compute empirical Fisher blocks directly from gradients.
This change:
fallback_to_outputs_if_no_lossestoauto_register_tagsandmake_jax_graph. When enabled and no LossTags are present, graph reachability pruning anchors to the primary function output (outvars[:1]), ignoring auxiliary outputs (aux).tracer.pyto allow tracing without LossTags whenfallback_to_outputs_if_no_lossesis specified inauto_registration_kwargs._compute_losses_vjp()inBlockDiagonalCurvature.update_curvature_matrix_estimate()to only the specific estimation modes that require it (fisher_gradients,fisher_empirical, curvature propagation, and exact modes), raising a descriptive ValueError if no loss tags are found for those modes.test_graph_matcher.pyandtest_estimator.pycovering fallback auto-registration, curvature updates, unsupported mode guards, and end-to-end Optimizer execution.