Skip to content

add 120b and deepspeed zero3 examples#3035

Merged
winglian merged 5 commits into
mainfrom
gpt-oss-examples
Aug 8, 2025
Merged

add 120b and deepspeed zero3 examples#3035
winglian merged 5 commits into
mainfrom
gpt-oss-examples

Conversation

@winglian
Copy link
Copy Markdown
Collaborator

@winglian winglian commented Aug 8, 2025

Summary by CodeRabbit

  • New Features
    • Added new configuration files for training GPT-OSS 120B and 20B models with advanced memory optimization, distributed training, and multilingual dataset support.
  • Documentation
    • Updated comments to clarify compatibility of memory-efficient loading options with specific model quantizations.
    • Simplified installation instructions and updated example commands for easier setup.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 8, 2025

Warning

Rate limit exceeded

@NanoCode012 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 53 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 4274f6c and edc43a5.

📒 Files selected for processing (6)
  • examples/gpt-oss/README.md (2 hunks)
  • examples/gpt-oss/gpt-oss-120b-fft-fsdp2-offload.yaml (1 hunks)
  • examples/gpt-oss/gpt-oss-20b-fft-deepspeed-zero3.yaml (1 hunks)
  • examples/gpt-oss/gpt-oss-20b-fft-fsdp2-offload.yaml (1 hunks)
  • examples/gpt-oss/gpt-oss-20b-fft-fsdp2.yaml (0 hunks)
  • examples/gpt-oss/gpt-oss-20b-sft-lora-singlegpu.yaml (0 hunks)
📝 Walkthrough

Walkthrough

Three YAML configuration files for GPT-OSS model training are introduced or updated. Two new files provide training setups for the 120B and 20B model variants using FSDP v2 and DeepSpeed Zero3 strategies, respectively. The third file receives a comment update clarifying the compatibility of a specific loading option with model quantization. Additionally, the GPT-OSS README was updated to simplify installation instructions and adjust model config comments.

Changes

Cohort / File(s) Change Summary
New GPT-OSS 120B FSDP2 Offload Config
examples/gpt-oss/gpt-oss-120b-fft-fsdp2-offload.yaml
Adds a YAML configuration for GPT-OSS 120B training with FSDP v2 and CPU RAM efficient offloading, specifying model, dataset, plugins, training hyperparameters, optimizer, scheduler, precision, attention, logging, and FSDP settings.
New GPT-OSS 20B DeepSpeed Zero3 Config
examples/gpt-oss/gpt-oss-20b-fft-deepspeed-zero3.yaml
Adds a YAML configuration for GPT-OSS 20B training using DeepSpeed Zero3, with detailed settings for model, quantization, plugins, dataset, training parameters, optimizer, scheduler, precision, attention, memory optimizations, logging, and distributed training.
Comment Update: FSDP2 Offload 20B
examples/gpt-oss/gpt-oss-20b-fft-fsdp2-offload.yaml
Updates a comment for the cpu_ram_efficient_loading option under fsdp_config to clarify its incompatibility with MXFP4 quantization and specify it is only usable with dequantized models. No functional changes.
README Update: GPT-OSS Installation and Docs
examples/gpt-oss/README.md
Simplifies Axolotl installation instructions by replacing repository cloning with a direct pip install command specifying a minimum version and 'flash-attn' extra. Updates comments on the 20B model training config to remove references to "2 experts" and adjust memory usage notes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • winglian
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gpt-oss-examples

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.
  • 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.

Support

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

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 generate unit tests to generate unit tests for 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.

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: 3

🧹 Nitpick comments (1)
examples/gpt-oss/gpt-oss-20b-fft-fsdp2-offload.yaml (1)

66-69: Good clarification on cpu_ram_efficient_loading vs MXFP4

Leaving cpu_ram_efficient_loading commented is correct here given MXFP4; the added note will prevent misconfigurations.

Consider adding a short link to the 120B dequantized example for users seeking a working reference.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d5c95d and 4183826.

📒 Files selected for processing (3)
  • examples/gpt-oss/gpt-oss-120b-fft-fsdp2-offload.yaml (1 hunks)
  • examples/gpt-oss/gpt-oss-20b-fft-deepspeed-zero3.yaml (1 hunks)
  • examples/gpt-oss/gpt-oss-20b-fft-fsdp2-offload.yaml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: winglian
