Repository navigation
fix(pytorch): preserve routed experts during prefill scoring - #5198
Draft
qescccczmr wants to merge 1 commit into
Draft
qescccczmr wants to merge 1 commit into
qescccczmr wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
Agentic RL replay can use
/generatewithmax_tokens=0to score a fixed sequence. When the caller also requests routed experts, the prefill scoring branch currently discards the model's routes, so replay needs a separate generation request to collect them.Changes
Carry routed experts alongside the compact input logprobs and append them to the sequence when zero-token prefill completes. The terminal response uses the existing routed-expert history and offset handling. The scoring path still finishes with zero generated tokens.
Validation
217 CPU tests passed across the model agent, prefill logprob, generate route, and session cleanup suites, with 8 CUDA cases skipped. The new regression tests cover requested and unrequested routes and terminal expert history. The generate tests check the joint response in streaming and non-streaming modes. Ruff, Markdown formatting, docstring formatting, and
git diff --checkpassed.The current prefill scoring constraints, including disabled speculative decoding, still apply.