Models · Object detection

RT-DETRv2 (ResNet-vd, S / M / M* / L / X)

RT-DETRv2 (S, M, M*, L, X; ResNet-vd, COCO) from the RT-DETR authors: real-time end-to-end detector, 300 queries and deformable attention, no NMS.

stable Fork of lyuwenyu/RT-DETR@df2a96c · backends: portable, kernels

Checkpoint

Paper 2024 Added in 0.1.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 4.10 ms 800x1344, fp16
vs the faster original 3.4× original fp32: 14.1 ms
Peak memory 137 MiB original: 196 MiB
Accuracy vs original fp32 +0.02 kernels box mAP, COCO val2017 (49.29 original)

Use it

pip install fastforks

Lean install with only what this model needs: pip install fastforks-core

from fastforks import detection

model = detection.load("rtdetrv2-s-coco")  # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.boxes  # also: scores, labels
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench rtdetrv2-s-coco

Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.

Speed and memory

Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.

Input: synthetic, 800x1344 (the task’s standard size)

BackenddtypeTime per call (ms)vs original fp32Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32incl. CPU resize + host copy (official pipeline)fp32 14.1–196 MiB/226 MiB0.30.09
Original fp16torch.autocast(fp16) around the forward; incl. CPU resize + host copy (official pipeline)fp16 16.80.84×192 MiB/220 MiB1.30.42
Portable fp32fp32not measured ––––
Portablefp16 9.601.5×137 MiB/166 MiB1.40.39
Kernelsfp16 4.103.4×137 MiB/208 MiB1.50.36
Portable + torch.compile 4.223.3×152 MiB/182 MiB37 (build)–
TensorRT fp16fp16 1.817.8×98 MiBenginenot comparable42 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-02 to 2026-11-16. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. Ratios divide two times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.

Other devices

DeviceBackenddtypems / callPeak memoryOutput vs referenceInput
Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14Originalfp3265.2 1,768 MiB process–800x1344
Portablefp1644.4 1,631 MiB processmatches800x1344
Portablefp3244.0 1,650 MiB processmatches800x1344
Kernelsfp16not implemented–800x1344
NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1613.1 110 MiB/126 MiB–800x1344
Kernelsfp164.56 111 MiB/212 MiB–800x1344
NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp169.62 110 MiB/126 MiB–800x1344
Kernelsfp162.76 112 MiB/208 MiB–800x1344
NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp168.33 110 MiB/126 MiB–800x1344
Kernelsfp164.88 112 MiB/208 MiB–800x1344
NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp169.88 110 MiB/126 MiB–800x1344
Kernelsfp164.74 113 MiB/208 MiB–800x1344
NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp163.55 134 MiB/146 MiB–800x1344
Kernelsfp162.21 158 MiB/248 MiB–800x1344

CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.

Licence and weights

Commercial use allowed

Code
Apache-2.0 LICENSE
Weights
Apache-2.0 (assumed from code)(not stated by the authors; assumed to follow the code) source
Training data
  • weights licence not stated by the original authors; assumed to be the code licence

Our reading of the licences, not legal advice.

Weights

rtdetrv2_r18vd_120e_coco_rerun_48.1.pth 81.2 MB· hosted on GitHub

fastforks downloads and checks these files on first use (fastforks download rtdetrv2-s-coco).

Accuracy

The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.

COCO val2017

every 10th image, box mAP

Rundtypebox mAP ↑Δ box mAP vs fp32 originalimagesms / image
Original fp32fp3249.29 reference 500 12.3
Original fp16fp1649.26 −0.03 500 15.8
Portable fp32fp3249.30 +0.01 500 8.72
Portablefp1649.29 ±0.00 500 8.11
Kernelsfp1649.31 +0.02 500 4.15

pycocotools COCOeval of the top 100 detections per image. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 44640884, 2026-11-17; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.

Closeness to the original

Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.2 and p99 <= 1.0 (absolute error of the output boxes).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.002 not recorded
GPU default dtypes, mean |diff|≤ 0.2 0.03739
GPU default dtypes, p99 |diff|≤ 1 0.1098

Recorded for rtdetrv2-s-coco on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-03, with these kernels: cudnn_hacc

Details

RT-DETRv2 (Lv et al. 2024, Baidu): real-time end-to-end detection; ResNet-vd backbone, hybrid encoder (one attention layer, CSP-RepVGG feature pyramid), deformable-attention decoder over 300 selected queries, no NMS; boxes, scores and COCO classes at the input size. The portable `module()` is the whole network at 640x640 (class logits and normalised boxes).

