Skip to content

feat: rewrite Pi0, enable loading pretrained weights and validate the performance#237

Merged
kwangneuraco merged 1 commit intomainfrom
feat/add_pi0
Feb 4, 2026
Merged

feat: rewrite Pi0, enable loading pretrained weights and validate the performance#237
kwangneuraco merged 1 commit intomainfrom
feat/add_pi0

Conversation

@kwangneuraco
Copy link
Contributor

@kwangneuraco kwangneuraco commented Jan 11, 2026

Features

This is a total rewrite of PI0 based on the official code from Physical Intelligence https://github.com/Physical-Intelligence/openpi. The official code has a lot of difference with our previous version ( How VLM and action expert interact, learning scheduler, gradient checkpoint to save VRAM etc) so I did a total rewrite based on the official code. At the same time I made the code interface same as our other algorithms and made several improvements.

Main features from the original code beside the main pi0 model structure:

  • Modification of transformers library and gemma model (transformers_replace and gemma_torch.py)
  • Can load pretrained model and do finetune
  • Gradient checkpoint to save VRAM (finetuning full model only needs around 14 GB VRAM, 4090 can do it)

Features I added:

  • Add patching code at __init__.py to automatically replace transformers library, instead of manually copy and paste as suggested by PI
  • Modified code and updated the library version in requirements.txt to use numpy >= 2.0 instead of 1.0 from the official code
  • Add flags so we can only fineture action experts, finetune action_experts + vision backbone (most cases lauguage part is not needed for finetuning) and full parameter finetune.
    • Use torch.compile() for inference speedup
  • Some libraries requires specific version (transformers etc) so added them in requirements.txt

Questions from me:

  • As PI0 model is complex, I hide most model code from pi0.py and put it in modlue.py and created a class call PI0Policy and PI0PolicyConfig. This makes the code cleaner and better structured (otherwise pi0.py may have 2k lines) but created a bit of repeated code.
  • As we discussed PI05 will be separated from PI0 (which i agree, because users can modify pi0 without affecting any pi05 and vice versa). So i put trainsformers_replace and gemma_pytorch.py inside PI0, although these parts are same for PI05.

Validation

Finetune with vx300 for 3 epochs and achieves 70% success rate

Ticket

https://neuracore.atlassian.net/browse/NCRL-33

@kwangneuraco kwangneuraco added the version:minor non-breaking feature updates, new functions or endpoints label Jan 12, 2026
stepjam

This comment was marked as resolved.

@stepjam stepjam removed the request for review from ypang-neuraco January 16, 2026 12:36
@github-actions
Copy link
Contributor

Consider updating changelogs/pending-changelog.md with a summary of this change for the release notes. This is optional and non-blocking.

@kwangneuraco kwangneuraco changed the title Rewrite Pi0, enable loading pretrained weights and validate the performance feat: rewrite Pi0, enable loading pretrained weights and validate the performance Jan 21, 2026
@kwangneuraco kwangneuraco force-pushed the feat/add_pi0 branch 3 times, most recently from e4fa450 to 937c968 Compare January 26, 2026 18:59
@kwangneuraco kwangneuraco force-pushed the feat/add_pi0 branch 3 times, most recently from 77c8d94 to 8f4c492 Compare January 27, 2026 17:46
@kwangneuraco kwangneuraco dismissed stepjam’s stale review January 27, 2026 17:48

Stephen is on holiday and we already discussed how to improve the code and get the code in

@kwangneuraco kwangneuraco force-pushed the feat/add_pi0 branch 2 times, most recently from 1fa530d to 00a9f5b Compare January 30, 2026 15:21
@kwangneuraco kwangneuraco requested review from aditya-neuraco and stepjam and removed request for mark-neuracore and sdas-neuraco February 2, 2026 09:48
@kwangneuraco kwangneuraco force-pushed the feat/add_pi0 branch 2 times, most recently from bc76422 to 9bb7513 Compare February 3, 2026 15:48
Copy link
Contributor

@stepjam stepjam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation is good (pending one small comment), but some final modification needed to tests.

@kwangneuraco kwangneuraco force-pushed the feat/add_pi0 branch 3 times, most recently from a406581 to 5c88a4a Compare February 4, 2026 14:29
Copy link
Contributor

@stepjam stepjam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kwangneuraco kwangneuraco merged commit e4d98bb into main Feb 4, 2026
7 checks passed
@kwangneuraco kwangneuraco deleted the feat/add_pi0 branch February 4, 2026 14:56
kwangneuraco added a commit that referenced this pull request Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

version:minor non-breaking feature updates, new functions or endpoints

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants