METEOR2 v1.1: fp16-safe Gather-form ONNX, TensorRT build script and checks
Browse filesFiles changed (5)
- README.md+46-10
- SHA256SUMS+3-2
- build_trt_engine.pyAdded+88
- deploy_metadata.yaml+1-1
- meteor2_gather.onnx+2-2
94 unmodified lines959697989910010110210310410510610710810911087 unmodified lines1981992002012022032042052062072082092102112122132142152162172182192202212226 unmodified lines22923023123223323494 unmodified lines| `meteor2_npu.onnx` | 1.48 GB | NPU form, plain ONNX in a single file (the low-rank lift maps are initializers). No calibration input || `meteor2_npu.pt` | 1.48 GB | NPU form, PyTorch checkpoint (EMA weights, no optimizer state, architecture arguments only). Source of the ONNX || `meteor2_npu.param.yaml` | | Same for the NPU form || `deploy_metadata.yaml` | | Deployment metadata recording the artifact version of this repository || `SHA256SUMS` | | Checksums of every file in this repository |> **TensorRT engines are not distributed here.** Engines are specific to the GPU architecture and> TensorRT version they are built on; build them locally from the ONNX files. These ONNX files were> checked with onnxruntime only (see Provenance); a TensorRT build of them has not been verified.> The NPU-form ONNX is the plain floating-point graph of the evaluation path; vendor-specific graph> layouts for a particular accelerator tool chain are produced by `deploy/export_mite_ckpt.py` in the> repository from the checkpoint.## Inputs and outputs (ONNX)**Inputs**87 unmodified linespublished path errors were measured with it. Behaviour with a zero history has not been characterisedfor these weights.- **Single frame.** No temporal memory; the perception outputs do not use previous frames.- **Deployment.** No TensorRT or accelerator build of these ONNX files has been verified.## Provenance| | || --- | --- || Original source | <https://github.com/tier4/METEOR> (`bevlane/meteorite.py`; the ONNX graphs are the evaluation path `forward_geo` with every side input made a graph input) || This repository | `AutowareFoundation/meteor2`, tag `v1.0` || Export | 2026-12-02, PyTorch 2.11.0 TorchScript exporter, opset 17, constant folding; from `meteor2_gather.pt` / `meteor2_npu.pt` || Check | onnxruntime 1.23.2 (CPU) against the PyTorch model in fp32 on 24 validation frames (one per scene), with route, without route and with the speed forced to 0 / 0.29 / 0.31 m/s || ONNX vs PyTorch fp32 (worst case over all runs) | Gather form | NPU form || --- | --- | --- || Runs (frames) | 55 (24) | 55 (24) || Ego path, max waypoint difference (3 s and 6 s, all candidates) | 0.0229 cm | 0.0229 cm || BEV segmentation argmax agreement (min) | 100.0000 % | 99.9997 % || Occupancy argmax agreement (min) | 99.9994 % | 99.9997 % || Box heatmap logits, max abs difference | 4.8e-05 | 5.0e-05 || Largest abs difference over all 14 outputs (logits) | 1.1e-03 | 1.1e-03 |The ONNX files take uint8 images, while the validation pipeline behind the results table feeds floatimages (scaled to 0..1 before the resize to 1152 × 648). Rounding those images to uint8 changes the6 unmodified linespaths were removed; every tensor is unchanged). The image normalisation and the stop gate (0.3 m/s) arepart of the ONNX graphs. One operator was rewritten for the export: the adaptive average pooling in the6 s head (200 × 125 → 16 × 10) is expressed as two constant `MatMul`s with the same averaging weights.## References94 unmodified lines959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014187 unmodified lines2292302312322332342352362372382392402412422432442452462472482492502512522532546 unmodified lines26126226326426526626726826927094 unmodified lines| `meteor2_npu.onnx` | 1.48 GB | NPU form, plain ONNX in a single file (the low-rank lift maps are initializers). No calibration input || `meteor2_npu.pt` | 1.48 GB | NPU form, PyTorch checkpoint (EMA weights, no optimizer state, architecture arguments only). Source of the ONNX || `meteor2_npu.param.yaml` | | Same for the NPU form || `build_trt_engine.py` | | Builds a TensorRT engine from either ONNX file (fp32, fp16, or fp16 with the camera projection kept in fp32) || `deploy_metadata.yaml` | | Deployment metadata recording the artifact version of this repository || `SHA256SUMS` | | Checksums of every file in this repository |> **TensorRT engines are not distributed here.** Engines are specific to the GPU architecture and> TensorRT version they are built on; build them locally from the ONNX files with `build_trt_engine.py`> (see [TensorRT](#tensorrt)).> The NPU-form ONNX is the plain floating-point graph of the evaluation path; vendor-specific graph> layouts for a particular accelerator tool chain are produced by `deploy/export_mite_ckpt.py` in the> repository from the checkpoint.## TensorRT```bashpip install tensorrt # tested with TensorRT 10.16python3 build_trt_engine.py meteor2_gather.onnx meteor2_gather_fp16.engine --fp16 --geometry-fp32python3 build_trt_engine.py meteor2_npu.onnx meteor2_npu_fp16.engine --fp16````--geometry-fp32` keeps the camera-projection layers of the Gather form (the layers whose inputs dependonly on `K`, `T_cam_ego` and constants) in fp32. It did not slow the engine in our measurement and brings the fp16 outputscloser to fp32; it has no effect on the NPU form. Without `--fp16` the engine runs in fp32 (TF32 off).Engines built with these settings (TensorRT 10.16.1, data-center GPU), compared with the PyTorch model in fp32, on the24 validation frames of [Provenance](#provenance):| | Gather fp32 | Gather fp16 + `--geometry-fp32` | Gather fp16 | NPU fp32 | NPU fp16 || --- | --- | --- | --- | --- | --- || NaN / Inf in any output | none | none | none | none | none || Same ego-path candidate chosen | 100 % | 100 % | 100 % | 100 % | 100 % || Ego path, max waypoint difference (mean / worst frame) | 0.002 / 0.009 cm | 10.7 / 30.7 cm | 12.5 / 31.4 cm | 0.002 / 0.006 cm | 11.6 / 33.1 cm || 6 s ADE on these frames (PyTorch fp32: 2.219 m Gather, 2.245 m NPU) | 2.219 m | 2.226 m | 2.228 m | 2.245 m | 2.250 m || BEV segmentation argmax agreement (mean) | 99.99 % | 99.90 % | 99.82 % | 99.99 % | 99.92 % || Occupancy argmax agreement (mean / worst frame) | 99.98 / 99.97 % | 99.28 / 98.85 % | 98.76 / 98.14 % | 99.97 / 99.95 % | 99.58 / 99.26 % || Box heatmap probability, max abs difference (mean / worst frame) | 0.000 / 0.000 | 0.039 / 0.124 | 0.058 / 0.129 | 0.000 / 0.000 | 0.006 / 0.013 |The fp16 engines change box scores near the detection threshold, so a few detections can appear ordisappear compared with fp32. AP and mIoU were not re-measured through TensorRT.v1.0 note: the Gather-form ONNX of tag `v1.0` leaves the fp16 range inside the camera projection, and a TensorRT fp16 engine built from it returns NaN. Use the ONNX of `v1.1` or later for fp16.## Inputs and outputs (ONNX)**Inputs**87 unmodified linespublished path errors were measured with it. Behaviour with a zero history has not been characterisedfor these weights.- **Single frame.** No temporal memory; the perception outputs do not use previous frames.- **Deployment.** TensorRT 10.16 builds were checked on 24 frames (see [TensorRT](#tensorrt)); otherTensorRT versions, Jetson / DRIVE devices and other accelerator tool chains have not been verified.## Provenance| | || --- | --- || Original source | <https://github.com/tier4/METEOR> (`bevlane/meteorite.py`; the ONNX graphs are the evaluation path `forward_geo` with every side input made a graph input) || This repository | `AutowareFoundation/meteor2`, tag `v1.1` (`v1.0`: same checkpoints and NPU-form ONNX; Gather-form ONNX before the fp16 fix) || Export | NPU form 2026-12-02, Gather form 2026-12-04 (v1.1); PyTorch 2.11.0 TorchScript exporter, opset 17, constant folding; from `meteor2_gather.pt` / `meteor2_npu.pt` || Check | onnxruntime 1.23.2 (CPU) against the PyTorch model in fp32 on 24 validation frames (one per scene), with route, without route and with the speed forced to 0 / 0.29 / 0.31 m/s || ONNX vs PyTorch fp32 (worst case over all runs) | Gather form | NPU form || --- | --- | --- || Runs (frames) | 55 (24) | 55 (24) || Ego path, max waypoint difference (3 s and 6 s, all candidates) | 0.0183 cm | 0.0229 cm || BEV segmentation argmax agreement (min) | 99.9998 % | 99.9997 % || Occupancy argmax agreement (min) | 99.9992 % | 99.9997 % || Box heatmap logits, max abs difference | 2.0e-04 | 5.0e-05 || Largest abs difference over all 14 outputs (logits) | 1.4e-03 | 1.1e-03 |The ONNX files take uint8 images, while the validation pipeline behind the results table feeds floatimages (scaled to 0..1 before the resize to 1152 × 648). Rounding those images to uint8 changes the6 unmodified linespaths were removed; every tensor is unchanged). The image normalisation and the stop gate (0.3 m/s) arepart of the ONNX graphs. One operator was rewritten for the export: the adaptive average pooling in the6 s head (200 × 125 → 16 × 10) is expressed as two constant `MatMul`s with the same averaging weights.In the Gather form (v1.1) the camera projection divides before it multiplies by the focal length andclamps the ray slope to ±8 and the sampling grid to ±2; this only touches cells that lie outside everyimage, so the fp32 outputs are unchanged within the tolerances above, and it keeps every intermediatevalue inside the fp16 range.## References
1234567efe0fc07ecdead49f54420ce856900135777851651eb85bc84bea2dee8462957 .gitignorec71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 LICENSE6bd2eba88475af5e5a823eb39b6994e1c45a820049e73500f40a114dd0f3fb03 deploy_metadata.yamle203175d17e67162ec82b2cf580f8c3479d8840f7be1ad634ba97d1e1b37b08a meteor2_gather.onnxa2eaf4c5858ee8c6556b0f50e232dda2407c114a944aebf22feae10f37085e60 meteor2_gather.param.yaml721c51476a5a37806f2ebb23cccce43a3a3592445786a7bcc88c6e110b81e16b meteor2_gather.ptb23023b395f3f6c472102a5b106f3962f32d3e28640e088993e3516ed746e196 meteor2_npu.onnx12345678efe0fc07ecdead49f54420ce856900135777851651eb85bc84bea2dee8462957 .gitignorec71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 LICENSE869bf3342137bb59b4d8c8463babb1628d420fe5d7b2da88e8a386d092a68ad6 build_trt_engine.py6fd5674a29573ceceeaa5e6920ecce56db0a3348f4284df5fb9f9fe9922008f8 deploy_metadata.yamlc7a2bcfc7f6bda6bd61c4993af609e4556bf8ab2b67c0794d282672cfa8748ad meteor2_gather.onnxa2eaf4c5858ee8c6556b0f50e232dda2407c114a944aebf22feae10f37085e60 meteor2_gather.param.yaml721c51476a5a37806f2ebb23cccce43a3a3592445786a7bcc88c6e110b81e16b meteor2_gather.ptb23023b395f3f6c472102a5b106f3962f32d3e28640e088993e3516ed746e196 meteor2_npu.onnx
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788#!/usr/bin/env python3"""Build a TensorRT engine from a METEOR2 ONNX file.
python3 build_trt_engine.py meteor2_gather.onnx meteor2_gather_fp16.engine --fp16 python3 build_trt_engine.py meteor2_gather.onnx meteor2_gather_fp16g.engine --fp16 --geometry-fp32
--fp16 allow fp16 kernels (default: fp32, TF32 off)--geometry-fp32 with --fp16: keep the camera-projection subgraph of the Gather form in fp32. These are the layers whose inputs depend only on K / T_cam_ego and constants (ego points -> camera -> pixel column and depth-bin coordinates that feed GridSample). They are cheap elementwise layers; keeping them in fp32 brings the fp16 engine closer to the fp32 outputs (see the model card). No effect on the NPU form.--workspace-gb builder workspace (default 4)
Tested with TensorRT 10.16. Engines are specific to the GPU and the TensorRT version they are built with."""import argparseimport time
import tensorrt as trt
GEOMETRY_INPUTS = ("K", "T_cam_ego")FLOAT_TYPES = (trt.float32, trt.float16)
def geometry_layers(net): """Indices of layers whose every input is derived only from K / T_cam_ego and constants.""" geo = {net.get_input(i).name for i in range(net.num_inputs) if net.get_input(i).name in GEOMETRY_INPUTS} const_like = set() picked = [] for i in range(net.num_layers): L = net.get_layer(i) ins = [L.get_input(j) for j in range(L.num_inputs) if L.get_input(j) is not None] if L.type in (trt.LayerType.CONSTANT,) or (ins and all(t.name in const_like for t in ins)) or not ins: for j in range(L.num_outputs): const_like.add(L.get_output(j).name) continue if ins and all(t.name in geo or t.name in const_like for t in ins) and any(t.name in geo for t in ins): for j in range(L.num_outputs): geo.add(L.get_output(j).name) if L.type != trt.LayerType.SHAPE and all(L.get_output(j).dtype in FLOAT_TYPES for j in range(L.num_outputs)): picked.append(i) return picked
def main(): ap = argparse.ArgumentParser() ap.add_argument("onnx") ap.add_argument("engine") ap.add_argument("--fp16", action="store_true") ap.add_argument("--geometry-fp32", action="store_true") ap.add_argument("--workspace-gb", type=int, default=4) a = ap.parse_args() log = trt.Logger(trt.Logger.WARNING) b = trt.Builder(log) flags = 0 if int(trt.__version__.split(".")[0]) >= 10 else 1 << int(trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH) net = b.create_network(flags) p = trt.OnnxParser(net, log) with open(a.onnx, "rb") as f: if not p.parse(f.read()): raise SystemExit("\n".join(str(p.get_error(i)) for i in range(p.num_errors))) cfg = b.create_builder_config() cfg.set_memory_pool_limit(trt.MemoryPoolType.WORKSPACE, a.workspace_gb << 30) if a.fp16: cfg.set_flag(trt.BuilderFlag.FP16) else: cfg.clear_flag(trt.BuilderFlag.TF32) if a.geometry_fp32: assert a.fp16, "--geometry-fp32 only makes sense with --fp16" idx = geometry_layers(net) for i in idx: L = net.get_layer(i) L.precision = trt.float32 for j in range(L.num_outputs): L.set_output_type(j, trt.float32) cfg.set_flag(trt.BuilderFlag.OBEY_PRECISION_CONSTRAINTS) print(f"geometry subgraph kept in fp32: {len(idx)} layers") t0 = time.time() ser = b.build_serialized_network(net, cfg) if ser is None: raise SystemExit("engine build failed") with open(a.engine, "wb") as f: f.write(ser) print(f"saved {a.engine} ({ser.nbytes / 1e6:.0f} MB) in {time.time() - t0:.0f} s, TensorRT {trt.__version__}, " f"{'fp16' if a.fp16 else 'fp32'}{' + geometry fp32' if a.geometry_fp32 else ''}")
if __name__ == "__main__": main()1version: v1.01version: v1.1
123version https://git-lfs.github.com/spec/v1oid sha256:e203175d17e67162ec82b2cf580f8c3479d8840f7be1ad634ba97d1e1b37b08asize 82275565123version https://git-lfs.github.com/spec/v1oid sha256:c7a2bcfc7f6bda6bd61c4993af609e4556bf8ab2b67c0794d282672cfa8748adsize 82276059
README.md+46-10
SHA256SUMS+3-2
build_trt_engine.pyAdded+88
deploy_metadata.yaml+1-1
meteor2_gather.onnx+2-2