Skip to content

[None][fix] Fix GIL management for guided decoding host func#13251

Merged
Tabrizian merged 1 commit into
NVIDIA:mainfrom
Tabrizian:user/imant/gil-hostfunc-main
May 13, 2026
Merged

[None][fix] Fix GIL management for guided decoding host func#13251
Tabrizian merged 1 commit into
NVIDIA:mainfrom
Tabrizian:user/imant/gil-hostfunc-main

Conversation

@Tabrizian
Copy link
Copy Markdown
Member

@Tabrizian Tabrizian commented Apr 21, 2026

Description

When the nano bind function passes Python objects by value we need to hold GIL for the entire duration of the function body since the Python objects will be destructed after the function completes.

Test Coverage

  • tests/integration/defs/accuracy/test_disaggregated_serving.py::TestLlama3_1_8BInstruct::test_guided_decoding_with_eagle3 - exercises the guided decoding + eagle3 + disagg path that invokes launch_hostfunc.

PR Checklist

  • Please check this after reviewing the above items as appropriate for this PR.

Summary by CodeRabbit

  • Refactor
    • Optimized runtime performance by improving host function execution efficiency

@Tabrizian
Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast

@Tabrizian Tabrizian requested a review from syuoni April 21, 2026 01:09
@Tabrizian Tabrizian enabled auto-merge (squash) April 21, 2026 01:09
@Tabrizian
Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast

@Tabrizian Tabrizian disabled auto-merge April 21, 2026 01:10
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

📝 Walkthrough

Walkthrough

Removed explicit GIL acquisition and release guards from nanobind hostfunc bindings. The functions no longer acquire the GIL during construction and scheduling phases, while GIL acquisition remains in the trampoline during Python callback execution.

Changes

Cohort / File(s) Summary
GIL Management
cpp/tensorrt_llm/nanobind/runtime/hostfunc.cpp
Removed nb::gil_scoped_acquire from launchHostFunc start and freeHostFuncUserData. Removed nb::call_guard<nb::gil_scoped_release>() from launch_hostfunc and free_hostfunc_user_data binding declarations. GIL acquisition retained in callback trampoline execution.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 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 identifies the main change: fixing GIL management for the guided decoding host function, which aligns with the PR's core objective of simplifying GIL handling in hostfunc.cpp.
Description check ✅ Passed PR description clearly explains the issue (GIL management in nanobind) and solution (removing manual GIL guards). Test coverage is specified with a concrete test path that exercises the modified code.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44544 [ run ] triggered by Bot. Commit: e2dcbaf Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44545 [ run ] triggered by Bot. Commit: e2dcbaf Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44545 [ run ] completed with state SUCCESS. Commit: e2dcbaf
/LLM/main/L0_MergeRequest_PR pipeline #34939 completed with status: 'FAILURE'

CI Report

⚠️ 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

Link to invocation

@Tabrizian
Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44756 [ run ] triggered by Bot. Commit: e2dcbaf Link to invocation

@Tabrizian Tabrizian changed the title [None][fix] Simplify GIL management for guided decoding host func [None][fix] Fix GIL management for guided decoding host func Apr 21, 2026
@Tabrizian Tabrizian requested review from mikeiovine and sunnyqgg and removed request for syuoni April 21, 2026 16:35
@mikeiovine mikeiovine requested a review from syuoni April 21, 2026 16:50
@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44756 [ run ] completed with state SUCCESS. Commit: e2dcbaf
/LLM/main/L0_MergeRequest_PR pipeline #35114 completed with status: 'FAILURE'

CI Report

⚠️ 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

Link to invocation

@Tabrizian Tabrizian force-pushed the user/imant/gil-hostfunc-main branch from e2dcbaf to 2e655d8 Compare April 22, 2026 00:31
@Tabrizian
Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44832 [ run ] triggered by Bot. Commit: 2e655d8 Link to invocation

@mzweilz
Copy link
Copy Markdown
Collaborator

mzweilz commented Apr 22, 2026

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44950 [ run ] triggered by Bot. Commit: 2e655d8 Link to invocation

@Tabrizian Tabrizian force-pushed the user/imant/gil-hostfunc-main branch from 2e655d8 to 328e8c0 Compare April 29, 2026 15:34
@Tabrizian
Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast

@Tabrizian Tabrizian enabled auto-merge (squash) April 29, 2026 15:35
@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #46167 [ run ] triggered by Bot. Commit: 328e8c0 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #46167 [ run ] completed with state SUCCESS. Commit: 328e8c0
/LLM/main/L0_MergeRequest_PR pipeline #36286 completed with status: 'FAILURE'

CI Report

⚠️ 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

CI Agent Failure Analysis

Link to invocation

@Tabrizian
Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #46291 [ run ] triggered by Bot. Commit: 328e8c0 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #46291 [ run ] completed with state SUCCESS. Commit: 328e8c0
/LLM/main/L0_MergeRequest_PR pipeline #36392 completed with status: 'FAILURE'

CI Report

⚠️ 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

CI Agent Failure Analysis

Link to invocation

@Tabrizian
Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #46404 [ run ] triggered by Bot. Commit: 328e8c0 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #46404 [ run ] completed with state SUCCESS. Commit: 328e8c0
/LLM/main/L0_MergeRequest_PR pipeline #36481 completed with status: 'FAILURE'

CI Report

⚠️ 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

CI Agent Failure Analysis

Link to invocation

@Tabrizian Tabrizian force-pushed the user/imant/gil-hostfunc-main branch from 328e8c0 to cd1d9c5 Compare May 12, 2026 18:56
@Tabrizian
Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #48015 [ run ] triggered by Bot. Commit: cd1d9c5 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #48015 [ run ] completed with state SUCCESS. Commit: cd1d9c5
/LLM/main/L0_MergeRequest_PR pipeline #37851 completed with status: 'SUCCESS'

CI Report

Link to invocation

@Tabrizian Tabrizian merged commit 550de9f into NVIDIA:main May 13, 2026
6 checks passed
yufeiwu-nv pushed a commit to yufeiwu-nv/TensorRT-LLM that referenced this pull request May 19, 2026
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.

4 participants