Skip to content

fix: use prompt token length for advantage group extraction#2176

Open
yfw wants to merge 1 commit intomainfrom
yifu/fix-prompt-extraction-multi-turn
Open

fix: use prompt token length for advantage group extraction#2176
yfw wants to merge 1 commit intomainfrom
yifu/fix-prompt-extraction-multi-turn

Conversation

@yfw
Copy link
Copy Markdown
Contributor

@yfw yfw commented Mar 30, 2026

The previous role-based extraction (_extract_prompt_only_messages) broke on multi-turn prompts containing assistant messages in the conversation history — it would strip them, corrupting the prompt IDs used for advantage estimation.

Replace with extract_initial_prompt_messages() which uses the length field to identify the original prompt boundary. Applied to both sync and async GRPO paths.

Closes #1960

What does this PR do ?

Add a one line overview of what this PR aims to accomplish.

Issues

List issues that this PR closes (syntax):

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

  • ...

The previous role-based extraction (`_extract_prompt_only_messages`)
broke on multi-turn prompts containing assistant messages in the
conversation history — it would strip them, corrupting the prompt IDs
used for advantage estimation.

Replace with `extract_initial_prompt_messages()` which uses the
`length` field to identify the original prompt boundary. Applied to
both sync and async GRPO paths.

Closes #1960

Co-Authored-By: Jiaqi Zeng <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw yfw requested a review from a team as a code owner March 30, 2026 23:17
@yfw yfw added the super-v3 label Mar 30, 2026
@yfw yfw requested a review from a team as a code owner March 30, 2026 23:17
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot bot commented Mar 30, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@yuki-97 yuki-97 added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Mar 31, 2026
@yuki-97
Copy link
Copy Markdown
Contributor

yuki-97 commented Mar 31, 2026

/ok to test 628a248

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

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) super-v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[super-pr] Use prompt length to find groups for advantage calculation

2 participants