|
11 | 11 | from pathlib import Path |
12 | 12 | from typing import Any |
13 | 13 |
|
14 | | -import yaml |
15 | 14 | from omegaconf import MISSING, DictConfig, OmegaConf |
16 | 15 |
|
17 | 16 | logger = logging.getLogger(__name__) |
@@ -151,18 +150,13 @@ class DataConfig: |
151 | 150 | datasets: list[DatasetEntry] = field(default_factory=list) |
152 | 151 |
|
153 | 152 |
|
154 | | -@dataclass |
155 | | -class DeepSpeedConfig: |
156 | | - """Pointer to the DeepSpeed YAML config file. Set to ``null`` to disable.""" |
157 | | - |
158 | | - config_path: str | None = "configs/deepspeed/zero2.yaml" |
159 | | - |
160 | | - |
161 | 153 | @dataclass |
162 | 154 | class AccelerateConfig: |
163 | 155 | """Flags forwarded to ``accelerate launch`` for explicit multi-node control.""" |
164 | 156 |
|
165 | 157 | mixed_precision: str = "bf16" |
| 158 | + # Only takes effect when the top-level `deepspeed:` config is also set; |
| 159 | + # `deepspeed: null` disables DeepSpeed at launch regardless of this flag. |
166 | 160 | use_deepspeed: bool = True |
167 | 161 | deepspeed_multinode_launcher: str = "standard" |
168 | 162 | same_network: bool = True |
@@ -252,7 +246,8 @@ class PostTrainingConfig: |
252 | 246 | dpo: DPOMethodConfig = field(default_factory=DPOMethodConfig) |
253 | 247 |
|
254 | 248 | # Infrastructure. |
255 | | - deepspeed: DeepSpeedConfig = field(default_factory=DeepSpeedConfig) |
| 249 | + # Inline DeepSpeed config dict. Set to null to disable DeepSpeed entirely. |
| 250 | + deepspeed: dict[str, Any] | None = None |
256 | 251 | accelerate: AccelerateConfig = field(default_factory=AccelerateConfig) |
257 | 252 | logging: LoggingConfig = field(default_factory=LoggingConfig) |
258 | 253 | slurm: SlurmConfig = field(default_factory=SlurmConfig) |
@@ -354,12 +349,3 @@ def resolve_gradient_accumulation_steps(self, world_size: int) -> int: |
354 | 349 | f"* world_size ({world_size}). Got gradient_accumulation_steps={gas}." |
355 | 350 | ) |
356 | 351 | return int(gas) |
357 | | - |
358 | | - def load_deepspeed_config(self) -> dict[str, Any]: |
359 | | - """Load the DeepSpeed YAML config and return it as a plain dict.""" |
360 | | - ds_path = Path(self.deepspeed.config_path) |
361 | | - if not ds_path.is_absolute(): |
362 | | - # Resolve relative to the project root (cwd). |
363 | | - ds_path = Path.cwd() / ds_path |
364 | | - with open(ds_path) as f: |
365 | | - return yaml.safe_load(f) |
0 commit comments