Skip to content

[Feature] Normalize DreamerV3 REINFORCE return scale - #4067

Draft
vmoens wants to merge 1 commit into
gh/vmoens/287/basefrom
gh/vmoens/287/head
Draft

[Feature] Normalize DreamerV3 REINFORCE return scale#4067
vmoens wants to merge 1 commit into
gh/vmoens/287/basefrom
gh/vmoens/287/head

Conversation

@vmoens

@vmoens vmoens commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

Summary:

  • checkpoint EMA fifth- and ninety-fifth-percentile return statistics in the actor loss
  • update them at rate 0.01 without debiasing and clamp the span to at least 1.0
  • divide detached REINFORCE advantages by the uncentered span
  • expose low, high, and scale diagnostics plus normalization configuration
  • enable the maintained example with the paper defaults

Rationale:
DreamerV3 normalizes the scale of REINFORCE advantages so reward magnitude does not directly determine actor-gradient magnitude. Persisting the EMA state keeps resumed training numerically continuous while evaluation remains read-only.

Test plan:

  • uv run pytest -q test/objectives/test_dreamer_v3.py
  • run the maintained DreamerV3 SOTA smoke with 11-bin CI overrides
  • verify the normalized REINFORCE equation, EMA updates, eval stability, torch.compile, gradients, and state-dict round trip
  • flake8 --config=setup.cfg on the changed Python files
  • ufmt check on the changed Python files
  • git diff --check

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 2 New Failures, 3 Unrelated Failures

As of commit 194e534 with merge base 2a77e48 (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@vmoens

vmoens commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed published head 194e534a1a57, including the complete layer diff, latest commit/check state, and the full PR conversation (no human review threads are present). The requested rebase onto freshly fetched origin/main stopped on a content conflict in sota-implementations/dreamer_v3/dreamer_v3.py; I preserved the in-progress rebase and did not push anything partial.

The EMA percentile-span normalization is applied only to detached REINFORCE advantages, its buffers are checkpointed, validation covers rates/quantiles/minimum scale, and the reparameterization path remains unscaled. I found no additional code defect in this layer. Both new focused tests (normalization behavior and checkpoint restoration) pass, and git diff --check is clean.

Residual risk: the published head has not been tested against current main because of the conflict, and torch.quantile remains the main compile/performance-sensitive operation in the actor hot path. The bot lint failure on the published head is a runner/container failure, not a reported lint diagnostic. Please resolve the script conflict, then rerun the focused tests and compile/SOTA coverage on the rebased head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Feature New feature Objectives sota-implementations/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant