Skip to content
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] Docs do-over (new API stack): Prep. RLModule; introduce Default[algo]RLModule classes (rename from [algo]RLModule). #49366

Conversation

sven1977
Copy link
Contributor

@sven1977 sven1977 commented Dec 19, 2024

Introduce Default[algo]RLModule classes (rename from [algo]RLModule).

  • This indicates a deeper move towards a world, where users don't have to subclass a algo-specific RLModule superclass anymore, but rather "only" have to implement APIs xyz in order to fulfil an algo's requirements.
  • For example, in order to learn with PPO, a user now can provide any(!) arbitrary RLModule, given that it implements the ValueFunctionAPI. The user does NOT have to subclass a PPO-specific superclass anymore freeing them from hidden/confusing/underlying implementation details, such as
    • In which property is the encoder?
    • Do I have to worry about that property if I want to bring in my own encoder or not use an encoder altogether?

Why are these changes needed?

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@sven1977 sven1977 changed the title [RLlib] Introduce Default[algo]RLModule classes (rename from [algo]RLModule). [RLlib] Docs do-over (new API stack): Prep. RLModule; introduce Default[algo]RLModule classes (rename from [algo]RLModule). Dec 19, 2024
@sven1977 sven1977 added rllib RLlib related issues rllib-models An issue related to RLlib (default or custom) Models. rllib-docs-or-examples Issues related to RLlib documentation or rllib/examples rllib-newstack labels Dec 19, 2024
Copy link
Collaborator

@simonsays1980 simonsays1980 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Some nice changes that clarify a bit more that users can start from our default RL modules for customization.

)


class DefaultAPPORLModule(DefaultPPORLModule, TargetNetworkAPI, abc.ABC):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this default naming. Do we apply it to all algorithms now? That would be great!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, exactly, that's the idea! Only DQN and SAC missing, I think ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DQN and the rest will be done in the next PR (already in review ...)


return RLModuleSpec(
module_class=BCTorchRLModule,
module_class=DefaultBCTorchRLModule,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@@ -119,11 +119,6 @@ def forward_target(self, batch: Dict[str, Any]) -> Dict[str, Any]:
),
)

# TODO (simon): DQN Rainbow does not support RNNs, yet.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes with the sequence sampling PR. Have to finish it.

self.encoder = self.catalog.build_actor_critic_encoder(framework=self.framework)
self.pi = self.catalog.build_pi_head(framework=self.framework)
self.vf = self.catalog.build_vf_head(framework=self.framework)
# __sphinx_doc_end__
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this sphinx logic here? All other modules don't have it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far yes. A follow up PR will redo the rst files and the example codes. WIP ...

@@ -69,8 +69,9 @@ def __init__(self, config: AlgorithmConfig):
self.filesystem_object = self.filesystem
elif self.filesystem is not None:
raise ValueError(
f"Unknown filesystem: {self.filesystem}. Filesystems can be "
"'gcs' for GCS, 's3' for S3, or 'abs'"
f"Unknown `config.input_filesystem` {self.filesystem}! Filesystems "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@sven1977 sven1977 enabled auto-merge (squash) December 19, 2024 19:24
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Dec 19, 2024
@github-actions github-actions bot disabled auto-merge December 19, 2024 20:49
@sven1977 sven1977 requested review from maxpumperla and a team as code owners December 19, 2024 22:22
@sven1977 sven1977 enabled auto-merge (squash) December 20, 2024 09:32
@sven1977 sven1977 merged commit 1e34aa7 into ray-project:master Dec 20, 2024
6 checks passed
@sven1977 sven1977 deleted the docs_redo_rl_module_001_default_rl_modules branch December 20, 2024 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests rllib RLlib related issues rllib-docs-or-examples Issues related to RLlib documentation or rllib/examples rllib-models An issue related to RLlib (default or custom) Models. rllib-newstack
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants