Skip to content

[Bug Report] axis_angle_from_quat produces NaN gradients at identity rotations #9250

Backlog

Description

@sylvesterkaczmarek

Describe the bug

axis_angle_from_quat() returns the correct zero rotation vector for an identity quaternion, but its backward pass produces NaNs. The unselected exact-ratio branch of torch.where evaluates a zero denominator even when the Taylor approximation is selected.

Steps to reproduce

import torch
from isaaclab.utils.math import axis_angle_from_quat

q = torch.tensor([0., 0., 0., 1.], requires_grad=True)
print(torch.autograd.grad(axis_angle_from_quat(q).sum(), q)[0])

Expected: [2., 2., 2., 0.]. Actual: NaN gradients.

System Info

main at ebf162a, macOS ARM64, PyTorch 2.12.0, CPU. Isaac Sim is not required.

Additional context

Protect the inactive exact-ratio branch from division by zero while preserving the existing Taylor approximation and forward values. The regression covers both quaternion signs of identity and fails before the fix. All 123 available math tests passed; three existing CUDA-only cases were skipped.

Activity

  1. RandomOakForest commented on Dec 2, 2026

    @RandomOakForest
    Collaborator

    Thanks, I saw the NaN gradients at identity on main and #9251 gives [2, 2, 2, 0].

  2. added
    bug
    on Dec 2, 2026
  3. sylvesterkaczmarek commented on Dec 2, 2026

    @sylvesterkaczmarek
    ContributorAuthor

    Thanks, @RandomOakForest, for confirming the gradient values. I reran the full math suite on the updated #9251 patch: 123 tests passed on CPU and the three CUDA-only cases were skipped. The identity regression is now kitless, the denominator fallback uses a scalar, and the final formatting correction is pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions