Skip to content

feat(action): publish action stats utility - #243

Open
zichen0116 wants to merge 1 commit into
NVIDIA:mainfrom
zichen0116:feat/publish-action-stats-tool
Open

feat(action): publish action stats utility#243
zichen0116 wants to merge 1 commit into
NVIDIA:mainfrom
zichen0116:feat/publish-action-stats-tool

Conversation

@zichen0116

Copy link
Copy Markdown

Fixes #168.

Summary

This PR adds a public utility for generating action normalization statistics from local LeRobot-compatible datasets.

Cosmos action-policy recipes consume precomputed statistics files, but the generation script is not included in the public repository. This makes it difficult to recompute statistics for a new robot embodiment or after changing dataset preprocessing.

Changes

  • Add tools/compute_action_stats.py.
  • Support one or more local LeRobot dataset roots.
  • Compute min, max, mean, std, q01, and q99.
  • Use deterministic reservoir sampling so quantiles do not require loading the full dataset into memory.
  • Validate action dimensions and reject empty, NaN, or infinite values.
  • Emit the flat JSON schema consumed by the existing action normalizer.
  • Add CPU-only tests for statistics, deterministic sampling, and invalid input handling.

Usage

python tools/compute_action_stats.py \
  --dataset-root /path/to/lerobot-dataset \
  --action-key action \
  --output stats.json \
  --reservoir-size 50000 \
  --seed 42

For multiple compatible datasets, pass multiple paths after --dataset-root.

Non-goals

  • No changes to model architecture or default normalization behavior.
  • No GPU requirement.
  • No changes to existing bundled statistics files.

Testing

  • pytest -o addopts= --confcutdir=tools tools/compute_action_stats_test.py — 6 passed
  • ruff check --isolated tools/compute_action_stats.py tools/compute_action_stats_test.py
  • ruff format --check --isolated tools/compute_action_stats.py tools/compute_action_stats_test.py
  • python -m compileall -q tools/compute_action_stats.py tools/compute_action_stats_test.py

Signed-off-by: zzcn <zzcn.leo@qq.com>
@zichen0116
zichen0116 force-pushed the feat/publish-action-stats-tool branch from fc1324d to c27cfeb Compare September 8, 2026 11:30
@zichen0116
zichen0116 marked this pull request as ready for review September 8, 2026 11:33
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.

Request to release the action normalization stats computation script

1 participant