Skip to content

feat(config): inline DeepSpeed config into main YAML#36

Merged
Neonkraft merged 8 commits into
mainfrom
feat/one-yaml-to-config-them-all
Jul 2, 2026
Merged

feat(config): inline DeepSpeed config into main YAML#36
Neonkraft merged 8 commits into
mainfrom
feat/one-yaml-to-config-them-all

Conversation

@Neonkraft

Copy link
Copy Markdown
Collaborator

Summary

Removes the separate DeepSpeed config file and embeds the DeepSpeed configuration directly in the main training YAML under a deepspeed: key. Set deepspeed: null to disable DeepSpeed entirely.

Previously, deepspeed.config_path pointed to a separate file (e.g. configs/deepspeed/zero2.yaml) which had to be kept in sync with the main config. All existing configs (sft.yaml, dpo.yaml) are migrated to use the inline format.

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Performance
  • Documentation
  • Maintenance

Copilot AI left a comment

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.

Pull request overview

This PR migrates DeepSpeed configuration from an external YAML file (deepspeed.config_path) to an inline deepspeed: block embedded directly in the main training config YAMLs, with deepspeed: null intended to disable DeepSpeed.

Changes:

  • Removes the DeepSpeedConfig dataclass and load_deepspeed_config() loader, replacing them with a top-level inline deepspeed config object.
  • Updates training argument construction to pass the inline deepspeed config directly.
  • Migrates TRL YAML configs (sft.yaml, dpo.yaml) to include the full DeepSpeed config inline.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/post_training/utils/guardrails.py Updates DeepSpeed summary output to reflect inline config rather than a referenced file path.
src/post_training/methods/common.py Switches DeepSpeed config source from file-loading to using config.deepspeed directly when building trainer kwargs.
src/post_training/config.py Removes file-based DeepSpeed config schema/loader and introduces an inline deepspeed field on the root config.
configs/trl/sft.yaml Replaces deepspeed.config_path with an inline DeepSpeed config block for SFT runs.
configs/trl/dpo.yaml Replaces deepspeed.config_path with an inline DeepSpeed config block for DPO runs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 77 to 79
t = config.training
ds_config = config.load_deepspeed_config() if config.deepspeed.config_path else None
ds_config = config.deepspeed

Comment on lines 245 to 248
# Infrastructure.
deepspeed: DeepSpeedConfig = field(default_factory=DeepSpeedConfig)
# Inline DeepSpeed config dict. Set to null to disable DeepSpeed entirely.
deepspeed: Any = None
accelerate: AccelerateConfig = field(default_factory=AccelerateConfig)
Comment on lines +246 to 248
# Inline DeepSpeed config dict. Set to null to disable DeepSpeed entirely.
deepspeed: Any = None
accelerate: AccelerateConfig = field(default_factory=AccelerateConfig)
@abhash-er abhash-er self-requested a review July 1, 2026 09:46
# ------------------------------------------------------------------

@classmethod
def load(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This function still supports the old deepspeed config style. (deepspeed: {config_path:...}). Maybe a deprecation warning over here or a assertion check while loading and merging would be good.

@abhash-er

abhash-er commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator
  • The tests are breaking- tests/test_config.py still uses old style.
  • Also while loading, a way to verify deepspeed configs would be good (but not necessary as deepspeed can handle them itself).
  • The unwanted files should also be cleaned up like- configs/deepspeed
  • A note on how to switch the scheme from zero-2 to zero-3 should be added either in Readme or as a comment in configs/trl/sft.yaml

@Neonkraft

Copy link
Copy Markdown
Collaborator Author

The tests are breaking- tests/test_config.py still uses old style.

Good catch! I'll fix that.

Also while loading, a way to verify deepspeed configs would be good (but not necessary as deepspeed can handle them itself).

I'd say no to this because:

  1. Deepspeed does it anyway, so it's redundant, like you said
  2. More work for us to keep the validation code synced with deepspeed

The unwanted files should also be cleaned up like- configs/deepspeed

I let them stay on as a reference. Might remove in future.

A note on how to switch the scheme from zero-2 to zero-3 should be added either in Readme or as a comment in configs/trl/sft.yaml

Yes, will do.

@abhash-er abhash-er left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Neonkraft Neonkraft merged commit d0d0bb9 into main Jul 2, 2026
2 checks passed
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.

3 participants