Skip to content

Make JacobianType.auto switch to sparse in put_model #234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

adenzler-nvidia
Copy link
Collaborator

This is no solution for #88 - but I think we should at least switch to sparse automatically if the user has set the option to auto.

@adenzler-nvidia adenzler-nvidia requested a review from thowell May 9, 2025 14:05
@@ -64,7 +64,7 @@ def put_model(mjm: mujoco.MjModel) -> types.Model:

# TODO(team): remove after solver._update_gradient for Newton solver utilizes tile operations for islands
nv_max = 60
if mjm.nv > nv_max and (not mjm.opt.jacobian == mujoco.mjtJacobian.mjJAC_SPARSE):
if mjm.nv > nv_max and (not mjm.opt.jacobian >= int(mujoco.mjtJacobian.mjJAC_SPARSE)):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like Model.is_sparse is set utilizing mujoco.mj_isSparse

is_sparse=mujoco.mj_isSparse(mjm),

so the mjJAC_AUTO case should be handled by the is_sparse field.

can we make the check here if mjm.nv > nv_max and mjm.opt.jacobian == mujoco.mjtJacobian.mjJAC_DENSE?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we can do that, it's just some boolean algebra. I agree it's clearer. Thanks.

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