[RLlib] fix: Support custom eval functions that return zero eval_results, env_steps, or agent_steps {}, 0, 0#61563
Open
petern48 wants to merge 3 commits intoray-project:masterfrom
Open
Conversation
Signed-off-by: Peter Nguyen <petern0408@gmail.com>
Signed-off-by: Peter Nguyen <petern0408@gmail.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where custom evaluation functions could not return falsy values like an empty dictionary {} or 0. The changes correctly adjust the validation logic to check for types instead of truthiness, allowing these valid return values. A new test case has been added to verify this fix. The implementation looks correct and effectively solves the described problem.
Note: Security Review did not run due to the size of the PR.
{} and 0{} and 0 or that don't write to metrics store
Signed-off-by: Peter Nguyen <petern0408@gmail.com>
386b1fd to
098b286
Compare
{} and 0 or that don't write to metrics store{}, 0, 0
Contributor
Author
|
cc @simonsays1980 as original author |
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
Custom evaluation functions are expected to return the following return values:
eval_results, env_steps, agent_steps. Sometimes, users may want to return an output of{}, 0, 0to skip the iteration (see the issue for an example). However, the code would raise a ValueError because it checks for falsy values. This PR updates the validation to check for the exact types instead.Additionally, I found that the code would throw a KeyError when the custom evaluation didn't write to the metrics store. To handle this, I added a
default={}to the peek call. The same peek call a few lines down already does the same.Related issues
Fixed #61513
Additional information
The following validation logic was originally added in this PR: #45652. It looks like the intention of the PR was to validate the inputs, not to prevent
0or{}values.ray/rllib/algorithms/algorithm.py
Lines 1633 to 1637 in 556e206