Skip to content

[BugFix] Decode DreamerV3 rewards and values end to end - #4066

Merged
vmoens merged 4 commits into
gh/vmoens/286/basefrom
gh/vmoens/286/head
Aug 12, 2026
Merged

[BugFix] Decode DreamerV3 rewards and values end to end#4066
vmoens merged 4 commits into
gh/vmoens/286/basefrom
gh/vmoens/286/head

Conversation

@vmoens

@vmoens vmoens commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

Summary:

  • add configurable reward_logits and value_logits NestedKeys while reserving reward and value keys for decoded scalars
  • preserve legacy logits-under-scalar-key inputs with v0.16 deprecation warnings
  • expose categorical critic logits and decoded values to lambda returns
  • share the trained prior and categorical reward head with imagination
  • configure the maintained DreamerV3 example for 255-bin reward and value cross entropy

Rationale:
Training consumes categorical logits, whereas environment rewards, critic baselines, and TD-lambda returns require decoded scalars. Separating these representations prevents logits from leaking into return computation, and sharing the trained heads ensures imagination reflects the optimized world model.

Test plan:

  • uv run pytest -q test/objectives/test_dreamer_v3.py
  • run the maintained DreamerV3 SOTA smoke with 11-bin CI overrides
  • 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/4066

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

✅ You can merge normally! (2 Unrelated Failures)

As of commit 54337d9 with merge base d5a62cb (image):

BROKEN TRUNK - The following jobs failed but were 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

Update after the stack-level ghstack rebase: The full eight-PR Dreamer stack was checked out from #4075, rebased onto current origin/main, linted with pre-commit run --all-files, and submitted successfully as vmoens. This PR is now at ba23945a1465. The core Dreamer suites pass (267 tests) and the two doctest modules pass (15 tests); the DMC-only smoke still requires dm_control, which is not installed locally. Any earlier conflict/head-status note below is superseded; the substantive code-review observations remain applicable.

Reviewed published head 6df1724eea04, including the full layer diff, the latest commit, current checks, and the complete PR conversation (there are no human review threads yet). I also attempted the requested rebase after fetching origin/main, but it stopped on a content conflict in sota-implementations/dreamer_v3/dreamer_v3.py; per the rebase workflow, I left that rebase in progress and did not push a partial result.

Within the published patch, the separation of categorical logits from decoded reward/value keys is coherent: the loss reads the configurable logits keys, the legacy fallback has an explicit v0.16 deprecation, nested-key coverage is present, and imagination shares the trained prior/reward head instead of independent parameters. I did not find an additional code defect in this layer. The four new focused tests (decoded critic value, legacy warning, nested logits keys, and shared imagination parameters) pass, and git diff --check is clean.

Residual risk: this head is still based on the pre-rebase stack, so it has not been validated against current origin/main. The existing bot-reported lint failure is an infrastructure/container failure rather than a source diagnostic. Please resolve the DreamerV3 script conflict and rerun the focused suite plus the SOTA smoke on the rebased result.

vmoens added 3 commits August 10, 2026 09:15
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@vmoens

vmoens commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the review pass and resubmitted this commit after rebasing the stack onto current main. No layer-specific code change was needed; the categorical logits remain separated from decoded reward/value scalars and the shared imagination heads are preserved. The full all-files lint suite passes at this PR boundary.

@vmoens
vmoens marked this pull request as ready for review August 12, 2026 08:41
vmoens added a commit that referenced this pull request Aug 12, 2026
Summary:
- add configurable reward_logits and value_logits NestedKeys while reserving reward and value keys for decoded scalars
- preserve legacy logits-under-scalar-key inputs with v0.16 deprecation warnings
- expose categorical critic logits and decoded values to lambda returns
- share the trained prior and categorical reward head with imagination
- configure the maintained DreamerV3 example for 255-bin reward and value cross entropy

Rationale:
Training consumes categorical logits, whereas environment rewards, critic baselines, and TD-lambda returns require decoded scalars. Separating these representations prevents logits from leaking into return computation, and sharing the trained heads ensures imagination reflects the optimized world model.

Test plan:
- uv run pytest -q test/objectives/test_dreamer_v3.py
- run the maintained DreamerV3 SOTA smoke with 11-bin CI overrides
- flake8 --config=setup.cfg on the changed Python files
- ufmt check on the changed Python files
- git diff --check

ghstack-source-id: 8408563
Pull-Request: #4066
@vmoens
vmoens merged commit 54337d9 into gh/vmoens/286/base Aug 12, 2026
122 of 124 checks passed
@vmoens
vmoens deleted the gh/vmoens/286/head branch August 12, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BugFix CI Has to do with CI setup (e.g. wheels & builds, tests...) CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Objectives sota-implementations/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant