Skip to content
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

UserObjectsTest.Inertial fails #2515

Open
2 tasks done
Flamefire opened this issue Mar 20, 2025 · 1 comment
Open
2 tasks done

UserObjectsTest.Inertial fails #2515

Flamefire opened this issue Mar 20, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@Flamefire
Copy link

Intro

Hi!

I am an Admin at the HPC center of ZIH TU-Dresden, I provide MuJoCo for our researchers

My setup

Mujoco 3.3.0, on Intel Sapphire Rapids and AMD Rome

GCC 13.2

What's happening? What did you expect?

Running ctest after the build shows a failure in UserObjectsTest.Inertial which I think is "just" an overly strict comparision. It looks like:

[ RUN      ] UserObjectsTest.Inertial
/dev/shm//mujoco-3.3.0/test/user/user_objects_test.cc:2511: Failure
Expected equality of these values:
  AsVector(m->body_iquat+4, 4)
    Which is: { -0.51924266463036339, 0.37105264616146549, 0.19689792716967142, -0.74427024344684178 }
  AsVector(quat, 4)
    Which is: { -0.5192426646303635, 0.37105264616146549, 0.19689792716967142, -0.74427024344684178 }

It looks like it compares floating point numbers for equality which is error-prone given the differing rounding behavior on different architectures.

Was this observed already somewhere else? Can it be changed to be more reliable?

I do get the exact same values (to the printed permission at least) on 2 different systems with otherwise identical software. So it doesn't look like a purely hardware-specific issue.

Steps for reproduction

  • mkdir build && cd build && cmake ..
  • make -j user_objects_test && (cd ../test/ && /dev/shm/mujoco-3.3.0/build/bin/user_objects_test )

Minimal model for reproduction

No response

Code required for reproduction

No response

Confirmations

@Flamefire Flamefire added the bug Something isn't working label Mar 20, 2025
@Flamefire
Copy link
Author

Flamefire commented Mar 20, 2025

I traced that to the function mju_euler2Quat in engine_util_spatial.c yielding those different results compared to user_object.cc

The issue seems to be caused by compiling one as C++ and the other as C which seem to have slightly different rounding behavior

Edit: I found a different vectorization in mjuu_mulquat compared to mju_mulQuat (besides the former doing a superflous normalization so the implementation and test code aren't fully equal to begin with, but that doesn't matter here as the same issue holds when the additional code is removed) The former is C++ and used from user_objects, the latter is in C. Putting the exact same code as input to gcc and g++ yields a slight difference that might explain the different results. See https://godbolt.org/z/rneTbfxas

This is a different default in GCC from std=c11 compared to std=c++11.

Maybe the C/C++ GNU_EXTENSIONS should be allowed (by the CMakeLists.txt)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant