Fix transpose in sparse Newton Hessian assembly#1405
Merged
adenzler-nvidia merged 1 commit intoJun 3, 2026
Merged
Conversation
_update_gradient_init_h_sparse wrote the mass matrix into the lower triangle of h via M_elemid[i, j], which is only populated where the column is an ancestor of the row (the lower triangle). The constraint term from _JTDAJ_sparse and the Cholesky factorization both use the upper triangle, so the upper-triangle Hessian was assembled without the mass matrix, producing an incorrect Newton Hessian. Transpose the lookup to M_elemid[j, i] so M lands in the upper triangle, and skip writing the lower triangle entirely since it is never read. The solver still converges with the wrong Hessian (Newton degrades toward gradient descent), so existing tests pass; the symptom is a large performance regression on the sparse path.
erikfrey
approved these changes
Jun 3, 2026
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.
_update_gradient_init_h_sparse(added in #1356) writes the mass matrix intohviaM_elemid[i, j].M_elemid[row, col]is only populated where the column is an ancestor of the row, i.e. the lower triangle. The constraint term from_JTDAJ_sparseand the Cholesky factorization both operate on the upper triangle, so the upper-triangle Hessian was assembled without the mass matrix — an incorrect Newton Hessian on the sparse path.This transposes the lookup to
M_elemid[j, i]soMlands in the upper triangle, and skips writing the lower triangle since it is never read.The solver still converges with the wrong Hessian (Newton degrades toward gradient descent), so existing tests pass and the only visible symptom is a large performance regression on the sparse Newton path (e.g.
three_humanoids). With the fix, performance returns to the level intended by #1356.