perf(trt): zero-copy CUDA graph replay + cross-stream event handshake#35
Open
aseembits93 wants to merge 1 commit into
Open
perf(trt): zero-copy CUDA graph replay + cross-stream event handshake#35aseembits93 wants to merge 1 commit into
aseembits93 wants to merge 1 commit into
Conversation
Drops the per-replay DtoD copy and output clone on the TRT CUDA-graph replay path. Callers opt in by setting ``_trt_reuse_as_input_buffer`` on their preallocated input tensor (graph is captured against that buffer and reused in-place). Output buffers are returned directly; consumers chain on ``_trt_produce_event`` and record into ``consumer_done_event`` so the next replay waits on the prior consumer instead of the host. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Drops the per-replay DtoD copy and output clone on the TRT CUDA-graph replay path, and replaces the trailing
stream.synchronize()ininfer_from_trt_enginewith a_trt_produce_eventrecorded on the graph's own capture stream (or the caller's stream when no graph ran)._trt_reuse_as_input_bufferon the caller's input tensor: when set, the graph is captured against that buffer and subsequent replays skip the copy into the graph's internal input buffer.buf.clone()); consumers that read directly can record intoconsumer_done_eventso the next replay waits on the prior consumer on the graph's stream..cpu()/.item()still work (those insert their own sync); cross-stream consumers should wait onresults[0]._trt_produce_event.End-to-end benchmark
rfdetr-seg-nano TRT, Tesla T4, FP16 engine,
vehicles_312px.mp4, 538 frames, 4 post-warmup runs per config. Isolating this change only (no other opt-in perf paths):Δ +4.56 FPS (+4.0%)
Parity verified vs graphs-off run: bit-exact xyxy / conf / class_id and mask MD5 per detection.
How to reproduce
Minimal benchmark script (save as
bench_rfdetr_seg.pyat repo root):Commands (1 warmup + 4 measured runs per config; take the mean of the 4):
Each run prints a final
frames=… elapsed=…s fps=…line; drop the first run per config as warmup and average the remaining four.Test plan
inference_modelsTRT integration suite on a CUDA host.cpu()syncs)Generated with Claude Code