Input / output
Input: one RGB image. Output: boxes, class labels, scores and instance masks.
Input size
any H x W >= 32, padded to a multiple of 32; tested up to 3000x4000 (530 MiB allocated)
Options
  • score_threshold=0.050.0 to 1.0· changes the output
  • max_detections=100>= 1· changes the output
  • cuda_graphs=true
Outputs
boxes, scores, labels
Checkpoint
blocks=[2,2,2,2], bottleneck=false, expansion=0.5, dec_layers=3, eval_layers=3
CUDA kernels
  • cudnn_haccconvolutions with fp16 accumulation (cuDNN)
Apple (MPS)
fp32, fp16

Limitations

  • Kernels keep CUDA graphs: their private pool and static outputs stay reserved, so peak reserved is ~110 MiB above portable (peak allocated is not); `cuda_graphs=false` or `release_graphs()` frees it.
Full reference, generated from the repository

RT-DETRv2 (S, M, M*, L, X; ResNet-vd, COCO) from the RT-DETR authors: real-time end-to-end detector, 300 queries and deformable attention, no NMS.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
rtdetrv2-s-cocosynthetic (800x1344)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
14.1
16.8
9.60
4.10
4.22
1.81
196 / 226
192 / 220
137 / 166
137 / 208
152 / 182
187 / 218
rtdetrv2-m-cocosynthetic (800x1344)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
17.1
20.9
9.96
5.19
5.35
2.42
239 / 254
254 / 270
159 / 190
159 / 212
177 / 206
199 / 222
rtdetrv2-ms-cocosynthetic (800x1344)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
24.7
22.5
11.1
5.40
5.82
2.62
322 / 374
309 / 358
169 / 202
169 / 242
193 / 220
244 / 288
rtdetrv2-l-cocosynthetic (800x1344)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
30.3
38.4
12.4
6.53
7.29
3.32
366 / 424
354 / 412
180 / 200
180 / 262
204 / 238
255 / 286
rtdetrv2-x-cocosynthetic (800x1344)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
36.3
46.8
14.9
9.17
10.9
5.23
529 / 596
589 / 622
247 / 278
247 / 320
269 / 296
381 / 430
Details
  • Original code: https://github.com/lyuwenyu/RT-DETR at df2a96c8c3a0
  • Code licence: Apache-2.0 (permissive); files: LICENSE
  • Weights licence: Apache-2.0 (assumed from code)
  • Licence evidence: https://github.com/lyuwenyu/RT-DETR/blob/df2a96c8c3a098567a1149bf0248da6efe6d495d/LICENSE
  • Training data: COCO 2017 (train, instance annotations), ImageNet-1k (ILSVRC 2012 classification) (COCO 2017 train (72 to 84 epochs); the ResNet-vd backbones start from ImageNet-1k (PaddleClas) pretraining)
  • Options: score_threshold = 0.05 (0.0 to 1.0), max_detections = 100 (>= 1), cuda_graphs = True (speed only)
  • Kernel libraries: cudnn_hacc
  • Variants: rtdetrv2-s-coco, rtdetrv2-m-coco, rtdetrv2-ms-coco, rtdetrv2-l-coco, rtdetrv2-x-coco
  • Outputs: boxes, scores, labels; label_set: coco-80
  • Input size: any H x W >= 32, padded to a multiple of 32
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): rtdetrv2-s-coco 3000x4000 (0.5 GiB peak allocated, 0.6 reserved); rtdetrv2-m-coco 3000x4000 (0.5 GiB peak allocated, 0.7 reserved); rtdetrv2-ms-coco 3000x4000 (0.5 GiB peak allocated, 0.7 reserved); rtdetrv2-l-coco 3000x4000 (0.6 GiB peak allocated, 0.7 reserved); rtdetrv2-x-coco 3000x4000 (0.6 GiB peak allocated, 0.8 reserved)
  • rtdetrv2-s-coco 800x1344, first call: portable + torch.compile 37 s (cold Inductor cache), TensorRT fp16 42 s (ONNX + engine).
  • rtdetrv2-m-coco 800x1344, first call: portable + torch.compile 32 s (cold Inductor cache), TensorRT fp16 44 s (ONNX + engine).
  • rtdetrv2-ms-coco 800x1344, first call: portable + torch.compile 28 s (cold Inductor cache), TensorRT fp16 44 s (ONNX + engine).
  • rtdetrv2-l-coco 800x1344, first call: portable + torch.compile 42 s (cold Inductor cache), TensorRT fp16 48 s (ONNX + engine).
  • rtdetrv2-x-coco 800x1344, first call: portable + torch.compile 44 s (cold Inductor cache), TensorRT fp16 55 s (ONNX + engine).
  • rtdetrv2-s-coco original (fp32) 800x1344: incl. CPU resize + host copy (official pipeline)
  • rtdetrv2-s-coco original 800x1344: torch.autocast(fp16) around the forward; incl. CPU resize + host copy (official pipeline)
  • rtdetrv2-m-coco original (fp32) 800x1344: incl. CPU resize + host copy (official pipeline)
  • rtdetrv2-m-coco original 800x1344: torch.autocast(fp16) around the forward; incl. CPU resize + host copy (official pipeline)
  • rtdetrv2-ms-coco original (fp32) 800x1344: incl. CPU resize + host copy (official pipeline)
  • rtdetrv2-ms-coco original 800x1344: torch.autocast(fp16) around the forward; incl. CPU resize + host copy (official pipeline)
  • rtdetrv2-l-coco original (fp32) 800x1344: incl. CPU resize + host copy (official pipeline)
  • rtdetrv2-l-coco original 800x1344: torch.autocast(fp16) around the forward; incl. CPU resize + host copy (official pipeline)
  • rtdetrv2-x-coco original (fp32) 800x1344: incl. CPU resize + host copy (official pipeline)
  • rtdetrv2-x-coco original 800x1344: torch.autocast(fp16) around the forward; incl. CPU resize + host copy (official pipeline)
  • rtdetrv2-s-coco load / first call: original 1.32 s / 0.417 s, portable 1.37 s / 0.389 s, kernels 1.51 s / 0.361 s
  • rtdetrv2-m-coco load / first call: original 0.45 s / 0.023 s, portable 1.45 s / 0.37 s, kernels 1.64 s / 0.329 s
  • rtdetrv2-ms-coco load / first call: original 0.52 s / 0.057 s, portable 1.51 s / 0.344 s, kernels 1.8 s / 0.31 s
  • rtdetrv2-l-coco load / first call: original 0.66 s / 0.043 s, portable 1.54 s / 0.358 s, kernels 1.89 s / 0.301 s
  • rtdetrv2-x-coco load / first call: original 1.13 s / 0.076 s, portable 1.79 s / 0.322 s, kernels 2.14 s / 0.285 s
  • Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5

