ROCm: default GPT-OSS to BF16 and disable AITER#4021
ROCm: default GPT-OSS to BF16 and disable AITER#4021danielhanchen wants to merge 12 commits intomainfrom
Conversation
Summary of ChangesHello @danielhanchen, 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 enhances the stability and compatibility for users on ROCm/HIP platforms by addressing known issues with model quantization and specific backend functionalities. It ensures that GPT-OSS models load in a more robust BF16 format by default and proactively disables problematic AITER and ROCm RoPE backends to prevent system instability, providing a smoother experience for users. 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. Changelog
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 defaults for ROCm environments to improve stability and avoid issues with certain models. Specifically, it disables AITER to prevent build locks and runtime faults, and it defaults GPT-OSS models to their BF16 versions to work around MXFP4 and pre-quantization problems. The changes are sensible, but I've suggested a small improvement to make the model selection logic for GPT-OSS more robust.
unsloth/models/loader.py
Outdated
| if "120b" in model_name.lower(): | ||
| model_name = "unsloth/gpt-oss-120b-BF16" | ||
| else: | ||
| model_name = "unsloth/gpt-oss-20b-BF16" |
There was a problem hiding this comment.
The current logic for selecting the BF16 version of a GPT-OSS model assumes that any model not containing '120b' is a '20b' model. This is not robust and could lead to incorrectly loading the 20b model for other sizes (e.g., a hypothetical 60b model). I suggest making this logic more explicit by handling the '20b' case and adding a warning for any other unhandled sizes.
| if "120b" in model_name.lower(): | |
| model_name = "unsloth/gpt-oss-120b-BF16" | |
| else: | |
| model_name = "unsloth/gpt-oss-20b-BF16" | |
| if "120b" in model_name.lower(): | |
| model_name = "unsloth/gpt-oss-120b-BF16" | |
| elif "20b" in model_name.lower(): | |
| model_name = "unsloth/gpt-oss-20b-BF16" | |
| else: | |
| logger.warning_once( | |
| f"Unsloth: gpt-oss model '{model_name}' is not explicitly supported for BF16 defaulting on ROCm. " | |
| f"Defaulting to 'unsloth/gpt-oss-20b-BF16', which might be incorrect." | |
| ) | |
| model_name = "unsloth/gpt-oss-20b-BF16" |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e1e24cc02
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
unsloth/models/loader.py
Outdated
| model_name = "unsloth/gpt-oss-120b-BF16" | ||
| else: | ||
| model_name = "unsloth/gpt-oss-20b-BF16" |
There was a problem hiding this comment.
Preserve non-base GPT-OSS IDs on HIP
This rewrite forces any HIP model_name that contains gpt-oss into one of two base BF16 checkpoints, so with default use_exact_model_name=False it silently changes explicit variants (for example unsloth/gpt-oss-safeguard-20b/120b in unsloth/models/mapper.py) and custom fine-tuned IDs or paths into unsloth/gpt-oss-20b-BF16 or -120b-BF16. In those cases users load a different model than requested and can lose safeguard behavior without an error, so the remap should be restricted to the base GPT-OSS IDs (or fail clearly for unsupported variants).
Useful? React with 👍 / 👎.
|
Validation update for ROCm:
NVIDIA compatibility notes:
|
|
Recheck update for PR #4021 against current ROCm notebook reruns. Re-evaluated items
Findings
Action
|
|
Follow-up adjustment: HIP GPT-OSS routing is now capability-based, not blanket BF16. What changed
Logic
Why
Validation (ROCm)
Note
Commit
|
|
Recheck complete. I cleaned up the PR to remove unintended fallback behavior that made the diff look botched.\n\nWhat I removed\n- HIP-specific fallback in that silently downgraded when is missing.\n- HIP-specific behavior in that auto-dropped / and auto-tokenized string inputs.\n\nWhat remains intentionally in this PR\n- : ROCm AITER defaults via so explicit user env overrides still win.\n- : capability-gated GPT-OSS BF16 fallback using + (Radeon can still use prequantized checkpoints where supported).\n- : defensive Trainer init patch guard + TorchAO with TypeError fallback for older TorchAO.\n\nCommit pushed\n- \n\nI will continue the AMD notebook reruns and keep logging outcomes in and . |
|
Recheck complete. I cleaned up the PR to remove unintended fallback behavior that made the diff look botched. What I removed
What remains intentionally in this PR
Commit pushed
I will continue the AMD notebook reruns and keep logging outcomes in |
|
Applied a fresh cleanup/refactor for the duplicated HIP GPT-OSS routing block in What changed
Behavior
Validation
Commit
|
|
Follow-up cleanup applied:
Safety note
Validation
Commit
|
|
Quick status update from the latest ROCm notebook cycle.
I will continue the remaining notebook sweep and report any |
|
Added follow-up AMD notebook stability fixes:\n\n- Commit: \n- Files:\n - \n - \n - \n\nWhat changed:\n- Added definitions for HIP/XPU branches so downstream checks have a stable callable.\n- Hooked Deepseek OCR patch invocation in with a guarded import/call path.\n- Added an offline GGUF guard path in () so Ollama notebook flows do not fail hard when GGUF conversion dependencies are unavailable.\n\nValidation evidence (ROCm runs):\n- Deepseek OCR fix path: (fail) -> (success).\n- Ollama flow: (success).\n- Full notebook latest status remains green in after this cycle (all 25 tracked notebooks currently latest=SUCCESS). |
|
Follow-up AMD notebook stability fixes are now pushed.
What changed:
Validation evidence (ROCm runs):
|
|
Additional follow-up pushed:
Change:
Why this was added:
Note on PR #4029:
|
|
Superseding my prior malformed CLI comment with corrected content. Re-review update with fresh A/B checks on ROCm:
Additional note from sanity run:
|
MI355X (gfx950) has the same 1024-thread workgroup limit as MI300X (gfx942), but was missing from is_cdna(), causing all Triton kernels to use num_warps=32 (2048 threads) instead of 16 (1024 threads), resulting in OutOfResources crash. Also includes ROCm GPT-OSS BF16 routing and dequant buffer dtype fix from PR unslothai#4021 by @danielhanchen, cherry-picked for MI355X validation. Tested on: 8x AMD Instinct MI355X (gfx950), ROCm 7.1 - Vision RL GRPO (Qwen2.5-VL-7B): 5/5 steps - Code RL GRPO (gpt-oss-20b BF16): 20/20 steps - gpt-oss-120b GRPO: 5/5 steps (B200 OOM'd on this) - MoE expert LoRA + save_pretrained_merged: success
Summary
Testing