Skip to content

[None][fix] ADP router crashes on serve when scheduling_params.attent… - #14267

Merged
nv-guomingz merged 1 commit into
NVIDIA:mainfrom
nv-guomingz:user/guomingz/adp_router_enhance
May 21, 2026
Merged

[None][fix] ADP router crashes on serve when scheduling_params.attent…#14267
nv-guomingz merged 1 commit into
NVIDIA:mainfrom
nv-guomingz:user/guomingz/adp_router_enhance

Conversation

@nv-guomingz

@nv-guomingz nv-guomingz commented May 18, 2026

Copy link
Copy Markdown
Collaborator

…ion_dp_relax is None

Summary by CodeRabbit

  • Bug Fixes

    • Fixed a crash in request scheduling that occurred when attention distribution parameters were left unset.
  • Tests

    • Added regression test to verify request scheduling handles default unset parameters without errors.

Review Change Stack

Description

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)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • 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.

@nv-guomingz
nv-guomingz requested a review from a team as a code owner May 18, 2026 14:23
@nv-guomingz
nv-guomingz requested a review from joyang-nv May 18, 2026 14:23
@nv-guomingz

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR fixes a crash in ADP request scheduling when SchedulingParams objects have attention_dp_relax set to None (the default). The routers now normalize None to True when computing sort keys, preventing None from being passed to Python's sorted() function. A regression test validates the fix with production-like default parameters.

Changes

ADP Router Relax None Normalization

Layer / File(s) Summary
Relax normalization in DefaultADPRouter and KVCacheAwareADPRouter
tensorrt_llm/_torch/pyexecutor/scheduler/adp_router.py
Both router classes normalize attention_dp_relax values in their sort-key computation by assigning to val and returning True if val is None else val, preventing None from reaching sorted().
Regression test for None relax scheduling
tests/unittest/_torch/executor/test_adp_router.py
New test constructs requests with default SchedulingParams (where attention_dp_relax is None), runs the scheduler, and asserts all requests are assigned without crashing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only the repository template with no actual content about the issue, solution, or test coverage provided by the author. Add sections explaining the root cause of the crash, how the fix normalizes the None value, and reference the new regression test added to the codebase.
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: fixing an ADP router crash when attention_dp_relax is None, matching the actual code modifications in the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
tests/unittest/_torch/executor/test_adp_router.py (2)

448-493: QA list updates are unnecessary for this PR.

