Skip to content

Revert #10192: _template_context must unset template.max_length in GRPO/GKD - #10221

Merged
tastelikefeet merged 1 commit into
modelscope:mainfrom
hjh0119:revert-10192
Sep 21, 2026
Merged

tastelikefeet merged 1 commit into
modelscope:mainfrom
hjh0119:revert-10192

Conversation

@hjh0119

@hjh0119 hjh0119 commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Reverts #10192, restoring the original default of RolloutTrainerMixin._template_context:
max_length: Optional[int] = None with template.max_length = max_length, and drops the
_TEMPLATE_CONTEXT_USE_ORIGINAL sentinel.

Why

max_length bounds the prompt in GRPO/GKD/inference (max_prompt_length), and the completion is
bounded separately by max_completion_length / the rollout generation_config. The training-time
re-encode of prompt + completion therefore must not be truncated again: a legal sample can be up to
max_length + max_completion_length.

#10192 made the default "preserve template.max_length", which silently re-enabled truncation at every
call site (GRPO _prepare_batch_inputs / SP logps / MLLM chunk re-encode, GKD _encode_samples).

The Megatron trainers (_template_context / _disable_maxlength_template_context) were never changed
and still unset max_length; this revert restores the same semantics for the HF path.

@tastelikefeet
tastelikefeet merged commit 650a775 into modelscope:main Sep 21, 2026
3 checks passed
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