Repository navigation
fix(deformable-detr): preserve image aspect ratio - #1753
Merged
Merged
Conversation
Match the benchmark checkpoint, revision and input dimensions to the native manifest. Keep the accuracy reference usable after removal of the legacy qualification package by loading its optional performance harness only on that path. Preserve every existing numerical criterion. Refs: NVIDIA#1671 Signed-off-by: Yizhuo Zhang <yizhuoz@nvidia.com>
Use checkpoint resize bounds and dynamic spatial shapes for the native detector. Derive positions, reference points, normalization and attention geometry from the actual unpadded feature maps instead of stretching every image to a square. Add independent dynamic-geometry and resize regressions without changing existing correctness criteria. Older family bundles require rebuilding for the new resize metadata and dynamic engine. Refs: NVIDIA#1671 Signed-off-by: Yizhuo Zhang <yizhuoz@nvidia.com>
Reject pathological aspect ratios that the checkpoint processor leaves outside the engine profile before invoking inference. Keep the builder optimization policy immediately after config creation as required by repository validation. Signed-off-by: Yizhuo Zhang <yizhuoz@nvidia.com>
15 tasks done
yizhuoz004
marked this pull request as ready for review
October 16, 2026 20:45
18 tasks done
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.
Background
Stage 4 (#1671, epic #1667) has nine qualified object detectors from merged #1718 and one remaining supported checkpoint,
SenseTime/deformable-detr. Its benchmark profile incorrectly copied RT-DETR's checkpoint, revision and 640x640 size. The standalone accuracy reference also imported the qualification framework removed in #1742 before handling a request.Real corpus validation then exposed a native defect: stretching every image to 800x800 dropped mAP by 2.74 percentage points and mAP50 by 3.13 points versus the canonical aspect-preserving FP32 reference, exceeding both unchanged two-point gates. A diagnostic FP32 square-resize run closely matched native results, locating the first divergence at input geometry.
Exit Criteria
Qualify Deformable DETR's actual FP16 bundle through its unchanged owning checkpoint case, 100 original-image corpus/native/HTTP checks, existing mAP gates, and real published PyPI AIPerf. Reconcile every current-main detector and close stage 4 only after this PR merges. This finishes the ten canonical checkpoints for single-image object detection; other precisions and workloads retain separate status.
Implementation
Keep all production behavior and numerical checks in
families/deformable_detr. Read checkpoint shortest/longest-edge bounds and preserve image aspect ratio without padding. Build a dynamic TensorRT spatial profile and derive positions, reference points, GroupNorm reshapes and attention geometry from actual feature-map sizes. Reject invalid or out-of-profile geometry before inference. TensorRT still owns GPU lowering and tactics; no custom kernel, platform branch or sibling dependency is added.Correct benchmark identity and dimensions to match the existing pinned native manifest. Import the removed legacy performance harness only on that existing legacy mode so
--request/--outputaccuracy execution works independently. Add native resize/bounds cases, configuration tests and an independent NumPy/PyTorch dynamic-geometry regression inside the single owning E2E case. Update the detection guide with the model name, profile and rebuild instruction.The public Task API, ABI, bundle container format, dependencies, labels, coordinates, scores and every original correctness threshold remain unchanged. Family
runtime.jsongains required resize bounds and the plan becomes dynamic: rebuild older Deformable DETR bundles. There is no old-bundle fallback.Change categories
Validation
Commands and Results
On
cf93a041d8c0660f2e3e3ad0a4e4008b70cfd26cwith a clean worktree:PYTHONPATH=core/builder:. python -m pytest families/deformable_detr/tests/test_model.py -q: 18 passed.ctest --test-dir "$RUNTIME_ROOT" -R '^deformable_detr_preprocess_and_decode$' --output-on-failure: 1 passed, including aspect-ratio and engine-bound regressions.PYTHONPATH=core/builder:. python -m pytest families/deformable_detr/tests/test_e2e.py --e2e-model deformable-detr-r50 --e2e-testcase deformable-detr-r50 -q -s: one executed, non-skipped case passed. SetTRTMC_BINARY,TRTMC_RUNTIME_ROOT,TRTMC_DEFORMABLE_DETR_MODEL_DIRto the prepared CLI/runtime and exact pinned snapshot. This builds the actual bundle, checks dynamic positions/attention against independent NumPy/PyTorch for landscape/portrait/square shapes, then compares native checkpoint detections with the official reference. The fixture reports worst IoU 0.9953 and score delta 0.0074; original IoU >= 0.5 and score delta <= 0.05 rules are unchanged.PYTHONPATH=apps/aiperf_qual:apps/benchmark:apps/perf_serving:core/builder:. python -m trtmc_aiperf_qual endpoint-profile --environment "$ENVIRONMENT" --profile deformable-detr-r50 --bundle "$BUNDLE" --inputs "$INPUTS/inputs.jsonl" --out "$RESULTS": 100 complete native/HTTP input-output comparisons passed, followed by 50/50 measured requests and 5/5 warmups through real PyPI AIPerf; 463 complete boxes (2315 coordinate/confidence values) checked, zero client errors or missing request/metric joins.ENVIRONMENTselects the prepared native runtime, server interpreter and pip-installed client;BUNDLEis the exact owning-case artifact below. PrepareINPUTSusing the checked-inapps/aiperf_qual/examples/prepare_detection_inputs.pyas shown in the usage guide._box_iou,_detections,_coco_ap_at_iou,_coco_detection_metrics. The evaluator is kept outside source commits; this does not restore the removed framework.PYTHONPATH=core/builder:apps/benchmark:apps/aiperf_qual:. python -m pytest tools/tests/test_architecture.py tools/tests/test_family_impact.py apps/aiperf_qual/tests/test_endpoint_catalog.py apps/aiperf_qual/tests/test_endpoint_profile.py -q: 91 passed in a detached exact-head review checkout.PYTHONPATH=core/builder:apps/benchmark:. python -m tools.model_ci validate,python tools/test_impact.py --validate, Ruff, clang-format andgit diff --check github/main...HEAD: pass. Impact selects onlydeformable_detrplus generic CPU/docs checks.npm --prefix website run test:model-support: 14 passed;npm --prefix website run build: pass, including all 34 diagram checks.Ten-detector benchmark results
All rows use one complete original RGB image per request, FP16/TP1, one persistent replica, concurrency 1, five warmups and 50 measured requests, published AIPerf 0.13.0,
/v1/inferwith endpoint typeimage_retrieval. HTTP latency andpublic_task_call_wallare separate; native Task time includes family preprocessing/inference/postprocessing and excludes transport decoding. Build/load/startup, correctness/verification calls and warmup are excluded from measured timing. These short integration runs establish no capacity or performance gate.The nine existing rows retain their original tested source
ad6ca2e0c60b2327c2c7a62350a54dda5b5f3f9band bundle/checkpoint identities in #1718. Their families and serving/runtime paths are unchanged by this PR and intervening main changes; they were not remeasured on this head. Deformable DETR is newly measured on the head above. The development host is shared, so the observed timings are not controlled speedup comparisons.deformable-detr-r50detr-resnet-50rtdetr-v2-r18yolo11nyolos-smallyolov10nyolov10syolov10xyolov5nyolov8nCorpus values below are percentages on the same 100 original COCO images. Preserve each family's label space and filtering. YOLOS has no existing dataset benchmark gate; its unchanged owning reference case passes separately.
deformable-detr-r50detr-resnet-50rtdetr-v2-r18yolo11nyolos-smallyolov10nyolov10syolov10xyolov5nyolov8nHardware, Environment, and Revisions
Base
268e03e56c9206d21611e5943c656ab97c4a08e1; tested sourcecf93a041d8c0660f2e3e3ad0a4e4008b70cfd26c. One NVIDIA GB300, Linux aarch64, Python 3.12.3, CUDA toolkit 13.3, driver 580.105.08, TensorRT 11.1.0.106, PyTorch 2.12.0+cu130, Transformers 5.2.0, timm 1.0.28, Pillow 12.3.0, published AIPerf 0.13.0. The strict FP32 micro-regression disables TF32 only for its probe; production FP16 arithmetic is unchanged.Checkpoint
SenseTime/deformable-detr@83ecd26945199939cb82806f988debdb71e6f43e. Profile: FP16, TP1, 800-pixel shortest-edge target / 1333-pixel longest-edge bound, confidence threshold 0.3, top 100. Datasetdetection-datasets/coco@cf0b22332314a937e9dc8a1957b21725430bb41d, validation split, the same pinned first-100-eligible original RGB selection as #1718, with complete dimensions, byte hashes and annotations retained. Reference is canonical FP32.Actual native-correctness/served bundle SHA-256:
4001c40acaaac239e6c65f2f8eb6f38985c07f943bee200447a2311520f7879e(89283054 bytes). All generated bundles, selections, records and reports are preserved outside commits.Not Run / Remaining Gaps
Other precisions, hardware targets, TP variants, batching, multiple images, streaming, document understanding outside the detection Task, and capacity sweeps are unqualified by these runs. The legacy performance CLI still depends on the upstream-deleted framework and is not restored or claimed here. Current-head CI must finish before merge. No additional canonical checkpoint gap remains in the refreshed ten-detector inventory.
Contributor Self-Review
Notes For Future Readers
Review checkpoint geometry first, then dynamic graph layout and runtime bindings, then the independent regression and corpus evidence. Rebuild older Deformable DETR artifacts with the corrected family. All production changes are family-local; shared serving code preserves the family's numeric labels, complete boxes/scores and coordinates without reinterpretation. No new third-party dependency, vendored source, binary, weight, fixture or dataset is redistributed. The pinned checkpoint was already owned by the native manifest; benchmark metadata now matches it.
Closes #1671. Other epic workloads keep their own stages and evidence.
Risk level
The family now uses aspect-preserving preprocessing, dynamic spatial tensors and mandatory resize metadata. Exact-bundle model/corpus/client proof passes without relaxing any gate; older bundles require rebuilding, and additional targets/configurations remain untested.