Individual envs are not deterministic?

Hello, I have started using Isaac Gym recently and noticed that while the execution results are generally consistent across different sessions, each environment does not seem to be consistent with each other.

While testing some basic panda arm motions, the arm would not move in the exact same way, despite setting the following to ensure that all randomness from numpy/torch are removed:

np.random.seed(42)
torch.manual_seed(42)

torch.set_printoptions(precision=4, sci_mode=False)
os.environ[‘CUBLAS_WORKSPACE_CONFIG’] = ‘:4096:8’
torch.use_deterministic_algorithms(True)

I then checked some of the existing examples, using the 1080_balls_of_solitude.py provided by IsaacGym and noticed that the balls do not fall in the exact same way either across environments. The code is the exact same as provided, except that I increase the env_spacing to a higher value so we can observe the ball falling more easily.

Changing the pipeline and sim device to cpu also resulted in a similar situation.
Is there a reason why the behaviour is not deterministic, and if so, how can it be resolved?

Hi @klinzw,

Since physics simulation uses floating point numbers under the hood, there will always be small differences between the simulation of any environment that’s in a different position in the world.

If instead you set env_spacing to 0, and run with two environments you can see that the simulation is the same by showing only the actors from env 0 or env 1:

image

As it turns out, in doing this test with more environments (ie: 36), the result is not always identical. There may be some other issues at play that we’ll need to get feedback from the physics team to better understand.

In the meantime however, your results are what we expect. Repeated simulation of the same set of environments from a fixed seed should provide deterministic simulation of the overall system however.

Take care,
-Gav

Hi @gstate, thanks for your answer. I have a follow up question: Is the PhysX meant to be non-deterministic? We are performing a robot arm pick and place action with a Panda Arm, with all the variables being fixed (bowl position, grasp location, robot trajectory)

We find that this does not always hold, as when the arm grasps the bowl, it shakes violently and eventually flies out of the gripper at an alarming speed, and at entirely random angles across different sessions of the same set of environments. We suspect it is the physics at play here as every other aspect of the experiment is the same and would like to check if this is supposed to happen.

Do you have any solution for minimizing object shaking unnaturally when gripped?