fix: Fix CUDA graph execution for non-batching models#125
Conversation
Greptile SummaryThis PR fixes a long-standing CUDA graph lookup miss for non-batching models (
Confidence Score: 5/5Safe to merge; the changes are surgical, well-commented, and only affect the non-batching CUDA graph path. Both hunks make narrow, correctly reasoned changes. The key-prefix fix directly matches how input_dims is initialised at inference time. The lower_bound_key guard prevents a structural length mismatch that would break the inexact-match bounds check for non-batching models. Batching models are unaffected because both new statements remain inside if (batch_size != 0). No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant GS as Graph Capture (SetCudaGraphShape)
participant Map as cuda_graph_execs_ (sorted map)
participant RT as Inference (RunInfer)
participant LK as FindClosestCudaGraph
Note over GS: max_batch_size == 0 (non-batching model)
GS->>GS: "batch_size = graph_spec.batch_size_ → 0"
GS->>GS: "(BEFORE FIX) key prefix = {0}"
GS->>GS: "(AFTER FIX) key prefix = {1}"
GS->>GS: Per-input: append raw shape dims (no batch dim prepended)
GS->>GS: lower_bound_key: skip push_back(lower_bound_key[0]) for non-batching
GS->>Map: "insert key = {1, shape_dims...}"
Note over RT: Single non-batched request arrives
RT->>RT: "input_dims = {total_batch_size_} = {1}"
RT->>RT: "For each input: append batchn_shape (no batch dim, support_batching_=false)"
RT->>RT: "input_dims = {1, shape_dims...}"
RT->>LK: "FindClosestCudaGraph(input_dims={1, shape_dims...})"
LK->>Map: "lower_bound({1, shape_dims...})"
Map-->>LK: (BEFORE FIX) miss — stored key starts with 0
Map-->>LK: (AFTER FIX) hit — stored key starts with 1
LK-->>RT: cuda_graph (found)
Reviews (1): Last reviewed commit: "Update" | Re-trigger Greptile |
This PR fixes CUDA graph lookup for non-batching models (max_batch_size: 0).
For these models, the captured graph key used 0 as its batch-size prefix, while the runtime lookup key used 1 because one non-batched request is treated as one execution unit. The mismatch prevented Triton from finding the captured graph, causing inference to fall back to regular TensorRT execution.
TensorRT input shapes and batching behavior are unchanged.
Closes triton-inference-server/server#7150