Repository navigation
fix(nvidia_nim): forward logprobs and top_logprobs to NIM models that serve them on lts/1.108.x (#54008) - #54043
Merged
mateo-berri merged 5 commits intoNov 24, 2026
Conversation
…answering 400 Port of the nvidia_nim change in BerriAI#54008 onto lts/1.108.x. NIM's supported params now list logprobs and top_logprobs, and top_logprobs sent without logprobs is dropped only under drop_params Source commits on main: e2a826c, 695e0e8, 537b438 (the first commit's Responses bridge work was reverted by the second, so only the nvidia_nim files move)
…apes NIM cannot take
owen-hj
requested review from
kerry-berri,
mateo-berri and
ryan-crabbe-berri
as code owners
November 24, 2026 03:10
Contributor
Contributor
Contributor
[Medium impact] The PR appears safe to merge, with no outstanding findings
|
…ls and name the proxy drop_params setting
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
Contributor
|
bugbot run |
Contributor
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 76ad380. Configure here.
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.
Handwritten 1-3 sentence description
This brings #54008 to lts/1.108.x. Asking an NVIDIA NIM model for
logprobsortop_logprobson chat completions through LiteLLM now works on the models NVIDIA serves them for. Before this, LiteLLM refused the request with a 400, so people had to setallowed_openai_paramsordrop_params, and the second one threw away what they asked forDetails
TLDR
Problem this solves:
nvidia_nim/chat calls 400 onlogprobsandtop_logprobsHow it solves it:
nvidia_nimchange to this line, with the samelitellm/codenvidia_nim/model names, proxy hint in the 400The
litellm/utils.pychange matches main line for line.litellm/llms/nvidia_nim/chat/transformation.pydiffers from main only in three type hints from main's #53715, which this line does not have. One commit is only for this line, 76ad380. It addssupports_logprobsto the cost-map schema intests/unit/test_utils.py, which main already has from #52514. The test file is main's with the line'sunittest.mockimport and without one embedding test for code this line lacks. The four cost-map rows have the same values as main. The copied rows matter only for a proxy withLITELLM_LOCAL_MODEL_COST_MAP=True, since this line reads main's cost map from GitHub otherwiseUser Flow
Before: a developer who wants token probabilities from an NVIDIA NIM model gets a 400 from LiteLLM
"model": "<nim model>"and"logprobs": truelitellm.UnsupportedParamsError: nvidia_nim does not support parameters: ['logprobs']"top_logprobs": 2gets the same 400 for both paramsAfter: the same request reaches NVIDIA and the reply carries per-token logprobs
"logprobs": truechoices[0].logprobs.contenthas itstokenandlogprob, streaming included"top_logprobs": 2returns the 2 most likely tokens for each positionRelevant issues
LTS twin of #54008
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Live runs against NVIDIA's hosted API, with the same config, setup and cases as #54008, which also has the direct NVIDIA calls. Before runs at the merge base a3e23fb, and After at 9de8bfa. The tip 76ad380 after it changes only a test. Cases 12 and 13 read the two model info routes. The branch merges cleanly into the line's newer tip. Every case prints the exact command it ran and that command's output
config.yaml and commands
Before (a3e23fb)
Every logprobs request answers 400, only drop_params or allowed_openai_params gets a 200 with no logprobs, and no model lists logprobs
After (9de8bfa)
Chat and streaming return logprobs, kimi drops them under drop_params and does not list them, and shapes NVIDIA cannot take still get the clear 400
The NIM tests pass on the line (90 in
tests/unit/llms/nvidia_nim/test_nvidia_nim.py, 208 with the cost-map tests), andmake checkpasses againstorigin/lts/1.108.xType
🐛 Bug Fix
Caveats (if any)
Copied from #54008
Medium
top_logprobsstill answers 400 until fix(responses): carry logprobs across the chat completions bridge #49536 comes to this linedrop_paramsif they refuse logprobsnvidia_nim/model with no cost-map row getslogprobssent to NVIDIA. If that model refuses them, the caller now gets NVIDIA's 400. Before,drop_params: truegave a 200 without logprobsmodel_info: supports_logprobs: falsedoes not turn it off. The only opt-out isadditional_drop_params, which drops the params even withoutdrop_params./model/infostill lists logprobs for that deploymentnemotron-safety-guard-8b-v3now returns 200 with no logprobslogprobs: truealone used to get LiteLLM's 400. It now gets a 200 withlogprobs: null, and the model lists logprobs as supportedtop_logprobsis also sent. The PR flags the three other models that return no logprobs, but not this one, since the flag would also blocklogprobswithtop_logprobs, which works thereLow
supports_logprobs: falseresponse_costwasNonewith a "model isn't mapped" error and is now0.0, sox-litellm-response-costreads0.0logprobs=true, which a Responses caller cannot send. fix(responses): carry logprobs across the chat completions bridge #49536 sends both params, so this goes away with it# mutable-okfollow the dict thatget_optional_paramsfills in place, and the cost-map read is acast, since validating the whole map on every call is slow. The tests setlitellm.drop_paramsandlitellm.model_costthroughmonkeypatch, the way callers set themllms-anthropiclane fails on this line without this PR, intest_unsigned_thinking_is_still_replayed_to_an_open_model, since fix(deepseek): forward output_config.effort and thinking as sent on /v1/messages #52196 merged. fix(anthropic)!: keep thinking disabled, display, between_tools, and effort on /v1/messages to OpenAI on lts/1.108.x #53987 and fix(anthropic): forward billing_policy and the linked billing beta on /v1/messages (lts/1.108.x) #53992 show the same redosv-scanflags@azure/msal-node6.0.1 invscode-extension/package-lock.json, which this PR does not touch. fix(anthropic)!: keep thinking disabled, display, between_tools, and effort on /v1/messages to OpenAI on lts/1.108.x #53987 and fix(anthropic): forward billing_policy and the linked billing beta on /v1/messages (lts/1.108.x) #53992 show the same redDecisions
supports_logprobs, gets both params sent to NVIDIA. Most hosted chat models that answered a probe return logprobs, so sending them by default is right. Dropping them for unknown models instead would hide logprobs from most callers. Gemini uses the same rule, and an operator can drop them per deployment withadditional_drop_params: ["logprobs", "top_logprobs"]logprobs, which /v1/completions sends as a count, is refused withoutdrop_paramsand dropped with it, the same as before this PR. NVIDIA only takestrueorfalse. Translating it tologprobs: trueplustop_logprobswas rejected because the text completion bridge returns no logprobs from a chat provider, so the caller would get nothing back for ittop_logprobswithoutlogprobs: trueis refused withoutdrop_paramsand dropped with it, the same as before this PR. NVIDIA ignores it on some models and answers a bare 400 on others (kimi-k3.1-pro,muse-glimmer-30b), so LiteLLM's error naming the param and the fix is clearer.allowed_openai_params: ["top_logprobs"]still sends it as istop_logprobskeeps the 400 from before this PR, because the Responses bridge sendstop_logprobswithoutlogprobs. fix(responses): carry logprobs across the chat completions bridge #49536 sends both and carries the logprobs back. fix(nvidia_nim): forward logprobs and top_logprobs to NIM models that serve them #54008's body shows /v1/responses returning logprobs on main with both PRs merged inFinal Attestation
Bugbot summary