Skip to content

Fix Orbax StepMetadata checkpoint loading - #99

Merged
LiangSu8899 merged 1 commit into
flashrt-project:mainfrom
heiheiha798:fix/orbax-stepmetadata-loader
Jun 21, 2026
Merged

LiangSu8899 merged 1 commit into
flashrt-project:mainfrom
heiheiha798:fix/orbax-stepmetadata-loader

Conversation

@heiheiha798

Copy link
Copy Markdown
Contributor

Summary

  • Use FlashRT's direct Orbax restore path for Orbax checkpoints instead of relying on OpenPI's restore_params helper.
  • Support current Orbax StepMetadata.item_metadata.tree["params"] metadata while preserving the legacy subscriptable metadata API (metadata["params"]).
  • Add CPU-only regression tests for StepMetadata, dict metadata, mapping-style metadata, and the current empty WeightLoader.run() behavior.

Problem

In the Thor CUDA13-era JAX / Orbax environment, orbax.checkpoint.PyTreeCheckpointer().metadata(path) returns a StepMetadata object. The previous loader path expected subscriptable metadata and failed before model execution with:

TypeError: 'StepMetadata' object is not subscriptable

The OpenPI-preferred loader path is not a reliable workaround in this environment because it reaches the same stale metadata assumption and also mutates sys.path to probe /workspace/src.

Validation

Local static check:

python -m py_compile flash_rt/core/weights/loader.py tests/test_weight_loader.py
-> passed

Local script runner:

PYTHONPATH=. python tests/test_weight_loader.py
-> 20/20 passed

Local pytest in the flashrt env:

/data/home/tianjianyang/miniconda3/envs/flashrt/bin/python -m pytest tests/test_weight_loader.py -q
-> 20 passed in 1.84s

Thor real-checkpoint validation performed during development:

GPU: NVIDIA Thor, compute capability (11, 0)
Python: 3.12.0
PyTorch: 2.10.0
CUDA runtime: 13.0
JAX stack: jax==0.9.2, jaxlib==0.9.2,
           jax-cuda13-pjrt==0.9.2, jax-cuda13-plugin==0.9.2
NumPy: 2.2.6
XLA_FLAGS=--xla_gpu_autotune_level=0

load_weights(PI05_JAX_CKPT, format="orbax")
-> loaded_count=51, seconds=6.25

Limits / Notes

  • No kernel, CMake, pybind, or runtime model-routing changes are included.
  • No silent fallback path is introduced; unsupported or malformed metadata still raises.
  • This intentionally removes the OpenPI-preferred restore branch for Orbax checkpoints. Validation covers the staged Pi0.5 JAX Orbax checkpoint on Thor; it does not claim a tensor-by-tensor comparison for every historical OpenPI checkpoint.
  • Pi0.5 JAX FP4 documentation / benchmark cleanup is intentionally left to a separate follow-up PR.

Use FlashRT's direct Orbax restore path for Orbax checkpoints and handle current Orbax StepMetadata metadata via item_metadata.tree while preserving the legacy subscriptable metadata API. This removes the OpenPI-preferred restore path because it has the same stale metadata assumption in the current Thor CUDA13-era JAX/Orbax stack and mutates sys.path for /workspace/src.

Add CPU-only regression tests for StepMetadata, dict metadata, mapping-style metadata, and the current empty WeightLoader.run() behavior. No kernel, CMake, pybind, or runtime routing changes are included.
Copilot AI review requested due to automatic review settings June 21, 2026 14:22
@heiheiha798
heiheiha798 requested a review from LiangSu8899 as a code owner June 21, 2026 14:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@LiangSu8899 LiangSu8899 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice! thx for doing this!

@LiangSu8899
LiangSu8899 merged commit e09c14c into flashrt-project:main Jun 21, 2026
@heiheiha798
heiheiha798 deleted the fix/orbax-stepmetadata-loader branch June 21, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants