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] Quick-fix for default RLModules in combination with a user-provided config-sub-dict (instead of a full DefaultModelConfig). #47965

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rllib/algorithms/bc/torch/bc_torch_rl_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BCTorchRLModule(TorchRLModule):
@override(RLModule)
def setup(self):
# __sphinx_doc_begin__
# Build models from catalog
# Build models from catalog.
self.encoder = self.catalog.build_encoder(framework=self.framework)
self.pi = self.catalog.build_pi_head(framework=self.framework)

Expand Down
14 changes: 9 additions & 5 deletions rllib/core/rl_module/multi_rl_module.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import copy
from dataclasses import dataclass, field
import dataclasses
import logging
import pprint
from typing import (
Expand Down Expand Up @@ -553,7 +553,7 @@ def _check_module_exists(self, module_id: ModuleID) -> None:


@PublicAPI(stability="alpha")
@dataclass
@dataclasses.dataclass
class MultiRLModuleSpec:
"""A utility spec class to make it constructing MultiRLModules easier.

Expand Down Expand Up @@ -666,7 +666,11 @@ def build(self, module_id: Optional[ModuleID] = None) -> RLModule:
observation_space=self.observation_space,
action_space=self.action_space,
inference_only=self.inference_only,
model_config=self.model_config,
model_config=(
dataclasses.asdict(self.model_config)
if dataclasses.is_dataclass(self.model_config)
else self.model_config
),
rl_module_specs=self.rl_module_specs,
)
# Older custom model might still require the old `MultiRLModuleConfig` under
Expand Down Expand Up @@ -859,10 +863,10 @@ def get_rl_module_config(self):
"module2: [RLModuleSpec], ..}, inference_only=..)",
error=False,
)
@dataclass
@dataclasses.dataclass
class MultiRLModuleConfig:
inference_only: bool = False
modules: Dict[ModuleID, RLModuleSpec] = field(default_factory=dict)
modules: Dict[ModuleID, RLModuleSpec] = dataclasses.field(default_factory=dict)

def to_dict(self):
return {
Expand Down
2 changes: 1 addition & 1 deletion rllib/core/rl_module/rl_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def build(self) -> "RLModule":
observation_space=self.observation_space,
action_space=self.action_space,
inference_only=self.inference_only,
model_config=self.model_config,
model_config=self._get_model_config(),
catalog_class=self.catalog_class,
)
# Older custom model might still require the old `RLModuleConfig` under
Expand Down
Loading