Skip to content

Conversation

dvrogozh
Copy link
Contributor

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
Copy link
Member

@NicolasHug NicolasHug left a comment

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.

@scotts
Copy link
Contributor

scotts commented Aug 18, 2025

@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 <[email protected]>
Signed-off-by: Dmitry Rogozhkin <[email protected]>
Signed-off-by: Dmitry Rogozhkin <[email protected]>
Copy link
Contributor

@scotts scotts left a comment

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
Contributor Author

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

These ci failures seem unrelated.

@scotts
Copy link
Contributor

scotts commented Aug 19, 2025

@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 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