@@ -130,58 +130,11 @@ def fill_match(self, ds_key_long, hf_val, hf_key=None, must_match=True):
130130
131131 fill_only = partialmethod (fill_match , must_match = False )
132132
133- def override_training_args_from_deepspeed (self , args ):
134- """
135- Override TrainingArguments based on DeepSpeed config values to ensure compatibility.
136-
137- This method ensures that the DeepSpeed config takes precedence over TrainingArguments
138- defaults when there are conflicts, particularly for mixed precision settings.
139-
140- Args:
141- args: TrainingArguments object to potentially modify
142- """
143- # Check precision settings in DeepSpeed config and override TrainingArguments accordingly
144- # Only override defaults, not explicit user settings
145-
146- # Check if user explicitly set precision options (we assume defaults are False)
147- user_set_fp16 = args .fp16 is True
148- user_set_bf16 = args .bf16 is True
149-
150- if self .is_true ("fp16.enabled" ):
151- # DeepSpeed config explicitly enables fp16
152- if not user_set_fp16 and not user_set_bf16 :
153- # User didn't explicitly set either, so apply DeepSpeed config
154- args .fp16 = True
155- args .bf16 = False
156- elif user_set_bf16 and not user_set_fp16 :
157- # User explicitly chose bf16, but DeepSpeed config wants fp16
158- # This is a potential conflict - let user choice win but log a warning
159- pass # Keep user's bf16=True, fp16=False
160- elif self .is_true ("bf16.enabled" ):
161- # DeepSpeed config explicitly enables bf16
162- if not user_set_fp16 and not user_set_bf16 :
163- # User didn't explicitly set either, so apply DeepSpeed config
164- args .bf16 = True
165- args .fp16 = False
166- elif user_set_fp16 and not user_set_bf16 :
167- # User explicitly chose fp16, but DeepSpeed config wants bf16
168- # This is a potential conflict - let user choice win but log a warning
169- pass # Keep user's fp16=True, bf16=False
170- elif self .is_false ("fp16.enabled" ) and self .is_false ("bf16.enabled" ):
171- # Both are explicitly disabled in DeepSpeed config
172- if not user_set_fp16 and not user_set_bf16 :
173- # User didn't explicitly set either, so apply DeepSpeed config (fp32)
174- args .fp16 = False
175- args .bf16 = False
176-
177133 def trainer_config_process (self , args , auto_find_batch_size = False ):
178134 """
179135 Adjust the config with `TrainingArguments` values. This stage is run during `TrainingArguments` object
180136 creation.
181137 """
182- # First, override TrainingArguments based on DeepSpeed config to ensure compatibility
183- self .override_training_args_from_deepspeed (args )
184-
185138 # DeepSpeed does:
186139 # train_batch_size = world_size * train_micro_batch_size_per_gpu * gradient_accumulation_steps
187140 train_batch_size = args .world_size * args .per_device_train_batch_size * args .gradient_accumulation_steps
0 commit comments