Skip to content

feature: Configurable num logprobs in vLLM generation#5107

Open
LeonEricsson wants to merge 5 commits intohuggingface:mainfrom
LeonEricsson:feat/vllm_logprobs_topk
Open

feature: Configurable num logprobs in vLLM generation#5107
LeonEricsson wants to merge 5 commits intohuggingface:mainfrom
LeonEricsson:feat/vllm_logprobs_topk

Conversation

@LeonEricsson
Copy link
Collaborator

@LeonEricsson LeonEricsson commented Feb 16, 2026

Summary

  • Adds a logprobs parameter across the vLLM generation stack (client, server, and generation orchestrator), allowing callers to request the top-N log-probabilities per generated token rather than only the sampled token's log-probability.
  • VLLMGeneration::generate returns a new logprob_token_ids field alongside logprobs, both with shape (num_sequences, seq_len, num_logprobs), giving downstream consumers access to the full top-k distribution.

Motivation

This change is a prerequisite for an upcoming PR I’m working on.

More broadly, it is a strict improvement over the original implementation. Previously, logprobs was hardcoded to 0, which discarded the richer top-k information that vLLM already computes internally. I was lazy when I implemented this the first time around because we only needed sampled logps. By exposing the logprobs parameter, we incur no additional overhead while unlocking access to information that was previously inaccessible.

Minimal upstream effect, GRPOTrainer and RLOOTrainer use the default logprobs=0

todo

  • run modified slow test, requires multiple accelerators

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a GitHub issue? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

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

Comments