Skip to content

AlgorithmConfig.to_dict() returns misleading values for new-API-stack #63669

Description

@corentinlger

Hello, when creating an algorithm config with the new RLlib API stack, config.to_dict()["train_batch_size"] returns the stale class default (4000 for PPO) instead of the value I set.

e.g if I set setting train_batch_size_per_learner=10 and only use 1 learner, I would expect to read back 10 from this field rather than 4000.

Question:

This is not a major problem as you can still always access the true batch size value through the config, so first I was wondering if to_dict() shouldn't be used at all on with the new API ? But either way the current behavior can be a bit misleading.

So in to_dict(), when enable_rl_module_and_learner is True, would it make sense to overwrite config["train_batch_size"] with self.total_train_batch_size (or any other field that has the same "issue") ? Or maybe to document this in the to_dict() docstring ?

Reproduction:

from ray.rllib.algorithms.ppo.ppo import PPOConfig

config = PPOConfig().training(
    train_batch_size_per_learner=10,
    minibatch_size=5,
)

print(config.total_train_batch_size)
print(config.train_batch_size_per_learner)
print(f"{config.to_dict()['train_batch_size']} - missleading field ") # missleading field
print(config.to_dict()["_train_batch_size_per_learner"])
print(config.to_dict().get("total_train_batch_size", "Not found"))
print(config.to_dict().get("train_batch_size_per_learner", "Not found"))
10
10
4000 - missleading field 
10
Not found
Not found

Thanks in advance !

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions