-
Notifications
You must be signed in to change notification settings - Fork 894
[dataset] update load_from_cache_file #5961
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
[dataset] update load_from_cache_file #5961
Conversation
Summary of ChangesHello @Jintao-Huang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request modifies the default behavior for dataset caching by setting Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request updates the default value of load_from_cache_file
to False
and adjusts the related documentation accordingly. It also centralizes the cache directory for datasets. My review identifies a significant issue in swift/llm/dataset/preprocessor/core.py
where a cache file name is incorrectly reused across different map
operations, which could lead to cache corruption or incorrect behavior. I have provided a refactoring suggestion to address this bug and eliminate code duplication, improving both correctness and maintainability.
/gemini review |
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.
Code Review
This pull request updates the default behavior of load_from_cache_file
to False
, which is a good change for encouraging more explicit control over dataset caching, especially during debugging. The extensive updates to documentation and example scripts to align with this new default are thorough and well-executed. I've identified a potential bug in the updated caching logic within swift/llm/dataset/preprocessor/core.py
, where a variable for a cache file name might be incorrectly reused across different map
operations. I've provided a specific comment with a suggested fix to address this. Overall, this is a valuable pull request that improves the framework's robustness.
if not dataset.cache_files: | ||
cache_file_name = os.path.join(get_cache_dir(), 'datasets', 'map_cache', | ||
f'{dataset._fingerprint}.arrow') |
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.
The cache_file_name
variable is being reused from a previous map
operation. If the first map
operation (for __#solution
) runs and populates the cache, this variable will hold the cache file path from that operation. When the code reaches this second map
operation, if the dataset
object's cache_files
attribute is already populated, the if
condition will be false, and the stale cache_file_name
will be passed to this map
call. This is incorrect as it could lead to using a wrong cache file. To fix this, cache_file_name
should be reset to None
before this block to ensure it's handled correctly for this specific map
operation.
cache_file_name = None
if not dataset.cache_files:
cache_file_name = os.path.join(get_cache_dir(), 'datasets', 'map_cache',
f'{dataset._fingerprint}.arrow')
No description provided.