Skip to content

Add CUDA jpeg decoding to benchmark - #1620

Merged
NicolasHug merged 1 commit into
meta-pytorch:mainfrom
NicolasHug:bench-nvjpeg
Aug 12, 2026
Merged

Add CUDA jpeg decoding to benchmark#1620
NicolasHug merged 1 commit into
meta-pytorch:mainfrom
NicolasHug:bench-nvjpeg

Conversation

@NicolasHug

Copy link
Copy Markdown
Contributor

Results of both CPU and CUDA decoders:

~/dev/torchcodec-cuda (main*) » python benchmarks/decoders/benchmark_image_decoders.py                                                                                         nicolashug@nicolashug-fedora-PW0H326Y
torch.get_num_threads()=1, OMP_NUM_THREADS=1
Note: libavif/dav1d internal threading is not exposed by decode_avif (library default).
Source: in-memory bytes

## Decode-to-tensor median latency (ms), 1 thread, 50 runs

format device res      size KB  torchcodec      PIL       tv   FFmpeg   PIL/tc    tv/tc  FFmpeg/tc
--------------------------------------------------------------------------------------------------
jpeg   cpu    320p        71.1       0.786    1.034    0.782    1.393    1.32x    1.00x      1.77x
jpeg   cpu    480p       138.0       1.576    2.229    1.573    2.572    1.41x    1.00x      1.63x
jpeg   cpu    720p       251.4       3.056    4.477    3.068    4.305    1.46x    1.00x      1.41x
jpeg   cpu    1080p      446.4       5.981    9.249    6.013    8.224    1.55x    1.01x      1.37x
png    cpu    320p       372.5       4.446    5.124    4.441    7.606    1.15x    1.00x      1.71x
png    cpu    480p       753.3       9.743   11.188    9.730   16.407    1.15x    1.00x      1.68x
png    cpu    720p      1431.0      20.758   23.930   20.749   34.890    1.15x    1.00x      1.68x
png    cpu    1080p     2634.8      43.975   51.255   44.150   74.635    1.17x    1.00x      1.70x
webp   cpu    320p        66.2       3.671    4.226    3.686    9.473    1.15x    1.00x      2.58x
webp   cpu    480p       124.1       7.266    8.318    7.278   18.362    1.14x    1.00x      2.53x
webp   cpu    720p       202.1      12.736   15.043   12.706   31.318    1.18x    1.00x      2.46x
webp   cpu    1080p      327.6      22.597   28.618   22.576   54.957    1.27x    1.00x      2.43x
gif    cpu    320p       157.7       2.284    1.660    2.445    1.781    0.73x    1.07x      0.78x
gif    cpu    480p       325.3       5.132    3.640    5.508    3.644    0.71x    1.07x      0.71x
gif    cpu    720p       656.5      11.364    7.992   12.290    7.364    0.70x    1.08x      0.65x
gif    cpu    1080p     1292.4      25.085   17.451   27.322   15.908    0.70x    1.09x      0.63x
avif   cpu    320p        69.1       5.266    5.719      N/A   10.262    1.09x      N/A      1.95x
avif   cpu    480p       130.3      10.378   11.241      N/A   19.951    1.08x      N/A      1.92x
avif   cpu    720p       221.3      17.731   19.655      N/A   33.666    1.11x      N/A      1.90x
avif   cpu    1080p      341.1      28.005   33.355      N/A   53.226    1.19x      N/A      1.90x
heic   cpu    320p       136.4      19.211   19.573      N/A   12.441    1.02x      N/A      0.65x
heic   cpu    480p       273.8      38.346   38.201      N/A   25.298    1.00x      N/A      0.66x
heic   cpu    720p       509.5      71.578   64.586      N/A   48.758    0.90x      N/A      0.68x
heic   cpu    1080p      899.0     136.545  119.747      N/A   91.335    0.88x      N/A      0.67x
jpeg   cuda   320p        71.1       0.750      N/A    0.757      N/A      N/A    1.01x        N/A
jpeg   cuda   480p       138.0       1.466      N/A    1.434      N/A      N/A    0.98x        N/A
jpeg   cuda   720p       251.4       2.735      N/A    2.698      N/A      N/A    0.99x        N/A
jpeg   cuda   1080p      446.4       5.145      N/A    5.083      N/A      N/A    0.99x        N/A

(PIL/tc, tv/tc and FFmpeg/tc > 1.0 mean torchcodec is faster.)

## Batch decode JPEG on CUDA, median ms, 50 runs (same image repeated)

res    batch    torchcodec       tv    tv/tc    tc/img    tv/img
----------------------------------------------------------------
320p   1             0.749    0.744    0.99x     0.749     0.744
320p   16           10.719   10.520    0.98x     0.670     0.657
320p   64           42.830   41.775    0.98x     0.669     0.653
480p   1             1.460    1.461    1.00x     1.460     1.461
480p   16           21.164   20.684    0.98x     1.323     1.293
480p   64           84.132   82.215    0.98x     1.315     1.285
720p   1             2.723    2.714    1.00x     2.723     2.714
720p   16           39.788   39.196    0.99x     2.487     2.450
720p   64          159.036  155.975    0.98x     2.485     2.437
1080p  1             5.149    5.082    0.99x     5.149     5.082
1080p  16           74.006   72.609    0.98x     4.625     4.538
1080p  64          295.248  289.212    0.98x     4.613     4.519

(tv/tc > 1.0 means torchcodec is faster.)

@pytorch-bot

pytorch-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/meta-pytorch/torchcodec/1620

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 21 Pending

As of commit c86c657 with merge base 574d78a (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 12, 2026
@NicolasHug
NicolasHug merged commit 95434fc into meta-pytorch:main Aug 12, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant