[rollout] feat: add custom sampling parameters for rollout generation #5138
+26
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a
sampling_kwargsfield toRolloutConfigandSamplingConfig, allowing users to pass arbitrary sampling parameters at runtime without modifying hardcoded configurations. This enables experimental flexibility for testing custom sampling strategies.Checklist Before Starting
[rollout] feat: add custom sampling parameters for rollout generationTest
This feature has been tested with the
stopparameter to verify custom sampling kwargs are properly applied. An alternative test was also run without sampling kwargs to confirm backward compatibility - the code runs normally whensampling_kwargsis not specified.Manual testing can be done by:
actor_rollout_ref.rollout.sampling_kwargsin config YAML (e.g., withstop: ["\n"])sampling_kwargsto verify backward compatibilityval_kwargs.sampling_kwargswhen setAPI and Usage Example
Design & Code Changes
High-level design:
sampling_kwargs: Optional[dict[str, Any]]to bothRolloutConfigandSamplingConfigdataclasses|)OmegaConf.to_container()to properly convert OmegaConf DictConfig objects to regular dicts before mergingconfig.val_kwargs.sampling_kwargsfirst, falling back toconfig.sampling_kwargsSpecific changes:
verl/workers/config/rollout.py: Addsampling_kwargsfields to dataclassesverl/trainer/config/rollout/rollout.yaml: Document the new fields with commentsChecklist Before Submitting
pre-commit run --all-filesci-requestchannel