Measured

pycocotools COCOeval of the top 100 detections per image. Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32original fp16portableportable fp32kernelsnote
rtdetrv2-s-cocoCOCO val2017, every 10th image, box mAP49.2949.2649.2949.3049.31
rtdetrv2-m-cocoCOCO val2017, every 10th image, box mAP49.8349.8149.8449.8349.79
rtdetrv2-ms-cocoCOCO val2017, every 10th image, box mAP51.9751.9851.9551.9651.96
rtdetrv2-l-cocoCOCO val2017, every 10th image, box mAP54.5254.5754.5154.5554.49
rtdetrv2-x-cocoCOCO val2017, every 10th image, box mAP55.5155.5455.5155.5655.49

Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 44640884, 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.

Parity

CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.2 and p99 <= 1.0 (absolute error of the output boxes).

variantkernels error vs original, mean / p99GPU, torchkernels used
rtdetrv2-s-coco0.03739 / 0.1098RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
rtdetrv2-m-coco0.06517 / 0.13434RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
rtdetrv2-ms-coco0.06765 / 0.17406RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
rtdetrv2-l-coco0.04387 / 0.1019RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
rtdetrv2-x-coco0.05571 / 0.2201RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400

Limitations

  • Kernels keep CUDA graphs: their private pool and static outputs stay reserved, so peak reserved is ~110 MiB above portable (peak allocated is not); cuda_graphs=false or release_graphs() frees it.

Example output

One fixed input through this checkpoint, the same for every model of the task (kernels · float16 · NVIDIA GeForce RTX 5060 Ti).

Input
Output
  • person 0.95
Astronaut Eileen Collins, input
Input · 100%

Input: Astronaut Eileen Collins, NASA (public domain).