Skip to content

Fix transpose in sparse Newton Hessian assembly#1405

Merged
adenzler-nvidia merged 1 commit into
google-deepmind:mainfrom
adenzler-nvidia:adenzler/fix-init-h-transpose
Jun 3, 2026
Merged

Fix transpose in sparse Newton Hessian assembly#1405
adenzler-nvidia merged 1 commit into
google-deepmind:mainfrom
adenzler-nvidia:adenzler/fix-init-h-transpose

Conversation

@adenzler-nvidia

Copy link
Copy Markdown
Collaborator

_update_gradient_init_h_sparse (added in #1356) writes the mass matrix into h via M_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_sparse and 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] so M lands 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.

_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.
@adenzler-nvidia adenzler-nvidia merged commit a5e23c3 into google-deepmind:main Jun 3, 2026
14 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.

2 participants