Skip to content

Comments

[https://nvbugs/5791242][fix] workaround for flashinfer.sampling.sampling_from_logits#10713

Merged
dongfengy merged 1 commit intoNVIDIA:release/1.2from
ixlmar:fix/sample-from-logits
Jan 20, 2026
Merged

[https://nvbugs/5791242][fix] workaround for flashinfer.sampling.sampling_from_logits#10713
dongfengy merged 1 commit intoNVIDIA:release/1.2from
ixlmar:fix/sample-from-logits

Conversation

@ixlmar
Copy link
Collaborator

@ixlmar ixlmar commented Jan 15, 2026

Description

Avoids https://nvbugs/5791242 by using flashinfer.sampling.sampling_from_probs instead of flashinfer.sampling.sampling_from_logits.

Test Coverage

Unclear, the issue is still being analyzed.

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

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

Details

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

Summary by CodeRabbit

  • Refactor
    • Internal sampling logic refactored to consolidate temperature-based sampling through a unified probabilistic path, maintaining deterministic behavior and backward compatibility.

✏️ Tip: You can customize this high-level summary in your review settings.

@ixlmar ixlmar requested a review from a team as a code owner January 15, 2026 13:49
@ixlmar ixlmar requested review from Funatiq and dongfengy January 15, 2026 13:49
@ixlmar
Copy link
Collaborator Author

ixlmar commented Jan 15, 2026

/bot run

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

The sampling logic for temperature-based operations in the flashinfer utilities was refactored to consolidate multiple code paths through a shared _sample_with_probs helper function. The old logits-based approach is now marked as deprecated, and both standard and temperature-based strategies route through the probabilistic sampling path.

Changes

Cohort / File(s) Summary
Sampling consolidation
tensorrt_llm/_torch/pyexecutor/sampling_utils_flashinfer.py
Replaced direct calls to _prepare_logits_with_temperature and flashinfer.sampling.sampling_from_logits with unified _sample_with_probs helper in both StrategyImpl.sample and TemperatureOnlyWithProbs.sample flows. Removed check_nan argument. Added FIXME comment deprecating the old logits-based path.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: implementing a workaround for a flashinfer sampling issue by switching from sampling_from_logits to sampling_from_probs.
Description check ✅ Passed The description is minimal but covers the key aspects: it explains what was changed (using sampling_from_probs instead of sampling_from_logits) and why (to avoid nvbugs/5791242). However, test coverage is marked unclear.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

🧹 Recent nitpick comments
tensorrt_llm/_torch/pyexecutor/sampling_utils_flashinfer.py (1)

615-638: Workaround implementation looks correct.

The change correctly routes temperature-only sampling through _sample_with_probs, which uses flashinfer.sampling.sampling_from_probs instead of the buggy sampling_from_logits. The numerical behavior should be equivalent since both paths apply temperature scaling followed by softmax and sampling.

Consider trimming the commented-out block—a brief reference to the bug (e.g., # FIXME: nvbugs/5791242 - revert to sampling_from_logits when fixed) is sufficient, and the original implementation is preserved in git history. Keeping 15 lines of dead code increases maintenance burden.

🔧 Optional: Trim commented code
             new_tokens, _ = self._sample_with_probs(
                 logits,
                 group_logit_indices=group_logit_indices,
                 top_k=None,
                 top_p=None,
                 temperature=self._temperature,
                 generator=generator,
             )
-            # FIXME: https://nvbugs/5791242
-            `#logits` = self._prepare_logits_with_temperature(
-            #    logits, group_logit_indices, self._temperature
-            #)
-            `#new_tokens` = flashinfer.sampling.sampling_from_logits(
-            #    logits,
-            #    # NB: Leveraging 'indices' would require applying temperature+softmax before batching,
-            #    #     because 'flashinfer.sampling.softmax' has no 'indices' argument; but that would
-            #    #     compute unnecessarily softmax also for situations allowing
-            #    #     flashinfer.sampling...._sampling_from_logits.
-            #    # indices=group_logit_indices,
-            #    deterministic=True,
-            #    generator=generator,
-            #    check_nan=self._flashinfer_check_nans(logits),
-            #)
+            # FIXME: nvbugs/5791242 - revert to sampling_from_logits when fixed
             return new_tokens, None

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc5094c and 3c85ed8.

📒 Files selected for processing (1)
  • tensorrt_llm/_torch/pyexecutor/sampling_utils_flashinfer.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: The code developed for TensorRT-LLM should conform to Python 3.8+
Indent Python code with 4 spaces. Do not use tabs
Always maintain the namespace when importing Python modules, even if only one class or function from a module is used
Python filenames should use snake_case (e.g., some_file.py)
Python classes should use PascalCase (e.g., class SomeClass)
Python functions and methods should use snake_case (e.g., def my_awesome_function():)
Python local variables should use snake_case, with prefix k for variable names that start with a number (e.g., k_99th_percentile)
Python global variables should use upper snake_case with prefix G (e.g., G_MY_GLOBAL)
Python constants should use upper snake_case (e.g., MY_CONSTANT)
Avoid shadowing variables declared in an outer scope in Python
Initialize all externally visible members of a Python class in the constructor
For Python interfaces that may be used outside a file, prefer docstrings over comments
Use comments in Python for code within a function, or interfaces that are local to a file
Use Google-style docstrings for Python classes and functions, which can be parsed by Sphinx
Python attributes and variables can be documented inline with the format """<type>: Description"""
Avoid using reflection in Python when functionality can be easily achieved without reflection
When using try-except blocks in Python, limit the except clause to the smallest set of errors possible
When using try-except blocks in Python to handle multiple possible variable types (duck-typing), keep the body of the try as small as possible and use the else block for the main logic

Files:

  • tensorrt_llm/_torch/pyexecutor/sampling_utils_flashinfer.py
**/*.{cpp,cc,cxx,h,hpp,hxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

All TensorRT-LLM source files (.cpp, .h, .cu, .py, and other source files) should contain an NVIDIA copyright header with the year of latest meaningful modification

Files:

  • tensorrt_llm/_torch/pyexecutor/sampling_utils_flashinfer.py
🧠 Learnings (3)
📚 Learning: 2025-12-12T03:27:18.859Z
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 9655
File: tensorrt_llm/_torch/pyexecutor/sampler.py:3031-3031
Timestamp: 2025-12-12T03:27:18.859Z
Learning: In tensorrt_llm/_torch/pyexecutor/sampler.py, when reviewing code that iterates through requests, ensure it does not convert excessive data into Python lists. Instead, the code should use torch.gather or indexing to gather only the data that will be used in the for loop before converting to Python lists. This minimizes data movement and improves performance.

Applied to files:

  • tensorrt_llm/_torch/pyexecutor/sampling_utils_flashinfer.py
📚 Learning: 2025-08-27T15:03:57.149Z
Learnt from: ixlmar
Repo: NVIDIA/TensorRT-LLM PR: 7294
File: tensorrt_llm/_torch/pyexecutor/sampler.py:368-392
Timestamp: 2025-08-27T15:03:57.149Z
Learning: In TensorRT-LLM's sampler.py, int32 usage for softmax_indices and related tensor indexing is intentional and should not be changed to int64. The torch.IntTensor type hint is correct for the sample() function's softmax_indices parameter.

Applied to files:

  • tensorrt_llm/_torch/pyexecutor/sampling_utils_flashinfer.py
📚 Learning: 2025-12-12T03:27:08.565Z
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 9655
File: tensorrt_llm/_torch/pyexecutor/sampler.py:3031-3031
Timestamp: 2025-12-12T03:27:08.565Z
Learning: In files under tensorrt_llm/_torch/pyexecutor, avoid accessing torch.Tensor objects inside for-loops when iterating over requests. Convert batched tensors to Python lists beforehand using tensor.tolist(), and then iterate over those lists. This improves performance by reducing tensor-bound operations inside hot loops. Apply this pattern to similar code paths that process batches to access simple Python data structures (lists) inside loops.

Applied to files:

  • tensorrt_llm/_torch/pyexecutor/sampling_utils_flashinfer.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32143 [ run ] triggered by Bot. Commit: 3c85ed8

@ixlmar
Copy link
Collaborator Author

ixlmar commented Jan 15, 2026

NOTE: Based on past benchmarks, the performance impact of this change is expected to be minor.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32143 [ run ] completed with state SUCCESS. Commit: 3c85ed8
/LLM/release-1.2/L0_MergeRequest_PR pipeline #2 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

@ixlmar ixlmar force-pushed the fix/sample-from-logits branch from 3c85ed8 to 1a32a7a Compare January 15, 2026 15:49
@ixlmar
Copy link
Collaborator Author

ixlmar commented Jan 15, 2026

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32155 [ run ] triggered by Bot. Commit: 1a32a7a

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32155 [ run ] completed with state SUCCESS. Commit: 1a32a7a
/LLM/release-1.2/L0_MergeRequest_PR pipeline #4 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

@dongfengy
Copy link
Collaborator

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32228 [ run ] triggered by Bot. Commit: 1a32a7a

@v-shobhit
Copy link
Contributor

@nvzhihanj we need this patch to feat/1.2-mlpinf. Commenting to track

@dongfengy dongfengy force-pushed the fix/sample-from-logits branch from 1a32a7a to ed1d149 Compare January 19, 2026 03:39
@dongfengy
Copy link
Collaborator

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32507 [ run ] triggered by Bot. Commit: ed1d149

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32507 [ run ] completed with state SUCCESS. Commit: ed1d149
/LLM/release-1.2/L0_MergeRequest_PR pipeline #47 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

@dongfengy
Copy link
Collaborator

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32528 [ run ] triggered by Bot. Commit: 1bbcb6a

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32528 [ run ] completed with state SUCCESS. Commit: 1bbcb6a
/LLM/release-1.2/L0_MergeRequest_PR pipeline #48 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
@dongfengy dongfengy force-pushed the fix/sample-from-logits branch from 1bbcb6a to 75cd145 Compare January 19, 2026 09:55
@dongfengy
Copy link
Collaborator

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32567 [ run ] triggered by Bot. Commit: 75cd145

@ixlmar
Copy link
Collaborator Author

ixlmar commented Jan 19, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32570 [ run ] triggered by Bot. Commit: 75cd145

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32570 [ run ] completed with state FAILURE. Commit: 75cd145
/LLM/release-1.2/L0_MergeRequest_PR pipeline #56 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

@ixlmar
Copy link
Collaborator Author

ixlmar commented Jan 19, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32580 [ run ] triggered by Bot. Commit: 75cd145

@ixlmar
Copy link
Collaborator Author

ixlmar commented Jan 19, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32597 [ run ] triggered by Bot. Commit: 75cd145

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32597 [ run ] completed with state SUCCESS. Commit: 75cd145
/LLM/release-1.2/L0_MergeRequest_PR pipeline #59 completed with status: 'SUCCESS'

@dongfengy dongfengy enabled auto-merge (squash) January 20, 2026 03:41
@dongfengy dongfengy merged commit 6c0b080 into NVIDIA:release/1.2 Jan 20, 2026
5 checks passed
@ixlmar ixlmar deleted the fix/sample-from-logits branch January 20, 2026 07:07
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Jan 21, 2026
…ling_from_logits (NVIDIA#10713)

Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Jan 21, 2026
…ling_from_logits (NVIDIA#10713)

Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Jan 21, 2026
…ling_from_logits (NVIDIA#10713)

Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Jan 22, 2026
…ling_from_logits (NVIDIA#10713)

Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Jan 22, 2026
…ling_from_logits (NVIDIA#10713)

Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Jan 22, 2026
…ling_from_logits (NVIDIA#10713)

Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
@dc3671 dc3671 mentioned this pull request Jan 23, 2026
4 tasks
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Jan 23, 2026
…ling_from_logits (NVIDIA#10713)

Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Jan 24, 2026
…ling_from_logits (NVIDIA#10713)

Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
chzblych pushed a commit that referenced this pull request Jan 25, 2026
…ling_from_logits (#10713)

Signed-off-by: ixlmar <206748156+ixlmar@users.noreply.github.com>
Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
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.

6 participants