Repository navigation
[BugFix] Format the key and class name into two error messages - #4496
Merged
Merged
Conversation
DiscreteCQLLoss.cql_loss and ParallelEnv._shutdown_workers built their
error messages without an f-prefix, so users saw the literal
"{self.tensor_keys.pred_val}" and "{self.__class__.__name__}".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4496
Note: Links to docs will display an error until the docs builds have been completed.
|
coder-jayp
approved these changes
Sep 29, 2026
coder-jayp
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Thanks for the fix. The regression test properly asserts the observable behavior.
bsprenger
pushed a commit
that referenced
this pull request
Oct 9, 2026
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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
Two error messages in TorchRL are missing their
fprefix, so they print the placeholder text instead of the value:DiscreteCQLLoss.cql_lossraisesKeyError: "Couldn't find the predicted qvalue with key {self.tensor_keys.pred_val} in the input tensordict. ..."when it's called beforevalue_loss. With a custompred_valkey the user can't see which key it looked for.ParallelEnv._shutdown_workersraisesRuntimeError: calling {self.__class__.__name__}._shutdown_workers only allowed when env.is_closed = False.This adds the
fprefix to both.Regression test:
TestDiscreteCQL.test_dcql_cql_loss_before_value_lossintest/objectives/test_cql.py. It setspred_val="custom_pred_val", callscql_lossbeforevalue_loss, and checks that theKeyErrornames that key. The test fails onmainbecause the message doesn't match, and passes with this change.TestDiscreteCQLpasses locally: 75 tests, Python 3.12, torch 2.14, tensordict 0.14.2, CPU. I didn't add a test for the_shutdown_workersmessage, because it only fires on an already-closed env behind@_check_start.Lint:
pre-commit runon the three files passes (ufmt, flake8, pydocstyle, pyupgrade, codespell). I ran autoflake directly, because the hook expects it on PATH: no issues.Fixes #4495
Generated with Claude Code