[https://nvbugs/6008710][fix] Adjust prompt logprobs to use the correct prompt token id#12499
Conversation
|
/bot run --disable-fail-fast |
|
PR_Github #40112 [ run ] triggered by Bot. Commit: |
|
PR_Github #40112 [ run ] completed with state
|
|
/bot run |
|
PR_Github #40295 [ run ] triggered by Bot. Commit: |
|
PR_Github #40295 [ run ] completed with state
|
bf1dd15 to
8940d49
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #40752 [ run ] triggered by Bot. Commit: |
|
PR_Github #40752 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #40909 [ run ] triggered by Bot. Commit: |
8940d49 to
4e40ea1
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #40963 [ run ] triggered by Bot. Commit: |
|
PR_Github #40909 [ run ] completed with state |
|
PR_Github #40963 [ run ] completed with state
|
Signed-off-by: Stefan Niebler <[email protected]>
… accurate computation - Adjusted the prompt token ID handling in `_compute_pytorch_prompt_logprobs` to append the first generated token ID. - Modified unit tests to reflect changes in prompt logprobs calculations, ensuring consistency with the updated logic. Signed-off-by: Stefan Niebler <[email protected]>
- replace key,value with token_id, logprob_obj - replace cannot with must not Signed-off-by: Stefan Niebler <[email protected]>
1b3b8cf to
82eda0d
Compare
|
/bot run --disable-fail-fast |
📝 WalkthroughWalkthroughChanges modify how prompt logprobs are computed and validated in the executor and test suite. The executor now reconstructs prompt token IDs by combining the first generated token with remaining prompt tokens and adds validation assertions. The test suite extends validation logic with offset parameters and cross-validation between prompt and generation logprobs. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
PR_Github #41197 [ run ] triggered by Bot. Commit: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tensorrt_llm/executor/base_worker.py (1)
858-866: Token alignment fix looks correct; consider guarding against emptyoutput_token_ids.The logic correctly aligns prompt token IDs with context logits by offsetting by 1 and appending the first generated token. However, line 862 accesses
result.output_token_ids[0]which could raiseIndexErrorifoutput_token_idsis an empty list, before the assertion on line 863 can catch it.If you want the assertion message to be shown instead of a raw
IndexError:🛡️ Optional defensive check
result = response.result.get_result() assert result is not None, "result must not be None when prompt_logprobs is requested." + assert result.output_token_ids and result.output_token_ids[0], \ + "output_token_ids must not be empty when prompt_logprobs is requested." # Single element list - first_generation_token = result.output_token_ids[0][:1] - assert first_generation_token, "first generation token must not be empty when prompt_logprobs is requested." + first_generation_token = result.output_token_ids[0][:1]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tensorrt_llm/executor/base_worker.py` around lines 858 - 866, Before indexing result.output_token_ids in base_worker.py, add a defensive assertion that result.output_token_ids is non-empty (e.g., assert result.output_token_ids, "result.output_token_ids must not be empty when prompt_logprobs is requested.") so the assertion fires instead of an IndexError; then safely compute first_generation_token from result.output_token_ids[0][:1] and continue building prompt_token_ids from generation_result._generation_request.prompt_token_ids[1:] + first_generation_token, keeping the existing context_logits checks intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tensorrt_llm/executor/base_worker.py`:
- Around line 858-866: Before indexing result.output_token_ids in
base_worker.py, add a defensive assertion that result.output_token_ids is
non-empty (e.g., assert result.output_token_ids, "result.output_token_ids must
not be empty when prompt_logprobs is requested.") so the assertion fires instead
of an IndexError; then safely compute first_generation_token from
result.output_token_ids[0][:1] and continue building prompt_token_ids from
generation_result._generation_request.prompt_token_ids[1:] +
first_generation_token, keeping the existing context_logits checks intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a21726a2-34b9-46d4-bb73-122fa1885475
📒 Files selected for processing (2)
tensorrt_llm/executor/base_worker.pytests/unittest/_torch/sampler/test_logits_logprobs.py
|
PR_Github #41197 [ run ] completed with state
|
|
/bot run |
|
PR_Github #41364 [ run ] triggered by Bot. Commit: |
|
PR_Github #41364 [ run ] completed with state |
…ct prompt token id (NVIDIA#12499) Signed-off-by: Stefan Niebler <[email protected]>
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests
Description
When determining the logprob of the prompt-token, the current implementation used the prompt token, which was used as input to create the logits/logprobs instead of the prompt-token which would come next. This PR adjusts this such that the prompt-token in the prompt-logprobs output are matched correctly
Test Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.