Skip to content

[Feature] Report MicroDuck trajectory evaluation metrics - #4396

Merged
vmoens merged 5 commits into
mainfrom
codex/microduck-evaluation-metrics
Sep 18, 2026
Merged

vmoens merged 5 commits into
mainfrom
codex/microduck-evaluation-metrics

Conversation

@vmoens

@vmoens vmoens commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Makes complete-trajectory evaluation a MicroDuck environment API instead of implementing environment semantics inside the PPO recipe.

  • Adds MicroDuckEnv.trajectory_metrics, which owns the observation layout and diagnostic_* key interpretation.
  • Reports tracking, survival, pose, hopping, displacement, world-ground speed, and wrapped heading-rate metrics.
  • Excludes padded collector rows from means, rates, paired-step events, and extrema.
  • Shrinks examples/microduck/ppo_mujoco.py relative to main; the evaluator now binds the metric callback in one line.

What was wrong and what is fixed

The recipe previously contained more than one hundred lines that decoded MicroDuck-specific observation indices and diagnostic keys. Besides obscuring the PPO example, this made the environment contract look like application boilerplate:

# Before: environment semantics implemented in the training recipe.
def microduck_metrics(trajectories, *, jumping=False):
    velocity = trajectories["next", "observation"][..., 6:8]
    # ... tracking, contacts, hopping, pose, displacement and heading logic ...
    return metrics

Evaluator(
    env,
    actor,
    metrics_fn=partial(microduck_metrics, jumping=jumping),
)

# After: the environment owns its trajectory interpretation.
Evaluator(
    env,
    actor,
    metrics_fn=partial(MicroDuckEnv.trajectory_metrics, jumping=jumping),
)

Padding also cannot be replaced with zero when computing extrema. For example, every observed height may be negative:

mask:                 [ true,  true, false]
height_gain:          [-1.0, -2.0,  99.0]

wrong, pad with 0:    [-1.0, -2.0,   0.0] -> max =  0.0  # never observed
fixed, pad with -inf: [-1.0, -2.0,  -inf] -> max = -1.0  # valid maximum

The same complete-trajectory mask is used for rates, means, and paired-step events.

Tests

  • test_microduck_trajectory_metrics_exclude_padding
  • test_microduck_example_recurrent_ppo_trains_on_whole_episodes

Both pass locally. The focused regression covers padded garbage, negative valid maxima, wrapped headings, world-ground velocity, and a one-step trajectory.

@pytorch-bot

pytorch-bot Bot commented Sep 16, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4396

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 16, 2026
@github-actions github-actions Bot added Feature New feature Environments Adds or modifies an environment wrapper Examples and removed Feature New feature labels Sep 16, 2026
@github-actions github-actions Bot added the Feature New feature label Sep 16, 2026
@vmoens vmoens added the ci/optdeps Run the full tests-optdeps suite on this PR label Sep 16, 2026
@vmoens
vmoens added this pull request to stack #4430 September 18, 2026 06:35
Base automatically changed from codex/microduck-hopping-tasks to main September 18, 2026 12:53
@vmoens
vmoens force-pushed the codex/microduck-evaluation-metrics branch from 22bfe2d to fd644bc Compare September 18, 2026 12:53
@vmoens
vmoens merged commit 697778c into main Sep 18, 2026
116 of 119 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/optdeps Run the full tests-optdeps suite on this PR CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Environments Adds or modifies an environment wrapper Examples Feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant