Skip to content

Conversation

@ruivieira
Copy link
Contributor

This PR implements log probabilities support in llm-d-inference-sim enabling compatibility with evaluation frameworks and other API clients that require token-level probability.

API Coverage

  • /v1/completions: logprobs parameter with TextLogprobs response structure
  • /v1/chat/completions: logprobs boolean + top_logprobs integer with ChatLogprobs response structure
  • Response format matching vLLM/OpenAI

Refer to #213
Replaces #215

Copy link
Collaborator

@mayabar mayabar left a comment

Choose a reason for hiding this comment

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

@ruivieira I added some in-place comments
In addition, please add logprobs support for requests with streaming=true (sendStreamingResponse), please take into consideration comments in PR #215 relevant to streaming (don't pass/use request in streaming.go).

Please add tests for the simulator with logprobs:
completions and chat completions requests with logprobs with and without streaming, and check the response

Copy link
Collaborator

@mayabar mayabar left a comment

Choose a reason for hiding this comment

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

Hi @ruivieira , I added some comments.
Please pay attention that there are changes in tests utility functions.

@mayabar
Copy link
Collaborator

mayabar commented Oct 29, 2025

/lgtm
/approve

@ruivieira - approved the PR, you just need to fix merge conflicts

@github-actions github-actions bot added the lgtm label Oct 29, 2025
github-actions[bot]
github-actions bot previously approved these changes Oct 29, 2025
mayabar
mayabar previously approved these changes Oct 29, 2025
@ruivieira ruivieira dismissed stale reviews from mayabar and github-actions[bot] via 5762aa3 October 29, 2025 09:21
@ruivieira ruivieira force-pushed the logprobs-simple branch 3 times, most recently from 0ccf03d to d201bd2 Compare October 29, 2025 09:29
Add support for log probabilities in both chat completions and text completions APIs:

- Add logprobs parameter to chat completions with top_logprobs support
- Add logprobs parameter to text completions with configurable count
- Implement streaming and non-streaming logprobs functionality
- Add comprehensive test coverage for all logprobs scenarios
- Add utility functions for logprobs calculation and validation
- Support both echo and random modes for logprobs generation
- Include proper token-level probability information in responses
- Fix undefined variables in tests after upstream merge

Signed-off-by: Rui Vieira <ruidevieira@googlemail.com>
@ruivieira
Copy link
Contributor Author

@mayabar thank for you for the comments. The conflict has been solved.

@mayabar mayabar merged commit 3967e23 into llm-d:main Oct 29, 2025
4 checks passed
@mayabar
Copy link
Collaborator

mayabar commented Oct 29, 2025

Fixes #213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants