Skip to content

Commit 4a07f8d

Browse files
committed
feat(vllm-model): on-policy sampling pin via sampling_overrides
Add a framework-agnostic sampling pin to vllm_model: sampling_overrides forces temperature/top_p on every chat request, read from generic policy_generation_* keys with on-policy defaults. This keeps an external harness's rollouts on-policy for training without Gym holding any framework-specific knowledge — the training framework publishes its sampling into the generic keys. Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
1 parent 74a48d6 commit 4a07f8d

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

responses_api_models/vllm_model/app.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ class VLLMModelConfig(BaseResponsesAPIModelConfig):
6666
# Corresponds to the extra_body of OpenAI Client.
6767
extra_body: Optional[Dict[str, Any]] = None
6868

69+
# Sampling params to force on every chat request, overriding whatever the client sent. An
70+
# external harness (e.g. a CLI agent) chooses its own temperature/top_p, but on-policy RL
71+
# training requires generation to match the sampling distribution the policy is optimized under.
72+
# The integrating training framework sets these to its generation sampling params; Gym only
73+
# enforces them and holds no knowledge of any specific framework. Unset means no override.
74+
sampling_overrides: Optional[Dict[str, Any]] = None
75+
6976
default_headers: Dict[str, str] = Field(default_factory=dict)
7077
# Optional prefix for resolving relative ``metadata.audio_path`` (or
7178
# entries in ``metadata.audio_paths``) against. Absolute paths are used
@@ -379,6 +386,12 @@ def _preprocess_chat_completion_create_params(self, request: Request, body_dict:
379386
# No user message found — create one with just the audio blocks.
380387
body_dict.setdefault("messages", []).append({"role": "user", "content": list(audio_blocks)})
381388

389+
# Pin sampling params last so they win over anything the client sent. On-policy RL training
390+
# requires the generation to match the training worker's sampling config; an external harness
391+
# sets its own temperature/top_p, so force them here to keep captured rollouts on-policy.
392+
if self.config.sampling_overrides:
393+
body_dict.update(self.config.sampling_overrides)
394+
382395
return body_dict
383396

384397
async def chat_completions(

responses_api_models/vllm_model/configs/vllm_model_for_training.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@ policy_model:
77
model: ${policy_model_name}
88
return_token_id_information: true
99
uses_reasoning_parser: true
10+
# On-policy training: force generation to the sampling params the policy is optimized under,
11+
# overriding whatever an external harness requests, so captured rollouts stay on-policy. The
12+
# integrating training framework supplies these via the generic keys below (Gym does not know
13+
# any framework); the defaults are standard on-policy sampling when a framework sets nothing.
14+
sampling_overrides:
15+
temperature: ${oc.select:policy_generation_temperature,1.0}
16+
top_p: ${oc.select:policy_generation_top_p,1.0}

0 commit comments

Comments
 (0)