feat: support resume_from_checkpoint=True to auto-find last checkpoint#8050
feat: support resume_from_checkpoint=True to auto-find last checkpoint#8050zhichenggeng wants to merge 1 commit intomodelscope:mainfrom
Conversation
Summary of ChangesHello @zhichenggeng, 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 enhances the training workflow by providing a convenient way to resume from the latest available checkpoint without requiring the user to specify the exact path. By setting Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
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.
Code Review
This pull request introduces a convenient feature to automatically resume training from the last checkpoint by setting resume_from_checkpoint=True. The implementation in sft_args.py correctly handles finding the latest checkpoint, including searching through versioned subdirectories. The logic is sound and the addition of a new test case in test_resume_from_checkpoint.py ensures the feature works as expected. I have one suggestion to improve the performance and robustness of directory scanning. Overall, this is a great addition.
| subdirs = [] | ||
| for name in os.listdir(output_dir): | ||
| m = re.match(r'v(\d+)', name) | ||
| if m is not None and os.path.isdir(os.path.join(output_dir, name)): | ||
| subdirs.append((int(m.group(1)), name)) |
There was a problem hiding this comment.
For better performance and robustness when scanning for versioned subdirectories, consider using os.scandir() instead of os.listdir(). os.scandir() is more efficient as it retrieves file type information along with the file name, avoiding extra system calls to check if an entry is a directory. I've also added error handling for the directory scanning operation, which the original code was missing.
subdirs = []
try:
with os.scandir(output_dir) as it:
for entry in it:
if entry.is_dir():
m = re.match(r'v(\d+)', entry.name)
if m:
subdirs.append((int(m.group(1)), entry.name))
except OSError as e:
logger.warning(f'Could not scan directory {output_dir} for versioned subdirectories: {e}')
PR type
PR information
Support
resume_from_checkpoint="true"((case-insensitive) to automatically detect and resume from the last checkpoint inoutput_dir, without needing to specify the exact checkpoint path.Changes
_resolve_last_checkpoint()method that searches for the last checkpoint directory inoutput_dir.resume_from_checkpoint='true'Experiment results
N/A