Skip to content

feat: check request cancellation before batch assembly - #127

Open
pskiran1 wants to merge 3 commits into
mainfrom
spolisetty/tri-1741-implement-request-cancellation-for-trt-backend
Open

feat: check request cancellation before batch assembly#127
pskiran1 wants to merge 3 commits into
mainfrom
spolisetty/tri-1741-implement-request-cancellation-for-trt-backend

Conversation

@pskiran1

@pskiran1 pskiran1 commented Sep 3, 2026

Copy link
Copy Markdown
Member

What does the PR do?

The PR checks TRITONBACKEND_RequestIsCancelled for each request in Run() and, when every request in the batch has been cancelled, responds and returns without submitting any work to the engine.

TensorRT issues a batch as a single asynchronous submission — one enqueueV3, a cudaGraphLaunch replay, or a multi-device fan-out — so there is no intermediate point at which partial work can be abandoned. The only actionable checkpoint is before the batch is assembled, which is where this check sits.

Scope is deliberately whole-batch only. Dropping a subset of requests from a forming batch would require re-deriving the batch size, shape tensor values and optimization profile selection, and is not worth the complexity unless profiling shows a meaningful rate of mid-batch cancellations.

Related PRs

Signed-off-by: Sai Kiran Polisetty <spolisetty@nvidia.com>
@pskiran1
pskiran1 marked this pull request as ready for review September 3, 2026 14:09
@pskiran1
pskiran1 marked this pull request as draft September 3, 2026 14:10
@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge with no outstanding actionable issue identified.

Summary

  • Queries cancellation only until a live request or query failure is encountered.
  • Returns cancelled responses without enqueueing fully cancelled batches.
  • Excludes implicit-state models so required state updates still occur.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Receive request batch] --> B{Uses implicit state?}
  B -- Yes --> E[Assemble and execute batch]
  B -- No --> C{All requests cancelled?}
  C -- No --> E
  C -- Query error --> E
  C -- Yes --> D[Send cancelled responses]
  D --> F[Return without TensorRT submission]
Loading

Signed-off-by: Sai Kiran Polisetty <spolisetty@nvidia.com>
@pskiran1 pskiran1 changed the title feat: Check request cancellation before batch assembly feat: check request cancellation before batch assembly Sep 8, 2026
Comment thread src/instance_state.cc Outdated
// execution. The batch-size, number of inputs, and size of each
// input has already been checked so don't need to do that here.
payload_->total_batch_size_ = 0;
bool all_requests_cancelled =

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.

Is all_requests_cancelled a descriptive name for the value assigned here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The initial value represents whether execution may be skipped, not whether all requests are already known to be cancelled. I renamed all_requests_cancelled to skip_batch_execution for better naming convention.

Signed-off-by: Sai Kiran Polisetty <spolisetty@nvidia.com>
@pskiran1
pskiran1 requested a review from yinggeh September 9, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants