[train] Fix regression where large Trainer attributes get serialized along with actor class #43234
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.
Why are these changes needed?
#43146 re-introduced a problem that was originally fixed by #28826.
The problem:
Trainer
's arguments, theTrainer
instance on the driver needs to be sure not to package itself (self
) when registering the actor class that will be run remotely.self
gets packaged along with the actor class during serialization, and so do these large objects.Trainer
instance (which serves as the dist. training coordinator), and because Ray Tune uses the Ray GCS redis key value store to save a shared copy of the serialized actor class, a huge actor class causes a gRPC error such as the one below:The fix is to remove the reference to
self
in the train coordinator function trainable. This PR also restructures the code a bit to make it harder to make such a mistake in the future.Future considerations
Related issue number
Closes #43191
Closes #43192
Closes #43193
Closes #43194
Closes #43195
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.