perf(rfdetr-seg): add torch.compile vs Triton fullpost ablation benchmark#32
Open
aseembits93 wants to merge 1 commit into
Conversation
…mark Benchmarks five post-process variants on the fullpost-eligible path to evaluate whether torch.compile can match the Triton fullpost kernel: - eager: baseline torch ops (what the non-Triton path runs) - compiled: torch.compile(eager) with dynamic=True - compiled_fixed: fixed-shape torch.compile (upsample all Q masks) - compiled_hybrid: compile filter+bbox; gather+upsample survivors eager - triton: triton_rfdetr_fullpost On T4 with ~25 survivors / 720x1280: compiled_hybrid reaches 2.25x vs 2.47x for Triton. Naive torch.compile is ~1x due to graph breaks on the boolean-mask indexing chain. Remaining gap comes from the atomic-counter over-launch pattern, which has no torch.compile equivalent. Includes an NVTX-annotated mode for nsys profiling and a parity check. 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
Adds a benchmark harness that answers: can
torch.compilematch the perf of the Triton fullpost kernel (triton_rfdetr_fullpost/ W2) introduced in #31?Five variants, all producing equivalent outputs on the fullpost-eligible path (batch=1, STRETCH_TO, class remapping, no static crop):
Key findings:
torch.compileis ~1x because Dynamo graph-breaks on every boolean-mask index in the filter chain (aten.nonzerois data-dependent). Even withcapture_dynamic_output_shape_ops=True, it partitions into 7 cudagraph regions.TVF.resizeforF.interpolate— TVF defaults to antialiased (upsample_gen2d_aa_out_frame), which is ~2x slower than plain bilinear at this size.tl.atomic_add; mask kernel over-launches for all 300 queries and early-exits by reading the counter on-GPU). No torch.compile equivalent.See
development/benchmark_scripts/README_rfdetr_postproc_ablation.mdfor the full writeup.Usage
Test plan
triton_fullpostprocunavailableBase branch
Targets #31 (
perf/optimize-rfdetr-seg-plus-is-seg-dataclasses-copy) since the benchmark importstriton_rfdetr_fullpostwhich only exists on that branch.🤖 Generated with Claude Code