Skip to content

Fix gpt-oss examples trl import error#1390

Open
sugunav14 wants to merge 1 commit intomainfrom
svelury/fix-6115282
Open

Fix gpt-oss examples trl import error#1390
sugunav14 wants to merge 1 commit intomainfrom
svelury/fix-6115282

Conversation

@sugunav14
Copy link
Copy Markdown
Contributor

@sugunav14 sugunav14 commented May 4, 2026

What does this PR do?

Type of change: Bug fix

Cap kernels<0.13 and trackio<0.21 in examples/gpt-oss/requirements.txt. Both newer versions require huggingface_hub>=1.x, but the example's transformers pins huggingface_hub<1.0, so a fresh install breaks on import (Unsupported type for field 'import_name': str | None from kernels; cannot import name 'Volume' from trackio).

Usage

No API change. On transformers<5.0, override the config's warmup_steps with --warmup_ratio 0.03 --warmup_steps 0 (or edit the YAML), as already noted by the comment in configs/sft_*.yaml.

# Add a code snippet demonstrating how to use this
accelerate launch --config_file configs/zero3.yaml sft.py --config configs/sft_full.yaml --model_name_or_path openai/gpt-oss-20b --quant_cfg MXFP4_MLP_WEIGHT_ONLY_CFG --output_dir gpt-oss-20b-qat --warmup_steps 0 --warmup_ratio 0.03

Testing

  1. pip install -r examples/gpt-oss/requirements.txt
    pip install transformers==4.57.3

    # Add a code snippet demonstrating how to use this
    accelerate launch --config_file configs/zero3.yaml sft.py --config configs/sft_full.yaml --model_name_or_path    openai/gpt-oss-20b --quant_cfg MXFP4_MLP_WEIGHT_ONLY_CFG --output_dir gpt-oss-20b-qat --warmup_steps 0 --warmup_ratio 0.03
  2. pip install -r examples/gpt-oss/requirements.txt
    pip install --upgrade transformers

    # Add a code snippet demonstrating how to use this
    accelerate launch --config_file configs/zero3.yaml sft.py --config configs/sft_full.yaml --model_name_or_path    openai/gpt-oss-20b --quant_cfg MXFP4_MLP_WEIGHT_ONLY_CFG --output_dir gpt-oss-20b-qat

Before your PR is "Ready for review"

Make sure you read and follow Contributor guidelines and your commits are signed (git commit -s -S).

Make sure you read and follow the Security Best Practices (e.g. avoiding hardcoded trust_remote_code=True, torch.load(..., weights_only=False), pickle, etc.).

  • Is this change backward compatible?: ✅
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: N/A
  • Did you write any new necessary tests?: N/A
  • Did you update Changelog?: N/A

Additional Information

Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
@sugunav14 sugunav14 requested a review from a team as a code owner May 4, 2026 22:42
@sugunav14 sugunav14 requested a review from kevalmorabia97 May 4, 2026 22:42
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

Dependency version constraints in the GPT-OSS example requirements are tightened. The kernels package now specifies an upper bound (<0.13), and trackio gains a version ceiling (<0.21), replacing previously looser constraints.

Changes

Dependency Version Pinning

Layer / File(s) Summary
Version Constraints
examples/gpt-oss/requirements.txt
kernels>=0.9.0 is tightened to kernels>=0.9.0,<0.13; trackio is pinned to trackio<0.21. trl>=0.21.0 remains unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix gpt-oss examples trl import error' is only partially related to the changeset. While it mentions a fix for trl import issues, the actual changes tighten dependency constraints for kernels and trackio to resolve version conflicts with huggingface_hub, not a direct trl import error.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Anti-Patterns ✅ Passed PR only tightens version constraints on existing dependencies (kernels, trackio) without introducing new ones or security anti-patterns.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch svelury/fix-6115282

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

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.

🧹 Nitpick comments (1)
examples/gpt-oss/requirements.txt (1)

1-2: Consider planning a migration to newer transformers.

While this fix correctly resolves the immediate import errors, pinning to older versions of kernels and trackio creates long-term maintenance overhead. Newer versions of transformers (5.0+) likely support huggingface_hub>=1.x, which would allow using the latest versions of all dependencies.

Consider opening a follow-up issue to track upgrading transformers and removing these upper bounds once the example code is compatible with transformers 5.0+.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/gpt-oss/requirements.txt` around lines 1 - 2, The requirements
pinning in requirements.txt (kernels>=0.9.0,<0.13 and trackio<0.21) is a
short-term workaround; open a follow-up issue to track upgrading to transformers
5.0+ and huggingface_hub>=1.x so these upper bounds can be removed, and update
the example once compatibility is verified by testing with transformers 5.x;
specifically note the packages "kernels" and "trackio" in the issue, plan to
remove the <0.13 and <0.21 caps, and add a CI job that runs the example against
transformers 5.x to confirm there are no import/runtime errors before lifting
the pins.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@examples/gpt-oss/requirements.txt`:
- Around line 1-2: The requirements pinning in requirements.txt
(kernels>=0.9.0,<0.13 and trackio<0.21) is a short-term workaround; open a
follow-up issue to track upgrading to transformers 5.0+ and huggingface_hub>=1.x
so these upper bounds can be removed, and update the example once compatibility
is verified by testing with transformers 5.x; specifically note the packages
"kernels" and "trackio" in the issue, plan to remove the <0.13 and <0.21 caps,
and add a CI job that runs the example against transformers 5.x to confirm there
are no import/runtime errors before lifting the pins.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 92c68367-4fc3-4491-ae27-474f620b77a9

📥 Commits

Reviewing files that changed from the base of the PR and between 70546bd and d76ba37.

📒 Files selected for processing (1)
  • examples/gpt-oss/requirements.txt

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.02%. Comparing base (fe3042b) to head (d76ba37).
⚠️ Report is 25 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1390      +/-   ##
==========================================
- Coverage   75.68%   74.02%   -1.67%     
==========================================
  Files         471      471              
  Lines       50400    53856    +3456     
==========================================
+ Hits        38145    39865    +1720     
- Misses      12255    13991    +1736     
Flag Coverage Δ
examples 41.59% <ø> (+0.96%) ⬆️
unit 52.78% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant