-
Notifications
You must be signed in to change notification settings - Fork 64
Support CPU fallback for videos that don't get decoded by nvdec #792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NicolasHug
merged 13 commits into
meta-pytorch:main
from
NicolasHug:enable10bitscudaAV_PIX_FMT_CUDA
Jul 30, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a9b6d46
Add proper checks for 10bit videos on CUDA
NicolasHug 0ea6f40
Avoid silently wrong results on 10bit CUDA
NicolasHug ed095ec
Add TORCHCODEC_CMAKE_BUILD_DIR
NicolasHug 3f5f0cb
Merge branch 'speedup-build' into enable10bitscuda
NicolasHug 9b55f72
Support P010LE, very WIP. Color conversion matrix is wrong.
NicolasHug 275cb18
Fix matrix. Currently assumes BT701
NicolasHug bd716c5
Handle 601, kinda
NicolasHug 83d78f3
Fallback on CPU for 10bits videos that aren't supported by nvdec
NicolasHug 5a6d1de
Merge branch 'main' of github.com:pytorch/torchcodec into enable10bit…
NicolasHug 816c486
Merge branch 'main' of github.com:pytorch/torchcodec into enable10bit…
NicolasHug 5d79e14
comments
NicolasHug a3d524d
Handle pre-alloated tensor
NicolasHug 6d85afe
Linter
NicolasHug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the case where NVDEC is unable to decode a frame stops occurring, will this test still pass?
In other words, would we expect the frames to not be equal when decoded by GPU vs CPU?
This testing approach looks good overall. I wonder if we could use pytest patch / mocks to check that
cpuInterface->convertAVFrameToFrameOutput
gets called, but it's not urgent at the moment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If NVDEC is suddenly able to decode this frame on the GPU, then we'd be failing this other check a bit later:
That's because this video is 10bits, so it's not in AV_PIX_FMT_NV12 format.
That's only for the current state of this PR though. In #790 which I'm working on, we'll be able to remove this
actualFormat == AV_PIX_FMT_NV12
check.You're right, it'd be great if we could do that. Right now we're only testing at a high level that this video can be decoded, but we don't know for sure that it's going through the cpu path. Well, we know it does because of our previous tests, but it's true that this is a weak guarantee.
I don't know how we could easily test this from python/pytest, because this is a very low-level C++ path and I'm not sure how to mock it. But that's a great point, ideally this is what we should test.