Skip to content

Commit

Permalink
[RLlib] Add framework-check to MultiRLModule.add_module(). (ray-pro…
Browse files Browse the repository at this point in the history
…ject#47973)

Signed-off-by: ujjawal-khare <[email protected]>
  • Loading branch information
sven1977 authored and ujjawal-khare committed Oct 15, 2024
1 parent 3111a2f commit 0c86e6a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions rllib/core/rl_module/multi_rl_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,19 @@ def add_module(
# has `inference_only=False`.
if not module.inference_only:
self.inference_only = False

# Check framework of incoming RLModule against `self.framework`.
if module.framework is not None:
if self.framework is None:
self.framework = module.framework
elif module.framework != self.framework:
raise ValueError(
f"Framework ({module.framework}) of incoming RLModule does NOT "
f"match framework ({self.framework}) of MultiRLModule! If the "
f"added module should not be trained, try setting its framework "
f"to None."
)

self._rl_modules[module_id] = module
# Update our RLModuleSpecs dict, such that - if written to disk -
# it'll allow for proper restoring this instance through `.from_checkpoint()`.
Expand Down

0 comments on commit 0c86e6a

Please sign in to comment.