Skip to content

Implement abstract per-GPU cache helper class - #814

Merged
scotts merged 4 commits into
meta-pytorch:mainfrom
dvrogozh:cache
Aug 19, 2025
Merged

Implement abstract per-GPU cache helper class#814
scotts merged 4 commits into
meta-pytorch:mainfrom
dvrogozh:cache

Conversation

@dvrogozh

Copy link
Copy Markdown
Collaborator

This commit introduces per-GPU cache helper class based on original design of the cache in CUDA device interface. New helper allows to store and reuse HW contexts which are expensive to create. Class is templated and allows storing different object types. At the moment it's applied to cache CUDA ffmpeg device contexts (AVBufferRef) and NPP contexts (NppStreamContext). Class can be further reused in non-CUDA device implementations.

CC: @scotts, @NicolasHug, @eromomon

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 13, 2025

@NicolasHug NicolasHug left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PR @dvrogozh , and for addressing our NppCtx cache TODOs! I made minor comments below, but this looks great overall. I'd also let @scotts take a look.

Comment thread src/torchcodec/_core/Cache.h Outdated
Comment thread src/torchcodec/_core/Cache.h Outdated
Comment thread src/torchcodec/_core/CudaDeviceInterface.cpp Outdated
Comment thread src/torchcodec/_core/Cache.h Outdated
Comment thread src/torchcodec/_core/Cache.h
Comment thread src/torchcodec/_core/Cache.h Outdated
@scotts

scotts commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

@dvrogozh, thank you for working on this! These abstractions are very much needed. The small tweaks to the implementation we talked about should be enough.

dvrogozh and others added 3 commits August 18, 2025 18:02
This commit introduces abstract per-GPU cache helper class. It allows
to store and reuse HW contexts which are expensive to create. Class
is abstract and allows storing different object types.

Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>

@scotts scotts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dvrogozh, this looks great, thank you!

@dvrogozh

Copy link
Copy Markdown
Collaborator Author

FAILED test/test_encoders.py::TestAudioEncoder::test_num_channels

These ci failures seem unrelated.

@scotts

scotts commented Aug 19, 2025

Copy link
Copy Markdown
Contributor

@dvrogozh, yup, agreed, it's a problem we know about and should start tracking. I'm going to merge.

@scotts
scotts merged commit c3eea9f into meta-pytorch:main Aug 19, 2025
46 of 47 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.

3 participants