[trl] vllm trl topk fixup#3935
Conversation
* remote unused hybridcache * cleanup
for more information, see https://pre-commit.ci
Summary of ChangesHello @Datta0, 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 resolves a critical compatibility issue between 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. 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 targeted fix for the top_k parameter within GRPOConfig when using vLLM. By setting top_k to -1 if it's None or 0, it correctly resolves a compatibility issue that caused errors during SamplingParams creation in vLLM. The PR also includes several minor whitespace cleanups, which improve code style and readability. The changes are well-implemented and address the issue effectively.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d72e3fe403
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| def grpo_config_fix_vllm_top_k(old_RLTrainer_source, old_RLConfig_source): | ||
| return "if use_vllm and (top_k is None or top_k == 0): top_k = -1\n" |
There was a problem hiding this comment.
Guard top_k fix for older TRL configs
The injected snippet always references top_k (and use_vllm) without checking whether the GRPOConfig signature actually includes it. In TRL versions prior to the linked PR, top_k isn’t defined in the config __init__, so when use_vllm is True this line will raise a NameError during config construction. Other config patches in this file guard on old_RLConfig_source (e.g., num_generations), so this should similarly check that top_k exists before injecting the line to avoid breaking vLLM users on older TRL versions.
Useful? React with 👍 / 👎.
* [transformers] [v5] remove unused hybridcache (unslothai#3910) * remote unused hybridcache * cleanup * Fix top_k on trl GRPO * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Daniel Han <danielhanchen@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Fix top_k for GRPO vLLM.
huggingface/trl#4695 with this change trl added top_k in GRPOConfig and defaults to 0
We don't want that since vllm's all include top_k is -1 and 0 returns an error on SamplingParams creation. (Comparison between None and 0 or something error)