Skip to content

upgrade trl==0.19.1#2892

Merged
winglian merged 12 commits into
mainfrom
trl-upgrade
Jul 14, 2025
Merged

upgrade trl==0.19.1#2892
winglian merged 12 commits into
mainfrom
trl-upgrade

Conversation

@winglian
Copy link
Copy Markdown
Collaborator

@winglian winglian commented Jul 9, 2025

Description

Motivation and Context

How has this been tested?

Screenshots (if appropriate)

Types of changes

Social Handles (Optional)

Summary by CodeRabbit

  • New Features

    • Added new configuration options for vLLM, including support for specifying data parallel size and vLLM operation mode.
    • Enhanced RL training configuration with additional vLLM-related parameters for more flexible deployment.
  • Bug Fixes

    • Improved worker initialization consistency in training data loaders.
    • Unified and simplified dataloader preparation logic for GRPO trainers.
  • Chores

    • Updated dependency versions for huggingface_hub and trl.
    • Expanded CI test matrix to cover additional vLLM and CUDA configurations.
  • Tests

    • Adjusted training loss threshold in multi-GPU test to reflect updated performance expectations.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 9, 2025

Warning

Rate limit exceeded

@winglian has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between be64aac and c963dad.

📒 Files selected for processing (9)
  • .github/workflows/multi-gpu-e2e.yml (1 hunks)
  • requirements.txt (1 hunks)
  • src/axolotl/cli/vllm_serve.py (2 hunks)
  • src/axolotl/core/trainers/grpo/__init__.py (2 hunks)
  • src/axolotl/core/trainers/grpo/trainer.py (1 hunks)
  • src/axolotl/utils/schemas/trl.py (2 hunks)
  • src/axolotl/utils/schemas/vllm.py (1 hunks)
  • tests/e2e/multigpu/solo/test_grpo.py (1 hunks)
  • tests/e2e/multigpu/test_llama.py (1 hunks)

Walkthrough

This update introduces configuration enhancements for vLLM integration, including new fields for data parallelism and mode selection. Workflow testing is expanded to cover additional CUDA, Python, and PyTorch versions. The GRPO trainer's dataloader logic is refactored for consistency, and dependency versions for huggingface_hub and trl are updated.

Changes

File(s) Change Summary
requirements.txt Updated huggingface_hub to >=0.33.0, transformers to 4.53.2, and trl to 0.19.1.
.github/workflows/multi-gpu-e2e.yml Added a new test matrix entry for CUDA 12.6.3, Python 3.11, PyTorch 2.7.0, and axolotl_extras: vllm.
src/axolotl/cli/vllm_serve.py Removed patch_vllm_worker() call; added handling and passing of data_parallel_size to arguments.
src/axolotl/core/trainers/grpo/trainer.py Removed custom get_train_dataloader; unified logic in _prepare_dataloader with improved worker init.
src/axolotl/core/trainers/grpo/init.py Enhanced set_training_args_kwargs to include new vLLM config parameters based on vllm_mode.
src/axolotl/utils/schemas/vllm.py Added optional data_parallel_size field to VllmConfig.
src/axolotl/utils/schemas/trl.py Added optional vllm_mode field to TRLConfig.
tests/e2e/multigpu/test_llama.py Increased acceptable loss threshold in test_ds_zero3_packed from 2.4 to 2.45.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Config
    participant VllmServe
    participant AxolotlScriptArguments

    User->>CLI: Start vLLM serve command
    CLI->>Config: Load configuration
    Config-->>CLI: Return config (may include data_parallel_size)
    CLI->>VllmServe: Call do_vllm_serve(config, cli_args)
    VllmServe->>AxolotlScriptArguments: Instantiate with data_parallel_size
    AxolotlScriptArguments-->>VllmServe: Arguments ready
    VllmServe->>CLI: Start vLLM server with arguments
Loading

Possibly related PRs

  • axolotl-ai-cloud/axolotl#2769: Removes and replaces the get_train_dataloader method in AxolotlGRPOTrainer, directly related to the trainer logic changes in this PR.
  • axolotl-ai-cloud/axolotl#2814: Updates the trl package version in requirements.txt, related to the dependency update in this PR.

Suggested reviewers

  • djsaunde
  • SalmanMohammadi

Poem

In the warren where the configs grow,
New fields for vLLM now softly show.
Trainers unified, dependencies rise,
CI hops nightly under CUDA skies.
With parallel dreams and modes anew,
This rabbit cheers the work you do! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c370d07 and 20b35e0.

📒 Files selected for processing (1)
  • requirements.txt (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: PyTest (3.11, 2.7.0)
  • GitHub Check: test-axolotl-multigpu (126, 12.6.3, 3.11, 2.6.0, 2, true)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.1)
  • GitHub Check: pre-commit
  • GitHub Check: test-axolotl-multigpu (126, 12.6.3, 3.11, 2.7.1, 2, true)
  • GitHub Check: PyTest from Source Dist (3.11, 2.6.0)
  • GitHub Check: PyTest (3.11, 2.6.0)
  • GitHub Check: PyTest (3.11, 2.7.1)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.0)
  • GitHub Check: pre-commit

Comment thread requirements.txt
datasets==3.6.0
deepspeed>=0.17.0
trl==0.18.2
trl==0.19.1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Upgrade acknowledged – please double-check runtime compatibility with TRL 0.19.1

trl 0.19.x introduced several breaking-change PRs (e.g. the new AutoModelForCausalLMWithValueHead split, renamed callbacks, and stricter accelerate/transformers minimums). While the pinned transformers==4.53.1 and accelerate==1.8.1 versions in this repo satisfy the new lower-bounds, any in-tree training scripts that relied on the older APIs may now error at runtime.

Run the quick scan below to surface the most common API symbols that changed between 0.18 → 0.19 and make sure they’re not used:

Expected result: no matches.
If matches appear, those call-sites must be migrated to the new APIs before merging to avoid runtime failures.


🏁 Script executed:

#!/usr/bin/env bash
# Look for TRL identifiers that were removed/renamed in 0.19
rg -n --type py -e 'AutoModelForSequenceClassificationWithValueHead' \
                -e 'create_reference_model' \
                -e 'CONFIG_NAME.json' \
                -e 'RewardTrainer' \
                -e 'RewardConfig' \
                -e 'ReinforceTrainer' \
                -e 'PPOTrainer.*reference_model' \
                -e 'CausalLMWithValueHead' \
                -e 'DPOTrainer.*ref_model'

Length of output: 1288


Breaking Change: Update In-Tree TRL API Usage for 0.19.1

Quick scan detected legacy TRL identifiers that were removed or renamed in 0.19.0–0.19.1. These call-sites must be migrated before merging to avoid runtime errors:

• src/axolotl/core/training_args.py
– Line 11: from trl import …, RewardConfig
– Line 55: class AxolotlRewardConfig(…, RewardConfig):
• src/axolotl/core/builders/causal.py
– Multiple references to AxolotlRewardTrainer and AxolotlRewardConfig (wrappers over TRL’s old APIs)
• src/axolotl/core/trainers/trl.py
– Line 11: import RewardTrainer
– Lines 107–111: class AxolotlRewardTrainer(…, RewardTrainer)
• src/axolotl/core/trainers/init.py
– Line 16: exports AxolotlRewardTrainer

Please replace these with the new 0.19.x equivalents (e.g. use the split AutoModelForCausalLMWithValueHead, updated config classes, and renamed trainer/callback APIs). Double-check all training scripts against the 0.19.1 changelog and run end-to-end tests to confirm compatibility.

🤖 Prompt for AI Agents
In requirements.txt at line 21, the TRL package is updated to version 0.19.1,
which introduces breaking changes. You need to update all legacy TRL API usages
in the codebase accordingly: replace imports of RewardConfig and RewardTrainer
with the new 0.19.x equivalents, update classes like AxolotlRewardConfig and
AxolotlRewardTrainer to use the new split AutoModelForCausalLMWithValueHead and
updated config classes, and revise all references in
src/axolotl/core/training_args.py, src/axolotl/core/builders/causal.py,
src/axolotl/core/trainers/trl.py, and src/axolotl/core/trainers/__init__.py to
match the new API. Finally, verify all training scripts against the 0.19.1
changelog and run end-to-end tests to ensure compatibility.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 9, 2025

Codecov Report

Attention: Patch coverage is 45.45455% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/axolotl/core/trainers/grpo/__init__.py 33.33% 4 Missing ⚠️
src/axolotl/cli/vllm_serve.py 0.00% 1 Missing ⚠️
src/axolotl/core/trainers/grpo/trainer.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 10, 2025

@github-actions github-actions Bot temporarily deployed to preview July 10, 2025 02:19 Inactive
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 025d563 and ec17bc4.

📒 Files selected for processing (3)
  • setup.py (1 hunks)
  • src/axolotl/core/trainers/grpo/__init__.py (1 hunks)
  • src/axolotl/utils/schemas/trl.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: PyTest (3.11, 2.6.0)
  • GitHub Check: PyTest (3.11, 2.7.1)
  • GitHub Check: PyTest (3.11, 2.7.0)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.1)
  • GitHub Check: PyTest from Source Dist (3.11, 2.7.0)
  • GitHub Check: PyTest from Source Dist (3.11, 2.6.0)
  • GitHub Check: pre-commit
  • GitHub Check: test-axolotl-multigpu (126, 12.6.3, 3.11, 2.6.0, 2, true)
  • GitHub Check: test-axolotl-multigpu (126, 12.6.3, 3.11, 2.7.1, 2, true)
  • GitHub Check: test-axolotl-multigpu (126, 12.6.3, 3.11, 2.7.0, vllm, 2, true)
  • GitHub Check: pre-commit
  • GitHub Check: preview
🔇 Additional comments (2)
setup.py (1)

73-73: vLLM 0.9.2 is available and compatible with PyTorch 2.7.0

vLLM 0.9.2 is the latest release on PyPI and its requires_dist pins torch==2.7.0, confirming compatibility.

  • File: setup.py
    Line: 73
    Change:
    - extras_require_map["vllm"] = ["vllm>=0.9.0"]
    + extras_require_map["vllm"] = ["vllm>=0.9.2"]
src/axolotl/core/trainers/grpo/__init__.py (1)

47-47: LGTM - Configuration propagation is correct.

The addition of vllm_mode to the training arguments is consistent with the existing pattern and correctly placed within the use_vllm conditional block. The implementation properly propagates the configuration value to the training arguments.

Note: The effectiveness of this change depends on proper validation of the vllm_mode field in the schema definition (as mentioned in the previous file review).

Comment thread src/axolotl/utils/schemas/trl.py Outdated
@github-actions github-actions Bot temporarily deployed to preview July 10, 2025 02:52 Inactive
@github-actions github-actions Bot temporarily deployed to preview July 10, 2025 03:15 Inactive
@github-actions github-actions Bot temporarily deployed to preview July 10, 2025 04:51 Inactive
@github-actions github-actions Bot temporarily deployed to preview July 10, 2025 05:25 Inactive
@github-actions github-actions Bot temporarily deployed to preview July 10, 2025 19:51 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 11, 2025

📖 Documentation Preview: https://6871fb18fc77479c11e7e564--resonant-treacle-0fd729.netlify.app

Deployed on Netlify from commit c963dad

Comment thread src/axolotl/core/trainers/grpo/__init__.py
@winglian winglian merged commit 5081db7 into main Jul 14, 2025
19 of 20 checks passed
@winglian winglian deleted the trl-upgrade branch July 14, 2025 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants