Make all fields of simulator.JaxSim
static excluding SimulatorData
#55
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With @flferretti, we noticed the occurrence of trace leaks in a jitted context of a parallel simulation on GPUs. It turns out that the leak was caused by the following line:
jaxsim/src/jaxsim/simulation/simulator.py
Line 359 in 6397508
For some reason, jax detects a leak in this operation.
Converting
JaxSim.step_size_ns
to a static attribute was the most straightforward solution. The pay to price, this time, is losing the possibility to perform a parallel simulation whose models are integrated using different step sizes, that is regardless an edge case not so common. If needed, we can try to fix it in the future, what matters now is to simulate a large batch of models all together on hardware accelerators.After this change, all attributes of
JaxSim
are marked asStatic
, with the exception ofJaxSim.data
that now contains the only mutable information — the real simulator state. It makes clear what can be changed during runtime —dynamically, w/o triggering recompilations— and what not.