Skip to content

Note what gradients through history need - #108

Merged
mattjolley merged 4 commits into
mainfrom
mattjolley/history-gradients-note
Dec 3, 2026
Merged

mattjolley merged 4 commits into
mainfrom
mattjolley/history-gradients-note

Conversation

@mattjolley

Copy link
Copy Markdown
Contributor

This pull request sits on #107 (mattjolley/static-after-dynamic; below it are #105, #104 and #103, all merged) and is to be merged after it. Until those are merged, the diff here also shows their commits; the two commits of this pull request are the last two. It follows them because it names what they build (the multipliers of the augmented constraints, the velocity a static step keeps).

What does this change, and why?

A design note and no code: section 14 of docs/design/sensitivity.md, "Gradients through history". One file, 73 lines.

"History" there is anything a term keeps from one converged state to the next. The section lists what history this code has and where it lives (the attachment of a sticky node, the anchor of a tied interface, the multipliers of an augmented constraint, the activation distance of a node distance, the rotation of a beam's sections, the velocity a static step keeps after a dynamic one, the internal variables of a material); writes the reverse sweep with one more adjoint for the history; says what that needs of the State and of the terms; and sorts the cases into three kinds by what a gradient means for each:

  • a function of earlier converged states: differentiable, the sweep gives the derivative of the run;
  • an event at a converged state (a tied anchor): the facet is held, and the anchor's position can be on the tape of the step of the event or held as a constant, with the limit said;
  • a function of the Newton iterates (a sticky attachment, a multiplier summed over augmentations, a beam's rotations): what a sweep returns is the derivative of the model with the history as found, which is not the derivative of the run.

It ends with an order of work with the check for each piece, and three decision points for MJ, Steve and the Warp team: S11, where history lives (in the State, or in the terms with the State holding references); S12, whether to return a gradient where the run depends on its iterates, said as such, or to refuse; S13, whether an anchor's own position is a constant of the sweep or on the tape.

The second commit brings the section up to what main gained the same day: FEBio's viscoelastic with history at the integration points (#98) and the reverse sweep through it (#99). For that one kind of history the split the section asks for exists, with the arrays owned by the term and referenced by the State, and the sweep is built; what stays design is the rest of the table (anchors, multipliers, the kept velocity) and S11 to S13.

Validation

  • Tests added or changed: none. Documents only.
  • FEBio reference (input file, quantity compared, tolerance, FEBio version), or N/A: N/A.
  • Devices the full tier ran on (CPU, and the GPU model if CUDA; say so clearly if no GPU was used): no code changes, so the runs are those of the line below it, at this branch's tip cb409d5 with Warp 1.20.0. The test of the notes' links (tests/test_docs_links.py) passes. Quick tier of the whole repository: CPU, 1,151 tests, none failed (89 skipped); Tesla P100 (cuDSS; the versions of the gpu extra), 1,151 tests, one failure (80 skipped), which is present on unchanged main at 25b5aac on the same GPU and is not of this pull request: tests/test_history_adjoint.py, ForwardSweep.test_the_jacobian_of_a_static_run_goes_through_the_steps (from History in the forward sweep #101; it passes on CPU). Not run: the full tier of the whole repository.

Checklist

  • I have read the contributing guide.
  • uvx pre-commit run --all-files passes. (Run on the one file of this change: passes.)
  • The full tier passes: FEBIO_WARP_TEST_LEVEL=full uv run -m unittest discover -s tests, and with FEBIO_WARP_TEST_DEVICE=cuda:0 for code that runs on the device. (Not run in full; documents only.)
  • If this changes what a design note says, the note is updated; open design questions are in its decision points, not only in this pull request.
  • The change is focused, and every commit is signed off (git commit -s).

🤖 Generated with Claude Code

mattjolley and others added 4 commits December 2, 2026 17:27
A static step that follows a dynamic one was refused (decision ST6 of
the steps note). Handoff K asks for it, as FEBio does it.

FESolidSolver2 tests the analysis type where the mass and the inertial
forces enter and where velocity and acceleration follow the
displacement, but not in PrepStep: its predictor runs in every time
step of a static step too, with nothing to correct it. So the nodes
keep a velocity and an acceleration (with the default parameters the
velocity changes sign in every time step), and a mass damping load of
the static step, which FEBio adds in every analysis type, reads the
velocity of the material points: the one the dynamic step ended with on
a solid or a shell, the nodal one on a three-field solid or a truss. A
dynamic step after the static one starts from what it left.

The State of such a time step carries these, the system applies the
damping force through its mass blocks, the coverage report says what
happens, and gradients through such a step are refused. A model with
beams is refused, whose rotations have a predictor of their own.

Against FEBio 4.13.0 at e4df3f8, on CPU and on a Tesla P100 with cuDSS:
three generated inputs (a shell patch, a three-field hex8, a block on
trusses in dynamic, static and dynamic steps) on FEBio's iterations in
every time step, with displacement, velocity, acceleration and stress
to 3e-12 (references/small_problems/generate_static_after_dynamic.py).

tests/test_activity.py asserted the refusal and now asserts the report.

After a dynamic step with alpha_f below 1 the velocity kept for a solid
or a shell is the interpolated one of the last dynamic update
(State.domain_v): on the shell patch with rhoi 0.5 in its dynamic step
the static states are then FEBio's to 1e-12 and its 344 iterations are
reproduced (a run made once, not a stored case).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
Main gained history at the integration points with FEBio's viscoelastic
material (pull request 98). New input ve_block_dynamic_then_static: the
viscoelastic block under a held force through 6 dynamic time steps,
which end with the block in motion, and 6 static ones. FEBio 4.13.0 at
e4df3f8 takes 18 and 22 iterations, this code the same in every time
step, with displacements and stresses to 2e-12 on CPU and on a GPU.

No code was needed: the domain commits its history at the end of every
converged time step of either kind of step, and the static predictor
does not touch it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
Design only. The adjoint refuses every term that keeps something from
one converged state to the next: the attachments of sticky contact, the
multipliers of an augmented constraint, a beam's rotations. Handoff K
asks what it would take to carry such history in the State, first for
the anchors of a tied or sticky interface and then for a material with
internal variables.

Section 14 of the sensitivity note lists the history there is, the
reverse sweep with one more adjoint for it, what that needs of the State
and of the terms, and which gradients are the derivative of the run and
which are not because the run depends on its iterates. Three decisions
are put for MJ (S11 to S13).

The section names inputs and a section of the steps note that are on
the branches of K3-2 and K3-3 and not on main at this date.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
Main has a first material with history since pull request 98, with a
committed and a trial array in the brick domain and the pair held by
every converged State, and the reverse sweep through it since pull
request 99. The note said such history was not built for solids and
shells. What stays design in section 14 is the rest: anchors,
multipliers, the kept velocity. No code.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
@mattjolley mattjolley mentioned this pull request Dec 3, 2026
3 of 5 tasks
@mattjolley
mattjolley merged commit b2ee44d into main Dec 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant