[Feature]: Function to save/load state of the simulator in/from file or scene.to_dict()

Author: mikel-zhobroCreated Feb 12, 2025Updated Aug 30, 2026
LabelsenhancementP1

What feature or enhancement are you proposing?

Directly trying to pickle the state fails since the simulation contains Taichi objects (like fields or expressions) that cannot be directly pickled.

python
...
state = scene.get_state()

import pickle
# save states
with open("state.pkl", "wb") as f:
    pickle.dump(state, f)

throws

bash
Traceback (most recent call last):
  File "<string>", line 22, in <module>
TypeError: cannot pickle 'taichi._lib.core.taichi_python.Expr' object

Motivation

Motivation: create dataset

I want to split simulation from rendering. I.e. simulate once and only save the states. And render offline.

Potential Benefit

This would allow the user to simulate once and render offline.

What is the expected outcome of the implementation work?

  • provide function save_state()
  • provide function load_state()

Additional information

No response

Source: Genesis-Embodied-AI/genesis-world