Skip to content

[RLlib] PPO automatic train batch size calculation fix - #25621

Merged
sven1977 merged 1 commit into
ray-project:masterfrom
ArturNiederfahrenhorst:ppobatchsizefix
Jun 10, 2022
Merged

sven1977 merged 1 commit into
ray-project:masterfrom
ArturNiederfahrenhorst:ppobatchsizefix

Conversation

@ArturNiederfahrenhorst

Copy link
Copy Markdown
Contributor

Why are these changes needed?

Our PPO config processing calculates rollouts lengths that accumulate to <= train_batch_size during algorithm execution, while they should be accumulating to >= train_batcH_size.

To cite a user from the forum:
"An example:
train_batch_size = 4000
rollout_fragment_length = 200
num_worker = 7
num_envs_per_worker = 1"
results in rollout_fragment_length of 571 and ends up collecting 7994 timesteps, which is almost 2x instead of 4004, which would be the sensible thing to do here.

Related issue number

Related forum discussion

Checks

):
new_rollout_fragment_length = config["train_batch_size"] // (
num_workers * config["num_envs_per_worker"]
new_rollout_fragment_length = math.ceil(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great idea! Yeah, this should push the collected num samples only slightly over the train_batch_size so a new rollout is not required, which would potentially almost double the train batch.

@sven1977 sven1977 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, thanks for the fix @ArturNiederfahrenhorst !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants