[ROCm] Add rocJPEG support for GPU JPEG decoding (backport of pytorch/vision#9342)#10
Merged
jithunnair-amd merged 1 commit intoJul 16, 2026
Conversation
Backport of pytorch#9342 adapted to the release/0.26 (classic, non stable-ABI) JPEG decoder layout. Adds a rocJPEG-backed GPU JPEG decode path for ROCm builds, gated by TORCHVISION_USE_ROCJPEG / ROCJPEG_FOUND, alongside the existing nvJPEG CUDA path. This enables decode_jpeg(..., device="cuda") on ROCm for UNCHANGED, GRAY and RGB modes using rocJPEG's hardware backend. rocJPEG uses ROCJPEG_BACKEND_HARDWARE, which rejects images smaller than 64x64 and 4:1:1/unknown chroma subsampling.
ethanwee1
added a commit
to ROCm/pytorch
that referenced
this pull request
Jul 8, 2026
Points the release/2.11 torchvision pin at ROCm/vision#10 (backport of pytorch/vision#9342, rocJPEG GPU JPEG decode).
jithunnair-amd
left a comment
Collaborator
There was a problem hiding this comment.
@ethanwee1 Since this PR is a reimplemented version of the upstream PR, can you please run the torchvision tests that would test the decoding functionality to establish equivalence? Please post the results in the Validation section of the PR description.
ethanwee1
added a commit
to ROCm/pytorch
that referenced
this pull request
Jul 16, 2026
Updates the release/2.11 torchvision pin to the merged ROCm/vision release/0.26 commit 3d50b2155c02d26e78b9c09baf99f5c707d70215 (ROCm/vision#10).
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.
What this does
Backports rocJPEG GPU JPEG decoding (upstream pytorch#9342) to
release/0.26, sodecode_jpeg(..., device="cuda")works on ROCm (MI300 / gfx94X) using rocJPEG's hardware backend forUNCHANGED,GRAY, andRGBmodes. Gated byTORCHVISION_USE_ROCJPEG/ROCJPEG_FOUND, alongside the existing nvJPEG CUDA path.Why this is a manual backport (not a cherry-pick)
#9342was merged againstmain, which has since diverged significantly fromrelease/0.26. Agit cherry-pickdoes not apply. The change had to be re-implemented against therelease/0.26layout:torch::stable::Tensor,STABLE_TORCH_LIBRARY_IMPL,common_stable.*, the separateimage_stableextension).release/0.26has none of that, so the decoder was rewritten with the classictorch::Tensor/at::empty/TORCH_CHECKAPI.io/image/hip/decode_jpegs_cuda.cpp. Onrelease/0.26the ROCm build hipifiesio/image/cuda/*intohip/, so the rocJPEG path lives incuda/decode_jpegs_cuda.{cpp,h}guarded by#if ROCJPEG_FOUNDand flows through hipify (verified: it transforms cleanly intohip/decode_jpegs_hip.cppwith thedecode_jpegs_cudasymbol and allrocJpeg*calls intact).release/0.26registers via a single.op("image::decode_jpegs_cuda", ...)inimage.cpp, so the upstream dual#if !ROCJPEG_FOUNDregistration split was not needed.USE_ROCJPEG+ROCJPEG_FOUNDdetection tomake_image_extension(noSTABLE_SOURCES/image_stableplumbing, which don't exist here).Changes
torchvision/csrc/io/image/cuda/decode_jpegs_cuda.h-RocJpegDecoderclass +CHECK_ROCJPEG/CHECK_HIPmacros under#if ROCJPEG_FOUND.torchvision/csrc/io/image/cuda/decode_jpegs_cuda.cpp- rocJPEG decode implementation (classic API); stub guard changed to#if !NVJPEG_FOUND && !ROCJPEG_FOUND.setup.py-TORCHVISION_USE_ROCJPEG/ROCJPEG_FOUNDdetection androcjpeglinkage.test/test_image.py-IS_ROCMtolerance bump for decode; skip GPU JPEG encoder tests (rocJPEG is decode-only).torchvision/io/image.py- docstring note about the rocJPEG path.Capability notes
rocJPEG uses
ROCJPEG_BACKEND_HARDWARE, which rejects images smaller than 64x64 and 4:1:1 / unknown chroma subsampling.Validation
Built via TheRock "Multi-Arch Build Portable Linux PyTorch Wheels" against this pin: https://github.com/ROCm/TheRock/actions/runs/28960912700
test_unary_ufuncs.pyuint8thresholdOverflowError), not JPEG/torchvision.Companion PR
Pin bump in ROCm/pytorch
release/2.11: ROCm/pytorch#3411