unsloth
unsloth copied to clipboard
Remove grpo requirement bs=num_generations
instead of forcing batch size = num_generations we remove the requirement. This allows for gradient accumulation on entire rollout groups.
The constraint is only forced in a scenario where steps_per_generation is None, generation_batch_size is None and batch_size*gradient_accumulation % num_generations != 0.
This has the added benefit of being backward compatible with our GRPO notebooks.
Qwen3: https://colab.research.google.com/drive/11W2iNnXji4orPGLMUwcHVfpHsy605QH2?usp=sharing GPT: https://colab.research.google.com/drive/118z5T-85I4gsZvDr36yLfGJ4Lya7qP-V?usp=sharing Gemma Vision: https://colab.research.google.com/drive/1S2VyBOVzsM4gyb7-I-I6BP__zoOmDDJ4?usp=sharing
Summary of Changes
Hello @mmathew23, I'm Gemini Code Assist[^1]! 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 refactors the batch size handling within the GRPO trainer to remove a previously enforced strict equality between per_device_train_batch_size and num_generations. This modification significantly enhances training flexibility by enabling gradient accumulation over full rollout groups. The batch size adjustment mechanism is now more intelligent, only intervening under specific conditions related to generation steps, batch size, gradient accumulation, and distributed training setup, ensuring broader applicability without breaking existing workflows.
Highlights
- Relaxed Batch Size Constraint: The strict requirement for
per_device_train_batch_sizeto be a direct multiple ofnum_generationsin GRPO training has been significantly relaxed. - Enabled Gradient Accumulation: This change now allows for effective gradient accumulation across entire rollout groups, providing greater flexibility in training configurations.
- Conditional Batch Size Adjustment: The automatic adjustment of
per_device_train_batch_sizetonum_generationsnow only occurs under specific conditions: whensteps_per_generationandgeneration_batch_sizeareNone, and the product ofbatch_size,gradient_accumulation_steps, andworld_sizeis not a multiple ofnum_generations. - Backward Compatibility: The updated logic maintains full backward compatibility with existing GRPO notebooks, ensuring no disruption to current workflows.
Using Gemini Code Assist
The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
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 :thumbsup: and :thumbsdown: 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.
[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.
ran all the grpo notebooks and they are all running successfully.
llama3.1: https://colab.research.google.com/drive/1MOpPjlYlKXTyI4fP_7cyu0baNM3T5B6t?usp=sharing mistral: https://colab.research.google.com/drive/1Y8KvsQsivm5MPrzSgdQD4yWzfDs88o6o?usp=sharing phi4: https://colab.research.google.com/drive/1iuTjllWxQjbiMn_5d5kBU_hChEz0HxsZ?usp=sharing llama 3.2: https://colab.research.google.com/drive/12tKwxmQ-yJaPLI2oMgHvMCkt9MnQyGk0?usp=sharing gemma vision: https://colab.research.google.com/drive/1tan7D9N_W_tOahWa5bUkwTDn1GGVJqDI?usp=sharing gemma 1b: https://colab.research.google.com/drive/1Xjjax-tEVG1cBPJNVswH_ZAr1BfnIQRD?usp=sharing deepseek: https://colab.research.google.com/drive/1BBmFC09whVgxB8ItgFJkh8dAEuk62sG0?usp=sharing gpt 2048: https://colab.research.google.com/drive/1quGOFcG2k52sU7JMD6jI1f1ijFFO84DR?usp=sharing gpt: https://colab.research.google.com/drive/1nuWeTFeOkPQJJ_939fvFj3OCSzi0XS46?usp=sharing qwen3: https://colab.research.google.com/drive/1iZzQd9raDt2VdmchHiiIPfL-CbB9BJAw?usp=sharing qwen3vl: https://colab.research.google.com/drive/17kyoClwIAHNDumZ3S19RIL1M0h9Xvm46?usp=sharing openenv: https://colab.research.google.com/drive/1M2tKVMt4zZJ_jZrS228xaEZ23L_GaLsD?usp=sharing openenvbf16: https://colab.research.google.com/drive/1QM1kqt9d8ChdAlJRDHW2qrdnPXSY63kz?usp=sharing