[tinker] Return prompt and top-k prompt logprobs from sample requests - #1945
Open
pcmoritz wants to merge 1 commit into
Open
[tinker] Return prompt and top-k prompt logprobs from sample requests#1945pcmoritz wants to merge 1 commit into
pcmoritz wants to merge 1 commit into
Conversation
…uests `sample` requests carrying `prompt_logprobs` / `topk_prompt_logprobs` came back with both fields unset, which the Tinker SDK surfaces as "Tinker response did not include prompt_logprobs". Three gaps, all in the glue between the API layer and the backends: - `api.py` accepted `topk_prompt_logprobs` and dropped it when building `types.SampleInput`, so it never reached a backend. A positive top-k now also implies `prompt_logprobs` (both come off the same prompt forward pass). - The SkyRL-Train backend never put `include_prompt_logprobs` / `topk_prompt_logprobs` in the sample body, so vLLM was never asked for them, and then read the result as a list-of-lists when `RemoteInferenceClient.sample` returns flat per-prompt-token lists -- position 0 (always None) would have been returned as the whole field. Only the first sample of each request asks for prompt logprobs now, since all `num_samples` samples share one prompt. - `types.SampleOutput.prompt_logprobs` was typed `list[float]`, which rejects the None at position 0. The two forwarding clients in `extra/` also gain prompt-logprob support via vLLM's `/v1/completions`, and the vLLM -> Tinker conversion is now shared (`convert_vllm_prompt_logprobs`) so the three paths cannot drift. The JAX backend returns an explicit error for `topk_prompt_logprobs`: tx's generator only produces the prompt tokens' own logprobs, so there is no per-position distribution to build top-k from. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces support for requesting top-k prompt logprobs (topk_prompt_logprobs) alongside standard prompt logprobs. It adds a helper function convert_vllm_prompt_logprobs to standardize the conversion of vLLM's prompt logprobs into Tinker's response format. The SkyRL-Train backend is updated to forward and parse these top-k logprobs, while the JAX backend is updated to explicitly reject requests with topk_prompt_logprobs > 0 as it is unsupported. Unit tests have also been added to verify this new functionality. I have no additional feedback to provide.
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.
samplerequests carryingprompt_logprobs/topk_prompt_logprobscame back with both fields unset, which the Tinker SDK surfaces as "Tinker response did not include prompt_logprobs".Three gaps, all in the glue between the API layer and the backends:
api.pyacceptedtopk_prompt_logprobsand dropped it when buildingtypes.SampleInput, so it never reached a backend. A positive top-k now also impliesprompt_logprobs(both come off the same prompt forward pass).include_prompt_logprobs/topk_prompt_logprobsin the sample body, so vLLM was never asked for them, and then read the result as a list-of-lists whenRemoteInferenceClient.samplereturns flat per-prompt-token lists -- position 0 (always None) would have been returned as the whole field. Only the first sample of each request asks for prompt logprobs now, since allnum_samplessamples share one prompt.types.SampleOutput.prompt_logprobswas typedlist[float], which rejects the None at position 0.The two forwarding clients in
extra/also gain prompt-logprob support via vLLM's/v1/completions, and the vLLM -> Tinker conversion is now shared (convert_vllm_prompt_logprobs) so the three paths cannot drift.The JAX backend returns an explicit error for
topk_prompt_logprobs: tx's generator only produces the prompt tokens' own logprobs, so there is no per-position distribution to build top-k from.