Skip to content
Open
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
9 changes: 9 additions & 0 deletions slime/rollout/sglang_rollout.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ async def generate(args: Namespace, sample: Sample, sampling_params: dict[str, A

prompt_ids = _prepare_prompt_ids(sample, state.tokenizer, state.processor)

# Clamp on retry: ABORTED samples carry response_length from prior attempts.
sampling_params = dict(sampling_params)
if args.rollout_max_response_len is not None:
remaining = args.rollout_max_response_len - sample.response_length
if remaining <= 0:
sample.status = Sample.Status.TRUNCATED
return sample
sampling_params["max_new_tokens"] = min(sampling_params["max_new_tokens"], remaining)

assert (
sampling_params["max_new_tokens"] >= 0
), f"max_new_tokens: {sampling_params['max_new_tokens']} should not be less than 0"
Expand Down
Loading