PR: axolotl-ai-cloud/axolotl#2707
File: src/axolotl/utils/data/sft.py:247-254
Timestamp: 2025-05-29T22:23:39.312Z
Learning: In distributed training scenarios with batch dispatching, placeholder datasets for non-zero ranks may intentionally use temporary files that persist during training. These files are typically very small and don't require explicit cleanup due to their minimal resource impact and specific training requirements.
🔇 Additional comments (8)
examples/gpt-oss/gpt-oss-120b-fft-fsdp2-offload.yaml (4)

60-67: FSDP2 config looks appropriate for 120B dequantized with CPU offload

offload_params + SHARDED_STATE_DICT + TRANSFORMER_BASED_WRAP with reshard_after_forward is a solid setup for memory pressure.


11-11: experimental_skip_move_to_device: true is appropriate for FSDP sharding

This prevents initial GPU OOM before sharding. Keep it enabled for this scale.


64-66: No changes needed: GptOssDecoderLayer is correctly defined
The transformer_layer_cls_to_wrap: GptOssDecoderLayer setting matches the entry in MOE_ARCH_BLOCK (src/axolotl/common/architectures.py), so the class name is resolvable and requires no updates.


4-5: Ensure use_kernels: false doesn’t disable your selected attention implementation

I didn’t find any code paths that automatically block a kernels-community/vllm-flash-attn3 backend when use_kernels is set to false. Please double-check that disabling “all fused kernels” globally does not inadvertently disable your flash-attention setup:

• File: examples/gpt-oss/gpt-oss-120b-fft-fsdp2-offload.yaml
– Lines 4–5: use_kernels: false
– Lines 44–45:
yaml flash_attention: true attn_implementation: kernels-community/vllm-flash-attn3

If turning off use_kernels does gate these community kernels, either add an explicit guard in your config loader or update the docs to call this out.

examples/gpt-oss/gpt-oss-20b-fft-deepspeed-zero3.yaml (4)

35-35: Verify 8-bit optimizer compatibility with DeepSpeed ZeRO-3

The config currently uses an 8-bit optimizer, which may conflict with ZeRO-3’s parameter partitioning/offload. Please confirm that adamw_torch_8bit has been tested with ZeRO-3 in your environment; if not, switch to a supported optimizer.

• File: examples/gpt-oss/gpt-oss-20b-fft-deepspeed-zero3.yaml
Line: 35

Suggested change if untested or incompatible:

- optimizer: adamw_torch_8bit
+ optimizer: adamw_torch

2-2: Confirmed: use_kernels=false does not disable the Flash Attention backend

The grep output shows that in examples/gpt-oss/gpt-oss-20b-fft-deepspeed-zero3.yaml:

  • Line 2: use_kernels: false
  • Line 42: flash_attention: true
  • Line 43: attn_implementation: kernels-community/vllm-flash-attn3

Disabling kernels via use_kernels: false does not override or disable the selected attention backend. No changes required.


10-10: Skip_move_to_device is correctly honored with DeepSpeed ZeRO-3

The loader forces skip_move_to_device=True when ZeRO-3 is enabled and then respects the experimental flag override, and the post-load setup only calls model.to() if skip_move_to_device is False.

Key locations:

  • In _build_model (around line 803):
    if is_deepspeed_zero3_enabled(): skip_move_to_device = True
  • Experimental override (lines 813–815):
    if self.cfg.experimental_skip_move_to_device is not None: skip_move_to_device = ...
  • In _apply_post_lora_load_setup (line 393): skip moving model when skip_move_to_device is True

No changes needed.


58-60: Double-check DeepSpeed Zero-3 BF16 config file

Please manually verify that the referenced config exists and includes the correct settings:

  • deepspeed_configs/zero3_bf16.json is present at the specified path
  • "zero_optimization" block sets stage: 3 (and any desired offload options)
  • "bf16" precision is enabled
  • Any CPU/GPU offload parameters are configured as expected

Comment thread examples/gpt-oss/gpt-oss-120b-fft-fsdp2-offload.yaml
Comment thread examples/gpt-oss/gpt-oss-120b-fft-fsdp2-offload.yaml
Comment thread examples/gpt-oss/gpt-oss-20b-fft-deepspeed-zero3.yaml
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 8, 2025

📖 Documentation Preview: https://6895ca83ff37d21757e33941--resonant-treacle-0fd729.netlify.app

Deployed on Netlify from commit edc43a5

Copy link
Copy Markdown
Collaborator

@NanoCode012 NanoCode012 left a comment

Choose a reason for hiding this comment

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

Where does the deepspeed

Comment thread examples/gpt-oss/README.md
@winglian winglian merged commit 50f2b94 into main Aug 8, 2025
4 checks passed
@winglian winglian deleted the gpt-oss-examples branch August 8, 2025 12:04
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