[OMNIML-5774] Add BEVFormer ONNX PTQ and evaluation example - #2208
[OMNIML-5774] Add BEVFormer ONNX PTQ and evaluation example#2208ajrasane wants to merge 11 commits into
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (3)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
cjluo-nv
left a comment
There was a problem hiding this comment.
Bot review (claude-opus-5) — DM the bot to share feedback.
New BEVFormer-tiny ONNX PTQ example (8 files, +593). Structure closely mirrors the existing examples/onnx_ptq/petr and far3d examples (Dockerfile + prepare_calibration.py + quantize.py + pinned requirements.txt + README), reuses the shared NpzCalibrationReader from examples/onnx_ptq/quantization_utils.py rather than adding a new reader, and the modelopt.onnx.quantization.quantize() call uses valid kwargs. build_inputs has a focused unit test that covers the scene-boundary reset and the can_bus delta math, and the temporal bookkeeping in that function (deep-copying position/angle before mutating can_bus) looks correct. Size is small and cohesive. No prompt-injection content found in the PR text.
Flagging for owner sign-off rather than approving:
- Licensing / OSRB (blocks auto-approval).
prepare_calibration.pyis explicitly "Adapted from" NVIDIA/DL4AGXbevformer-int8-eq/tools/calib_data_prep.pyand carries a non-canonical header (Copyright (c) 2024, 2026 …plus an attribution line) that diverges fromLICENSE_HEADER. The Dockerfile additionally clonesDerryHub/BEVFormer_tensorrt(which vendors OpenMMLab-derived code underthird_party/), applies a DL4AGX patch, and builds mmcv/mmdetection; the README instructs users to download a third-party checkpoint and nuScenes/CAN-bus data. This is the same third-party-provenance review that was requested on the sibling PETR PR (#2180) — it needs a human/OSRB sign-off, not an automated approval. - Stacked on an unmerged base. The base branch is
ajrasane/petr(#2180), whose own review has open items and which ownsNpzCalibrationReader. The diff can only be judged final once that lands and the reader API is settled; the PR should be retargeted tomainbefore merge. - README/code mismatch on
prev_bev. The README says the script "carriesprev_bevacross frames while resetting it between scenes", butmain()never resetsprev_bev— onlyuse_prev_bevis set to 0 andcan_bus[:3]/can_bus[-1]are zeroed, so the last frame of the previous scene's BEV is what gets written into the first NPZ of the next scene and therefore into the calibration statistics for theprev_bevinput. Please confirm this matches the DL4AGX reference and either zeroprev_bevon scene change or fix the README wording. - Deferred imports without a stated reason.
from mmcv import Configandfrom third_party.bev_mmdet3d.datasets.builder import …sit insidemain(), while the PETR/FAR3Dprepare_calibration.pyscripts import at module top. The likely (and legitimate) reason is that the new unit test importsbuild_inputson a CPU-only runner without mmcv/mmdet3d — please add a one-line comment saying so, otherwise it reads as a style deviation. - Fragile container pin.
onnxruntime-gpu==1.24.0.dev20260123002comes from an Azure nightly feed; those feeds prune old dev builds, so the image build will silently start failing. A note in the README (or a documented fallback) would help.python setup.py installfor pytorch-quantization is also deprecated on modern setuptools. - Test scope. Only
build_inputsis covered; the sample loop (prev_bev propagation, thesaved != num_samplesfailure path, which currently leaves a partially populated output dir) andquantize.py's defaults are untested. Acceptable for an example, but a small fake-session test of the loop would be cheap.
|
@ajrasane thanks for creating this PR. Can you please elaborate a bit on what "temporal-state unit coverage" means? Also, what's the perf expectation between INT8 and FP8? My understanding is that they should be on par but in this example, INT8 is faster than FP8, which matches my own experience with this model too. Do we need to investigate this on ModelOpt (Q/DQ node placement differences between INT8 and FP8) or on TensorRT (kernel improvements / tactic selection in FP8)? Finally, would it make more sense to just add the FP8 results to https://github.com/NVIDIA/DL4AGX/tree/master/AV-Solutions/bevformer-int8-eq or move it here as you're proposing? If the latter, should we deprecate the workflow on DL4AGX so that there's a single source of truth? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## ajrasane/petr #2208 +/- ##
==============================================
Coverage 78.41% 78.41%
==============================================
Files 523 523
Lines 60903 60903
==============================================
Hits 47756 47756
Misses 13147 13147
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
82f926d to
e175c84
Compare
Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
Co-Authored-By: Codex <codex@openai.com> Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
Co-Authored-By: Codex <codex@openai.com> Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
Co-Authored-By: Codex <codex@openai.com> Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
Co-Authored-By: Codex <codex@openai.com> Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
Co-Authored-By: Codex <codex@openai.com> Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
Co-Authored-By: Codex <codex@openai.com> Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
Co-Authored-By: Codex <codex@openai.com> Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
e175c84 to
67a8657
Compare
Co-Authored-By: Codex <codex@openai.com> Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
Reset temporal state at scene boundaries and add loop-level coverage. Document pinned dependencies and align copied-source licensing. Co-Authored-By: Codex <codex@openai.com> Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
d0e57cf to
4c232d7
Compare
|
“Temporal-state unit coverage” means unit tests for BEVFormer’s frame-to-frame input bookkeeping.
Regarding the perf difference, I think it would be best to loop in the TensorRT team for debugging this. For now, I will keep the FP8 measurements and add a TODO for investigating the perf differences. |
7986cab to
f0bbb36
Compare
What does this PR do?
Type of change: new example
Adds an end-to-end BEVFormer-tiny ONNX PTQ example under
examples/onnx_ptq/bevformer. The example provides a pinned container environment, temporal calibration-data generation, INT8 and FP8 quantization, TensorRT engine building, full nuScenes accuracy evaluation, and latency benchmarking.The workflow extends NVIDIA's DL4AGX BEVFormer INT8 example with FP8 support and reuses the shared bounded
NpzCalibrationReaderintroduced by #2180. It also adds temporal-state unit coverage, links the example from the ONNX PTQ index, and updates the changelog.Usage
Testing
Before your PR is "Ready for review"
Make sure you read and follow Contributor guidelines and your commits are signed (
git commit -s -S).Make sure you read and follow the Security Best Practices (e.g. avoiding hardcoded
trust_remote_code=True,torch.load(..., weights_only=False),pickle, etc.).CONTRIBUTING.md: ✅Additional Information
This PR is stacked on #2180 to reuse its shared calibration reader and should be retargeted to
mainafter #2180 merges.Reference workflow: NVIDIA DL4AGX BEVFormer INT8 example.