[BugFix] Avoid unnecessary SAC and CQL collector spec queries - #4377
Open
aswanth-07 wants to merge 1 commit into
Open
aswanth-07 wants to merge 1 commit into
aswanth-07 wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4377
Note: Links to docs will display an error until the docs builds have been completed.
|
aswanth-07
marked this pull request as ready for review
September 14, 2026 09:17
aswanth-07
force-pushed
the
fix/sac-cql-spec-query
branch
from
September 19, 2026 14:57
e8f32af to
65600d1
Compare
Contributor
Author
|
Rebased this onto current main in 65600d1 and resolved the trainer test import overlap. The focused SAC/CQL trainer regression remains green: 25 passed, 2894 deselected. Changed-file formatting, lint, pydocstyle, pyupgrade, codespell, autoflake, and docstring-argument checks also pass. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
SACTrainerandCQLTrainernow query the collector environment for an action spec only when automatic target entropy cannot be resolved from the loss or actor.Numeric
target_entropyvalues and actor-provided action specs no longer requirecollector.getattr_env. SAC's existing collector fallback remains unchanged when neither the loss nor actor supplies the required spec.The regression constructs both trainers through their public APIs with a collector that has no environment accessor. It covers explicit zero target entropy and automatic entropy derived from a two-dimensional actor spec, then verifies the resolved target. A separate case verifies that SAC still requests the collector spec exactly once and resolves the same two-dimensional target to
-2.0.Motivation and Context
Closes #4376.
This is the SAC/CQL follow-up requested during review of #4368. Collectors without
getattr_envcurrently fail during trainer construction even when the loss already has enough information to determine target entropy.Types of changes
Tests
python -m pytest test/test_trainer.py::TestEntropyTrainerActionSpec test/objectives/test_sac.py test/objectives/test_cql.py -q -k 'EntropyTrainerActionSpec or test_sac_target_entropy_auto or test_sac_target_entropy_explicit or test_cql_target_entropy_auto'(25 passed,2894 deselected)py -3.13 scripts/check-docstring-args torchrl/trainers/algorithms/sac.py torchrl/trainers/algorithms/cql.pypassed.Checklist
AI assistance disclosure: AI-assisted development tools were used during investigation and implementation. The reported tests were run against the final diff.