The model's performance dropped significantly when converting the model's checkpoint from the JAX version to the PyTorch version
I trained a JAX version of the model following the tutorial and achieved very good results. But when I converted the model checkpoint to the PyTorch version, the model's performance became very strange, and the robotic arm's movements became incomprehensible. The script I used is “examples/convert_jax_model_to_pytorch.py”. And because my GPU is NVIDIA GeForce RTX 5090, I upgrade torch version from 2.7 to 2.8. Besides, I ran into the same problem as https://github.com/Physical-Intelligence/openpi/issues/654, I solved this problem by adding TORCHINDUCTOR_AUTOTUNE=0 before "uv run scripts/serve_policy.py". So, at which point in this whole process might something have gone wrong? I hope to get an answer, thank you.
Hello, after converting the pi05_base jax model to PyTorch, I ran the following inference.py script:
from openpi.training import config as _config
from openpi.policies import policy_config
from openpi.shared import download
import torch
config = _config.get_config("pi05_droid")
checkpoint_dir = "/home/user/.cache/openpi/openpi-assets/checkpoints/pytorch_ckpt/pi05_base"
policy = policy_config.create_trained_policy(config, checkpoint_dir)
example = {
"observation/exterior_image_1_left": torch.randint(0, 256, (1, 3, 224, 224), dtype=torch.uint8),
"prompt": "pick up the fork"
}
action_chunk = policy.infer(example)["actions"]
However, I encountered an error: Invalid key(s) in state_dict: "action_in_proj.bias", "action_in_proj.weight", "action_out_proj.bias", *****.
Have you ever encountered this error? If you know the solution, could you please let me know? Thank you!
The dtypes of these parameter tensors don’t match the model’s precision setup. The base model uses mixed precision (bfloat16 + float32). You can try adjusting the strict argument when loading the checkpoint (e.g., set strict=False) to bypass mismatched keys first and then handle them accordingly.
Hello, after converting the pi05_base jax model to PyTorch, I ran the following inference.py script:
from openpi.training import config as _config from openpi.policies import policy_config from openpi.shared import download import torch config = _config.get_config("pi05_droid") checkpoint_dir = "/home/user/.cache/openpi/openpi-assets/checkpoints/pytorch_ckpt/pi05_base" policy = policy_config.create_trained_policy(config, checkpoint_dir) example = { "observation/exterior_image_1_left": torch.randint(0, 256, (1, 3, 224, 224), dtype=torch.uint8), "prompt": "pick up the fork" } action_chunk = policy.infer(example)["actions"]However, I encountered an error: Invalid key(s) in state_dict: "action_in_proj.bias", "action_in_proj.weight", "action_out_proj.bias", *****.
Have you ever encountered this error? If you know the solution, could you please let me know? Thank you!
Sorry, I haven't encountered this problem before. But it seems there are many issues related to this question; you can try looking for answers among them. Good luck :)
Hello, I was wondering if you’ve found any solution regarding the performance drop after converting from JAX to PyTorch. I’m experiencing a similar issue — I started with the Pi-0 base model, converted it from JAX to PyTorch, and then fine-tuned it on a single LIBERO task. However, during evaluation, the robot’s movements become quite unstable and hard to interpret.
Do you think this is purely due to the JAX-to-PyTorch conversion, or could there be other factors involved?
这些参数张量的d类型与模型的精度设置不匹配。基础型号采用混合精度(bfloat16 + float32)。你可以尝试在加载检查点时调整严格参数(例如设置 strict=False),先绕过不匹配的键,然后相应处理。
accordingly
Hello, have you achieved similar results to those obtained with JAX using the Torch version of the model? Could you please tell me what specific changes you made to the Torch version of the code. Or where exactly is the problem with the torch code Thank you very much. This will be of great help to me