use a set instead of list for VAECache unprocessed file lookups#2841
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request improves VAECache membership-check performance by introducing a cached set view of local_unprocessed_files, keeping it in sync when the underlying list is reassigned, and updating the hot-path checks to use the set. It also adds a unit test to verify that the cache refreshes correctly when the list object changes.
Changes:
- Added
_local_unprocessed_files_setand_local_unprocessed_files_set_sourceplus_local_unprocessed_file_set()to cache a set derived fromlocal_unprocessed_files. - Updated
_reduce_bucket()andprocess_buckets()to use the cached set for membership checks instead of the list. - Added a unit test to ensure the cached set updates when
local_unprocessed_filesis reassigned.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
simpletuner/helpers/caching/vae.py |
Adds and uses a cached set for fast membership checks against local_unprocessed_files, with cache reset on rediscovery. |
tests/test_vae.py |
Adds a unit test validating the cached set refreshes when the underlying list is replaced. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request optimizes how the
VAECacheclass handles and checks membership in thelocal_unprocessed_fileslist by introducing a cached set representation, which improves performance and ensures correctness when the file list changes. It also adds a unit test to verify this behavior.Performance and correctness improvements:
_local_unprocessed_files_set) and its source tracker toVAECache, with a helper method_local_unprocessed_file_set()that keeps the set in sync withlocal_unprocessed_filesand is used for faster membership checks. [1] [2]_reduce_bucketandprocess_buckets) to use the cached set for membership checks instead of the list, improving performance and correctness. [1] [2] [3]Nonewheneverdiscover_unprocessed_filesupdates the file list, ensuring the cache stays accurate.Testing:
test_local_unprocessed_file_set_tracks_reassigned_file_listto verify that the cached set properly tracks changes tolocal_unprocessed_files.