[fix] Return origin_samples instead of False in filter_long_prompt#558
[fix] Return origin_samples instead of False in filter_long_prompt#558guapisolo wants to merge 6 commits intoradixark:mainfrom
Conversation
Co-Authored-By: miles-code-angel <miles.pr.bot@gmail.com>
Co-Authored-By: miles-code-angel <miles.pr.bot@gmail.com>
Co-Authored-By: miles-code-angel <miles.pr.bot@gmail.com>
Co-Authored-By: miles-code-angel <miles.pr.bot@gmail.com>
Co-Authored-By: miles-code-angel <miles.pr.bot@gmail.com>
Co-Authored-By: miles-code-angel <miles.pr.bot@gmail.com>
Summary of ChangesHello @guapisolo, 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 introduces several key improvements across distributed training, evaluation, and utility functions. It addresses a critical type-related bug in prompt filtering, enhances the flexibility of parameter quantization ignore rules, and significantly improves the robustness of distributed weight updates through better synchronization. Furthermore, it adds a powerful feature for specifying custom generation functions on a per-sample basis, which is crucial for advanced evaluation setups. Minor adjustments to logging and configuration validation also contribute to overall system stability and usability. Highlights
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 correctly fixes a bug in filter_long_prompt where it was returning False instead of a list of samples, which violated the function's type hint. It also introduces a valuable feature for specifying a custom generation function on a per-sample basis, enhancing flexibility for evaluations. Furthermore, it includes several important correctness and synchronization fixes for the weight update process, especially concerning quantization and distributed operations. The changes are well-implemented and improve both the robustness and capabilities of the codebase. My review includes suggestions to handle empty list inputs gracefully, optimize performance by caching loaded functions, and a micro-optimization for rule checking.
| if max_length is None: | ||
| return False | ||
| return origin_samples |
There was a problem hiding this comment.
This function does not handle the case where origin_samples is an empty list. Accessing origin_samples[0] later on line 85 would raise an IndexError. It's safer to handle this case at the beginning of the function.
| if max_length is None: | |
| return False | |
| return origin_samples | |
| if max_length is None or not origin_samples: | |
| return origin_samples |
| for name, param in converted_named_params: | ||
| is_ignored = any((r.startswith("re:") and re.match(r[3:], name)) or r == name for r in ignore_rules) | ||
| is_ignored = any( | ||
| (r.startswith("re:") and re.match(r[3:], name)) or r == name or name.startswith(r) for r in ignore_rules |
There was a problem hiding this comment.
For a slight performance improvement, it's good practice to place cheaper, more common checks before more expensive ones like regex matching. Due to short-circuit evaluation of or, this can avoid some unnecessary startswith('re:') and re.match calls.
| (r.startswith("re:") and re.match(r[3:], name)) or r == name or name.startswith(r) for r in ignore_rules | |
| r == name or name.startswith(r) or (r.startswith("re:") and re.match(r[3:], name)) for r in ignore_rules |
No description provided.