-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RLlib] Learner API: Fix and unify grad-clipping configs and behaviors. #34464
[RLlib] Learner API: Fix and unify grad-clipping configs and behaviors. #34464
Conversation
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sharing this. However, I am overall confused by this pr. Is it incomplete?
rllib/core/learner/tf/tf_learner.py
Outdated
) for k, v in gradients_dict.items() | ||
} | ||
|
||
# Clip by L2-norm (per gradient tensor). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we going to allow users to clip gradients by value and then by norm? that doesn't sound right to me, but that is the behavior that has been enabled here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point. Was thinking about this myself. Maybe we should just do: grad_clip: [some value]
and then grad_clip_by: [value|norm|global_norm]
.
rllib/algorithms/qmix/qmix.py
Outdated
|
||
# TODO (sven): Deprecate grad_clip setting once all-in on new Learner API. | ||
self.grad_clip = 10.0 | ||
self.grad_clip_by_global_norm = 10.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is this going to be used downstream by the qmix policy / multi_gpu_train_one_batch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed by replacing the new settings with backward-compatible ones
…process_gradients_implementations
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
…process_gradients_implementations
Signed-off-by: sven1977 <[email protected]>
Hey @avnishn , sorry about the confusion and thanks for taking a look! I went through the PR once more and your comments and addressed all of them. |
@@ -422,16 +425,6 @@ def validate(self) -> None: | |||
self.vtrace_clip_pg_rho_threshold | |||
) | |||
|
|||
@override(AlgorithmConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed anymore with this PR. grad clipping has been universally moved into Learner.postprocess_gradients()
.
@@ -79,6 +79,22 @@ def compute_gradients( | |||
|
|||
return grads | |||
|
|||
@override(Learner) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was missing in torch thus far.
@@ -27,6 +27,48 @@ | |||
tf1, tf, tfv = try_import_tf() | |||
|
|||
|
|||
@PublicAPI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New grad clip utilities, replacing the old, messy ones (some of the old ones do clipping by value, some by norm (not global norm), some have additional optimizer update logic in them, etc..
…s. (ray-project#34464) Signed-off-by: Jack He <[email protected]>
Learner API: Fix and unify grad-clipping configs and behaviors.
grad_clip_by
, which can be set to "value", "norm" or "global_norm" and determines the mode of clipping.grad_clip
a generic AlgorithmConfig property (was only supported by some algos before). However, this setting is only used if_enable_learner_api=True
.Why are these changes needed?
Related issue number
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.