test(value_learning): add stop_target_gradients regression tests#162
Open
Sumu004 wants to merge 2 commits into
Open
test(value_learning): add stop_target_gradients regression tests#162Sumu004 wants to merge 2 commits into
Sumu004 wants to merge 2 commits into
Conversation
value_learning functions (td_learning, sarsa, q_learning) correctly
default to stop_target_gradients=True — matching vtrace.py — but had
no tests verifying that the gradient is actually blocked.
Add StopTargetGradientsDefaultTest covering:
- Default (True): gradient wrt bootstrap target (v_t / q_t) is zero
- Explicit False: gradient does flow (opt-in meta-gradient path)
- Forward values are identical regardless of the flag (stop_gradient
is transparent in forward computation)
These tests are the value_learning counterpart of the regression tests
added to multistep_test.py in PR google-deepmind#161, completing the coverage story.
…ests - Break inline lambda-style defs onto two lines (C0321 multiple-statements) - Shorten StopTargetGradientsDefaultTest docstring to fit 80 chars (C0301)
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.
What does this PR do?
Adds
StopTargetGradientsDefaultTesttovalue_learning_test.py— the gradient-behaviour counterpart of the tests added in #161 formultistep_test.py.All
value_learningfunctions correctly default tostop_target_gradients=True, which means gradients do not flow through bootstrap targets (matchingvtrace.py). However, there were no tests verifying this at the gradient level — the existing tests only check forward-computation correctness.New tests for
td_learning,sarsa, andq_learning:grad(output wrt v_t/q_t)is exactly zero when using the defaultFalsepasses gradient — the opt-in meta-gradient path still worksstop_gradientis transparent in the forward passThese tests would have caught a regression if the defaults were accidentally flipped (as happened in
multistep.pybefore #161).