Repository navigation
[RLlib][build_base] Introduce preprocessors to RLModules/Catalog - #33447
Conversation
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
| # deprecated the old model catalog. | ||
| cls = get_preprocessor(observation_space) | ||
| prep = cls(observation_space, options) | ||
| return prep |
There was a problem hiding this comment.
I'm not adding a test to for this method itself in this PR, since it is very shallow and all underlying functionality is covered by the existing and added preprocessor tests themselves + integration tests.
| input_space: The input space space of the RLModule. This may differ from the | ||
| observation space of the environment. For example, a discrete observation | ||
| space of an environment, would usually correspond to a one-hot encoded | ||
| input space for the RLModule. |
There was a problem hiding this comment.
I've repeatedly encountered users confused about the difference between policy observation space and environment observation space. I'd like to clear this up here with this remark.
| merged_conf.model, | ||
| include_multi_binary=self.config.get( | ||
| "_enable_rl_module_api", False | ||
| ), |
There was a problem hiding this comment.
This is our only entry point to ModelCatalog.get_preprocessor_for_space.
This extra argument is not a pretty solution, but by far the best one I could think of for now.
This PR includes comments on inlining the preprocessor method, which is when we'll be able to get rid of this method.
| ) | ||
| ) | ||
|
|
||
| if options.get("custom_preprocessor"): |
There was a problem hiding this comment.
As per discussion with @sven1977 , I'm fully deprecating custom_preprocessors in this PR.
This method is @DeveloperAPI, so we are able to move the actual deprecation error to algorithm config and simply deleting the warning here since it has been deprecated for a long time.
| def observation_space(self) -> gym.Space: | ||
| obs_space = gym.spaces.Box(0.0, 1.0, self.shape, dtype=np.float32) | ||
| obs_space.original_space = self._obs_space | ||
| return obs_space |
There was a problem hiding this comment.
Context for this change:
The new catalog will, by default, support two spaces: 1D and 3D image. Preprocessors cast other spaces we are compatible with into these two. Previously, we would simply cast incoming data to float inside the models. This is an implicit conversion between multi binary and float-box that we don't want to do anymore, so that the observation space of the RLModules fully matches the incoming observations.
This preprocessor has to be excluded from our ModelV2 code paths though in order to not change our old models.
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
| observation_space: The observation space of the RLModule. This may differ | ||
| from the observation space of the environment. For example, a discrete | ||
| observation space of an environment, would usually correspond to a | ||
| one-hot encoded observation space of the RLModule because of preprocessing. |
| obs_space, merged_conf.model | ||
| obs_space, | ||
| merged_conf.model, | ||
| include_multi_binary=self.config.get( |
There was a problem hiding this comment.
Do you want to include multi binary processor when rl_module is enabled? or the other way?
There was a problem hiding this comment.
nvm. Understood after reading the whole PR.
Signed-off-by: Artur Niederfahrenhorst <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]> Signed-off-by: elliottower <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]> Signed-off-by: Jack He <[email protected]>
Why are these changes needed?
This PR does the following:
Deprecation:
Integration with RLModules/Catalog:
Catalog.get_preprocessor()that users could use if they really wanted to hack our preprocessors. I'll annotate this as DeveloperAPI at first, since our policy so far has been to make users write wrapped environments instead of preprocessors.Catalog.get_preprocessor()to support diverse observation spaces.Prerequisite: #32940