Skip to content

feat: add flags for multi_round pipeline to return logprob.#993

Open
DragonFive wants to merge 2 commits intojd-opensource:mainfrom
DragonFive:feat/multiround-complete-logprobs-flag
Open

feat: add flags for multi_round pipeline to return logprob.#993
DragonFive wants to merge 2 commits intojd-opensource:mainfrom
DragonFive:feat/multiround-complete-logprobs-flag

Conversation

@DragonFive
Copy link
Collaborator

@DragonFive DragonFive commented Mar 4, 2026

PR Description

Summary

This PR adds optional REC logprob output for pure-device multi-round beam results on top of main.

Background

main already has the beam ranking order fix (descending by beam logprob).
The remaining gap was REC multi-round output logprobs in generate_multi_round_output.

What changed

  1. Added a new global flag:
  • FLAGS_output_rec_logprobs (default: false)
  1. Updated REC multi-round output behavior in SequencesGroup::generate_multi_round_output:
  • If FLAGS_output_rec_logprobs == true:
    • Return a full logprobs list aligned with token_ids
    • Fill missing per-token logprobs with last_lps[beam_idx]
  • If FLAGS_output_rec_logprobs == false:
    • Do not return out.logprobs
  1. Kept beam ranking logic unchanged.

Files changed

  • xllm/core/common/global_flags.h
  • xllm/core/common/global_flags.cpp
  • xllm/core/framework/request/sequences_group.cpp

Behavior matrix

  • output_rec_logprobs=false (default): no REC multi-round out.logprobs
  • output_rec_logprobs=true: token-aligned out.logprobs, filled by final beam logprob

Compatibility / performance

  • Default is false, so existing behavior remains unchanged unless explicitly enabled.
  • Enabling the flag increases output payload and per-output construction work proportionally to token count.

Validation

  • Verified symbol wiring and code paths (DECLARE/DEFINE/usage).
  • Verified only target files were modified for this feature.
  • Full build/test was not run in this patch.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new flag, output_rec_logprobs, to enable the output of token-aligned log probabilities for multi-round recommendation pipelines. While the feature is a good addition, the current implementation has a couple of issues. First, it uses an incorrect default value for log probabilities in an edge case, which could lead to misleading results. Second, there is a performance concern due to inefficient token decoding within a loop. I have provided specific comments and code suggestions to address these points.

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