Skip to content

[BugFix] Bootstrap truncated states in SAC with skip_done_states - #4756

Open
Bndrwe wants to merge 1 commit into
pytorch:mainfrom
Bndrwe:fix-sac-skip-done-states-truncation
Open

Bndrwe wants to merge 1 commit into
pytorch:mainfrom
Bndrwe:fix-sac-skip-done-states-truncation

Conversation

@Bndrwe

@Bndrwe Bndrwe commented Nov 22, 2026

Copy link
Copy Markdown

Description

SACLoss and DiscreteSACLoss now decide which next states to skip with the terminated key (falling back to done), like TQCLoss, so truncated steps are bootstrapped again when skip_done_states=True. Also fixed the docstring.

Motivation and Context

With the flag on, time-limit truncations were skipped like terminal states, so their targets were the bare reward (discrete) or used a zero action (continuous), silently.

Fixes #4755

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTION guide (required)
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

Tests: two new regression tests (fail on main, pass here). test_discrete_sac_terminating put NaN observations on rows that were done but not terminated, which assumed the old behaviour, so those rows are now marked terminated too. Full test/objectives/test_sac.py passes (1690 passed, 495 skipped), ufmt and flake8 are clean.

With skip_done_states=True, SACLoss and DiscreteSACLoss masked next states
on the done key. Truncated transitions (done=True, terminated=False) were
therefore skipped too: DiscreteSACLoss set their next value to 0, and
SACLoss evaluated the target critic with a zero action and zero log-prob
instead of a policy sample. The value estimator still bootstraps on
~terminated, so those transitions silently got a wrong target.

Mask on the terminated key (falling back to done), as TQCLoss already does,
so only terminal states are skipped.
@pytorch-bot

pytorch-bot Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⚠️ 16 Awaiting Approval

As of commit 2c49fa9 with merge base df1db3d (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

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 Nov 22, 2026

This branch has not been deployed

No deployments
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. Objectives

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] SAC / DiscreteSAC with skip_done_states=True don't bootstrap truncated steps

1 participant