Skip to content

feat: check request cancellation before backend dispatch - #522

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

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

Conversation

@pskiran1

Copy link
Copy Markdown
Member

A request cancelled while waiting for an execution slot is no longer passed to the backend. The check sits in TritonModelInstance::Schedule, the single point every scheduler routes through on the way to TRITONBACKEND_ModelInstanceExecute...

Signed-off-by: Sai Kiran Polisetty <spolisetty@nvidia.com>
@pskiran1
pskiran1 marked this pull request as ready for review August 31, 2026 14:05
Signed-off-by: Sai Kiran Polisetty <spolisetty@nvidia.com>
@pskiran1
pskiran1 marked this pull request as draft August 31, 2026 14:08
@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown

Greptile Summary

Adds a final cancellation check after scheduler and rate-limiter waiting but before backend dispatch.

  • Completes and removes cancelled non-sequence requests before request preparation and backend execution.
  • Avoids invoking the backend when cancellation leaves an empty batch.
  • Prevents unsuccessful or null responses from being inserted into the dynamic batcher’s response cache.
  • Preserves fixed request positions for sequence-batched models.

Confidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness or repository-rule findings.

The current code removes cancelled ordinary requests at the final backend-dispatch boundary, preserves sequence slots, avoids empty backend calls, and excludes unsuccessful responses from cache insertion. The only previous finding was manually resolved after Greptile conceded that fixed sequence positions make the exception intentional.

Important Files Changed

Filename Overview
src/backend_model_instance.cc Adds final pre-dispatch cancellation cleanup while preserving sequence-batch slot mappings and skipping empty backend executions.
src/backend_model_instance.h Declares the cancellation-cleanup helper and documents its sequence-batching exception.
src/dynamic_batch_scheduler.cc Restricts response-cache insertion to non-null responses with successful status while retaining ordered-response handling.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Scheduler forms payload] --> B[Rate limiter / execution-slot wait]
  B --> C[TritonModelInstance::Schedule]
  C --> D{Sequence batching?}
  D -->|Yes| E[Preserve fixed sequence slots]
  D -->|No| F[Complete and remove cancelled requests]
  F --> G{Requests remain?}
  G -->|No| H[Return success without backend dispatch]
  G -->|Yes| I[Prepare requests]
  E --> I
  I --> J[Backend execute callback]
  J --> K{Successful response?}
  K -->|Yes| L[Eligible for response-cache insertion]
  K -->|No| M[Deliver without caching]
Loading

Reviews (6): Last reviewed commit: "Merge branch 'main' of https://github.co..." | Re-trigger Greptile

Comment thread src/backend_model_instance.cc
…into spolisetty/tri-1741-implement-request-cancellation-for-trt-backend
@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown

Want your agent to iterate on Greptile's feedback? Try greploops.

@pskiran1
pskiran1 marked this pull request as ready for review September 3, 2026 15:34
@pskiran1 pskiran1 changed the title feat: Check request cancellation before backend dispatch feat: check request cancellation before backend dispatch Sep 8, 2026

@whoisj whoisj 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.

lgtm. thanks.

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.

3 participants