This is a unittest-only regression addition; no tests/integration/test_lists/qa/* change is needed.

As per coding guidelines "If the PR only touches unittest/ or narrow unit scope, say explicitly whether QA list updates are unnecessary or optional."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/_torch/executor/test_adp_router.py` around lines 448 - 493,
The PR should explicitly state that QA list updates are unnecessary because this
change only touches unit tests; update the PR description or commit message to
include a line like "QA list updates are unnecessary for this PR" referencing
that the change is confined to tests/unittest/_torch/executor/test_adp_router.py
(specifically the
test_schedule_attention_dp_requests_serve_default_relax_None_does_not_crash
addition) so reviewers and release managers know no
tests/integration/test_lists/qa/* edits are required.

448-493: ⚡ Quick win

Add a matching KVCacheAwareADPRouter regression for attention_dp_relax=None.

This new test validates only the default router path (_assign(...)), while the PR also changes KVCacheAwareADPRouter.get_relax_value. Add one parallel test to lock coverage on that second code path.

Suggested test shape
+def test_kv_cache_aware_schedule_attention_dp_requests_serve_default_relax_none_does_not_crash():
+    from tensorrt_llm.scheduling_params import SchedulingParams
+
+    dist = _mock_dist(tp_size=2)
+    kv_cache_manager = MagicMock()
+    kv_cache_manager.enable_block_reuse = True
+    router = KVCacheAwareADPRouter(dist=dist, kv_cache_manager=kv_cache_manager)
+
+    states = [
+        RankState(rank=0, num_active_requests=0, num_active_tokens=0),
+        RankState(rank=1, num_active_requests=0, num_active_tokens=0),
+    ]
+
+    def _make_req(req_id):
+        r = Mock()
+        r.py_scheduling_params = SchedulingParams()  # relax/rank default to None
+        r.input_token_ids = [1, 2, 3]
+        return RequestQueueItem(req_id, r)
+
+    reqs = [_make_req(i) for i in range(4)]
+    result, _ = router.route_requests(states, reqs, max_num_active_requests=8)
+    assert sum(len(v) for v in result.values()) == 4

As per coding guidelines "Coverage expectations: Assess whether new/changed tests cover happy path, important edge cases, and failure modes relevant to the feature or fix."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/_torch/executor/test_adp_router.py` around lines 448 - 493,
Add a parallel regression test that exercises the KVCacheAwareADPRouter code
path when attention_dp_relax is None: create a new test (e.g.,
test_schedule_attention_dp_requests_kvcacheaware_relax_None_does_not_crash) that
mirrors the existing test but invokes the KVCacheAwareADPRouter path (call the
router method that uses KVCacheAwareADPRouter.get_relax_value or otherwise
ensure get_relax_value from KVCacheAwareADPRouter is executed), build
RequestQueueItem instances with mock_request.py_scheduling_params =
SchedulingParams() and input_token_ids like the existing test, then run the same
assignment logic (or call the public entry that triggers _assign behavior) and
assert no exception and that all requests are assigned; reference
SchedulingParams, RequestQueueItem, and KVCacheAwareADPRouter.get_relax_value to
locate and mirror the existing test flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/unittest/_torch/executor/test_adp_router.py`:
- Around line 448-493: The PR should explicitly state that QA list updates are
unnecessary because this change only touches unit tests; update the PR
description or commit message to include a line like "QA list updates are
unnecessary for this PR" referencing that the change is confined to
tests/unittest/_torch/executor/test_adp_router.py (specifically the
test_schedule_attention_dp_requests_serve_default_relax_None_does_not_crash
addition) so reviewers and release managers know no
tests/integration/test_lists/qa/* edits are required.
- Around line 448-493: Add a parallel regression test that exercises the
KVCacheAwareADPRouter code path when attention_dp_relax is None: create a new
test (e.g.,
test_schedule_attention_dp_requests_kvcacheaware_relax_None_does_not_crash) that
mirrors the existing test but invokes the KVCacheAwareADPRouter path (call the
router method that uses KVCacheAwareADPRouter.get_relax_value or otherwise
ensure get_relax_value from KVCacheAwareADPRouter is executed), build
RequestQueueItem instances with mock_request.py_scheduling_params =
SchedulingParams() and input_token_ids like the existing test, then run the same
assignment logic (or call the public entry that triggers _assign behavior) and
assert no exception and that all requests are assigned; reference
SchedulingParams, RequestQueueItem, and KVCacheAwareADPRouter.get_relax_value to
locate and mirror the existing test flow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6573e9ed-2d0d-4e9a-98fb-c029733b7d90

📥 Commits

Reviewing files that changed from the base of the PR and between a6fc155 and b2e0040.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/pyexecutor/scheduler/adp_router.py
  • tests/unittest/_torch/executor/test_adp_router.py

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #48922 [ run ] triggered by Bot. Commit: b2e0040 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #48922 [ run ] completed with state SUCCESS. Commit: b2e0040
/LLM/main/L0_MergeRequest_PR pipeline #38670 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

@nv-guomingz

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49029 [ run ] triggered by Bot. Commit: b2e0040 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49029 [ run ] completed with state ABORTED. Commit: b2e0040

Link to invocation

@nv-guomingz

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49436 [ run ] triggered by Bot. Commit: 7577b60 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49436 [ run ] completed with state SUCCESS. Commit: 7577b60
/LLM/main/L0_MergeRequest_PR pipeline #39081 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

…ion_dp_relax is None

Signed-off-by: nv-guomingz <137257613+nv-guomingz@users.noreply.github.com>
@nv-guomingz
nv-guomingz force-pushed the user/guomingz/adp_router_enhance branch from 7577b60 to 4f1ae83 Compare May 21, 2026 01:24
@nv-guomingz

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49529 [ run ] triggered by Bot. Commit: 4f1ae83 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49529 [ run ] completed with state SUCCESS. Commit: 4f1ae83
/LLM/main/L0_MergeRequest_PR pipeline #39159 completed with status: 'SUCCESS'

CI Report

Link to invocation

@nv-guomingz
nv-guomingz merged commit e64c92b into NVIDIA:main May 21, 2026
7 checks passed
xxi-nv pushed a commit to xxi-nv/TensorRT-LLM that referenced this pull request May 22, 2026
NVIDIA#14267)

Signed-off-by: nv-guomingz <137257613+nv-guomingz@users.noreply.github.com>
bmarimuthu-nv pushed a commit to nv-auto-deploy/TensorRT-LLM that referenced this pull request May 28, 2026
NVIDIA#14267)

Signed-off-by: nv-guomingz <137257613+nv-guomingz@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.

3 participants