Repository navigation
fix(solvers): correct reverse rules of the projected damage solve - #14
Merged
Merged
Conversation
The damage update solves A(H) d_unc = b(H) and projects the result, d = clamp(max(d_unc, d_prev), 0, 1). Three defects affected gradients through this step: - the history pullback evaluated dA/dH at the projected damage instead of the unconstrained solution d_unc; - the history-only route returned no gradient for d_prev, so nodes held at their previous damage did not propagate gradients to earlier steps; - with fixed material values the solve was dispatched to the forward-only path, detaching the damage from H and d_prev. The forward solution is unchanged. Gradients with respect to Gc and l0 were already evaluated at d_unc and are unaffected. Adds three regression tests: the history gradient against a dense solve-and-project reference and central differences with the projection active, the d_prev gradient on the irreversibility branch, and the history gradient with fixed material values on a small mesh. All three fail on the previous implementation.
… damage
The unconstrained-damage history pullback is derived for solve-then-clamp
routes ('post_clamp', 'direct'). The projected-CG route solves a
bound-constrained problem whose exact sensitivity needs a reduced
active-set system, which is not implemented. On an AT1 projected-CG test
case the unconstrained pullback moved the gradient further from central
differences (relative error 0.66 against 0.56 with the projected damage),
so that route keeps the projected damage. The d_prev gradient and the
dispatch correction apply to all routes.
The fixed-material dispatch test meshed a SENT plate with gmsh, which fails to load on the Ubuntu CI runners (missing libGLU). It now uses a structured unit-square T3 mesh from FEMMesh.from_tensors; the test still fails on the previous code at the intended assertion.
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.
Summary
The damage update solves
A(H) d_unc = b(H)and enforces the boundsd_prev <= d <= 1. Three defects affected reverse-mode gradients through this step:bounds_method='post_clamp'or'direct'),dA/dHwas evaluated at the projected damage instead of the unconstrained solutiond_unc(_AdjointDamageSolve,_AdjointDamageSolveScalar,_AdjointDamageSolveField).d_prevgradient. The history-only route returnedNoneford_prev, so nodes held at their previous damage (irreversibility branch) did not pass gradients to earlier steps.Gc/l0passed withoutrequires_grad), the solve was dispatched to the forward-only path even whenHord_prevrequired gradients.Forward solutions are unchanged. The direct
Gc/l0pullback term was already evaluated atd_uncand is unchanged, but total multi-step gradients with respect toGc,l0or other parameters change wherever the history ord_prevpaths contribute.Projected CG (
bounds_method='projected_cg'). This route solves a bound-constrained problem whose exact sensitivity needs a reduced active-set system, which is not implemented. On an AT1 projected-CG case the unconstrained pullback moved the gradient further from central differences (relative error 0.66 against 0.56), so this route keeps the projected damage in the history pullback; corrections 2 and 3 apply to all routes. Gradients through projected-CG solves remain approximate.Tests
New
tests/test_damage_adjoint_regressions.py:d_prevgradient on the irreversibility branch;All five test cases fail on the current
mainand pass with this change. Full suite locally: 472 passed.