Skip to content

[WIP][video][cuda] NVDECCache eviction policy, static implementation#1243

Open
vkhalidov wants to merge 1 commit intomainfrom
vkhalidov/nvdeccache_eviction_policy_static
Open

[WIP][video][cuda] NVDECCache eviction policy, static implementation#1243
vkhalidov wants to merge 1 commit intomainfrom
vkhalidov/nvdeccache_eviction_policy_static

Conversation

@vkhalidov
Copy link
Contributor

@vkhalidov vkhalidov commented Feb 16, 2026

Summary

Adds the notion of statically defined eviction policy to NVDECCache. Eviction policy decides which entry should leave the cache when it's full and a new decoder needs to be created. This PR suggests the following API for an eviction policy:

 - void onInsert(CacheIterator it)      // Called when entry is added
 - void onRemove(CacheIterator it)      // Called when entry is removed
 - CacheIterator selectForEviction()    // Returns iterator to evict
 - bool empty() const                   // Returns true if nothing to evict

Three example policies are provided:

 - LRUEvictionPolicy     // Least Recently Used eviction policy
 - FIFOEvictionPolicy    // First In, First Out eviction policy
 - NoEvictionPolicy      // No eviction, rejects new entries when the cache is full (used before this PR)

LRUEvictionPolicy is proposed as the default eviction policy.

Test Plan

Benchmarks were run on a set of 1200 diverse videos of 132 different resolutions; top 10 resolution buckets are:

  Count Resolution
    200 720x720
    189 720x1280
    180 640x640
    140 720x900
     70 480x480
     59 360x640
     35 640x360
     30 640x800
     21 480x600
     18 720x406

On the plots below, different numbers of frames at different frame steps were extracted from these videos using different numbers of worker threads by decoders using this PR (with eviction) and decoders before this PR (baseline). Throughput in terms of the number of decoded frames per second (FPS) is plotted as a function of the number of worker threads (# threads).

15 decoded frames:
Screenshot 2026-02-16 at 09 10 05

30 decoded frames:
Screenshot 2026-02-16 at 09 12 25

60 decoded frames:
Screenshot 2026-02-16 at 09 13 51

90 decoded frames:
Screenshot 2026-02-16 at 09 14 46

Conclusion

Eviction policy brings advantage in terms of performance and scaling across almost all the settings. However, if the number of decoded frames is too small (e.g. 15 frames at frame step 1) or too big (60 frames at larger frame steps, 90 frames), cache eviction seems to no longer yield advantage.

@pytorch-bot
Copy link

pytorch-bot bot commented Feb 16, 2026

🔗 Helpful Links

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

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

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 Feb 16, 2026
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