feat: add stop condition to model customization trainers#5579
Merged
mollyheamazon merged 1 commit intoaws:masterfrom Feb 26, 2026
Merged
feat: add stop condition to model customization trainers#5579mollyheamazon merged 1 commit intoaws:masterfrom
mollyheamazon merged 1 commit intoaws:masterfrom
Conversation
mufaddal-rohawala
approved these changes
Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add stopping_condition parameter to model customization trainers
Problem
Customers need to run multi-day training jobs with large datasets (1M+ samples), but there was no way to override the training runtime limit through the trainer APIs. SageMaker Training Jobs support up to 28 days, but the SDK didn't expose this configuration.
Solution
Added
stopping_conditionparameter to all model customization trainers (SFT, DPO, RLVR, RLAIF) following the ModelTrainer pattern.Changes
stopping_condition: Optional[StoppingCondition] = Noneparameter to:SFTTrainerDPOTrainerRLVRTrainerRLAIFTrainerTrainDefaults.get_stopping_condition()which defaults to 1 hour if not specifiedUsage
python
from sagemaker.train import SFTTrainer
from sagemaker.train.configs import StoppingCondition
trainer = SFTTrainer(
model="meta-llama/Llama-2-7b-hf",
model_package_group="my-model-group",
training_dataset="s3://bucket/data.jsonl",
stopping_condition=StoppingCondition(
max_runtime_in_seconds=259200 # 3 days
)
)
Backward Compatibility
✅ Fully backward compatible - defaults to 1 hour if not specified
Testing
test_sft_trainer.py,test_dpo_trainer.py,test_rlvr_trainer.py,test_rlaif_trainer.pyBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.