Skip to content

[https://nvbugs/5955173][fix] Add abort method for GenerationResultBase#11970

Merged
JunyiXu-nv merged 2 commits intoNVIDIA:mainfrom
JunyiXu-nv:dev-junyi-no-abort-bug
Mar 12, 2026
Merged

[https://nvbugs/5955173][fix] Add abort method for GenerationResultBase#11970
JunyiXu-nv merged 2 commits intoNVIDIA:mainfrom
JunyiXu-nv:dev-junyi-no-abort-bug

Conversation

@JunyiXu-nv
Copy link
Collaborator

@JunyiXu-nv JunyiXu-nv commented Mar 6, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added functionality to abort individual generation requests with comprehensive status tracking and verification.
    • Abort status is now properly tracked and reliably propagated through the entire processing pipeline to ensure system-wide consistency.
  • Tests

    • Added comprehensive tests validating abort functionality, request status visibility, and propagation across the system.

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)

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

Signed-off-by: Junyi Xu <219237550+JunyiXu-nv@users.noreply.github.com>
@JunyiXu-nv JunyiXu-nv requested a review from a team as a code owner March 6, 2026 03:33
@JunyiXu-nv JunyiXu-nv requested a review from hchings March 6, 2026 03:34
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

📝 Walkthrough

Walkthrough

These changes introduce an abort mechanism for generation results. A new should_abort field is added to PostprocWorker.Output, and base-level abort handling is implemented in GenerationResultBase with accessor methods. When responses signal abort, this state propagates to the result objects, and GenerationResult inherits this behavior through the base class.

Changes

Cohort / File(s) Summary
Abort Mechanism in Result Classes
tensorrt_llm/executor/result.py
Introduces abort() and aborted() methods in GenerationResultBase with private _aborted flag; refactors GenerationResult.abort() to delegate to base class via super().abort() and removes redundant _aborted initialization; adds propagation logic in response handling to trigger abort when response.should_abort is true.
Abort Signal in Postprocessing
tensorrt_llm/executor/postproc_worker.py
Adds should_abort: bool = False field to PostprocWorker.Output NamedTuple; propagates abort state from request records to output in handle_single_input.
Unit Tests for Abort Functionality
tests/unittest/llmapi/test_executor.py
Adds test cases verifying abort() and aborted() behavior on GenerationResultBase and DetokenizedGenerationResultBase, and confirms should_abort flag propagation through PostprocWorker.Output to result abortion.

Sequence Diagram

sequenceDiagram
    participant PostprocWorker
    participant Response as PostprocWorker.Output
    participant Handler as _handle_response
    participant Result as GenerationResult

    PostprocWorker->>Response: Create Output with should_abort
    Response->>Handler: Emit output signal
    Handler->>Handler: Check response.should_abort
    alt should_abort is True
        Handler->>Result: Call abort()
        Result->>Result: Delegate via super().abort()
        Note over Result: Sets _aborted flag in base class
    end
    Handler->>Result: Store output in results
    Result->>Result: aborted() returns True
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only the template placeholders with no actual content filled in for Description, Test Coverage, or PR Checklist items left unchecked. Replace template placeholders with actual content: explain the issue and solution in the Description section, list relevant test cases in Test Coverage, and ensure all PR Checklist items are properly reviewed and marked.
Docstring Coverage ⚠️ Warning Docstring coverage is 47.06% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding an abort method for GenerationResultBase to fix a bug referenced in the NVBugs ticket.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/unittest/llmapi/test_executor.py`:
- Around line 337-370: Rename the three test functions to snake_case to match
project conventions: change test_abort_on_GenerationResultBase to
test_abort_on_generation_result_base,
test_abort_on_DetokenizedGenerationResultBase to
test_abort_on_detokenized_generation_result_base, and
test_PostprocWorker_Output_should_abort to
test_postproc_worker_output_should_abort; update any local references or
fixtures that call these function names (if any) and run the test suite to
ensure discovery still works (look for these symbols:
test_abort_on_GenerationResultBase,
test_abort_on_DetokenizedGenerationResultBase,
test_PostprocWorker_Output_should_abort).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b00e8800-123b-4383-9ba4-fd4dfd2826b1

📥 Commits

Reviewing files that changed from the base of the PR and between dd61fd5 and 5c1008b.

📒 Files selected for processing (3)
  • tensorrt_llm/executor/postproc_worker.py
  • tensorrt_llm/executor/result.py
  • tests/unittest/llmapi/test_executor.py

@JunyiXu-nv
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #37956 [ run ] triggered by Bot. Commit: 5c1008b Link to invocation

@tensorrt-cicd
Copy link
Collaborator

PR_Github #37956 [ run ] completed with state SUCCESS. Commit: 5c1008b
/LLM/main/L0_MergeRequest_PR pipeline #29395 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

Link to invocation

Signed-off-by: Junyi Xu <219237550+JunyiXu-nv@users.noreply.github.com>
@JunyiXu-nv
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38175 [ run ] triggered by Bot. Commit: ea1471c Link to invocation

@tensorrt-cicd
Copy link
Collaborator

PR_Github #38175 [ run ] completed with state SUCCESS. Commit: ea1471c
/LLM/main/L0_MergeRequest_PR pipeline #29574 completed with status: 'SUCCESS'

Link to invocation

Copy link
Collaborator

@hchings hchings left a comment

Choose a reason for hiding this comment

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

LGTM.

@JunyiXu-nv JunyiXu-nv merged commit a865b6c into NVIDIA:main Mar 12, 2026
5 checks passed
JunyiXu-nv added a commit to JunyiXu-nv/TensorRT-LLM that referenced this pull request Mar 12, 2026
…se (NVIDIA#11970)

Signed-off-by: Junyi Xu <219237550+JunyiXu-nv@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