fix(train): Skip default instance_type/instance_count when instance_groups is set#5564
Open
mufaddal-rohawala wants to merge 1 commit intoaws:masterfrom
Open
Conversation
…roups is set Guard the default injection of instance_type and instance_count in TrainDefaults.get_compute() and JumpStartTrainDefaults.get_compute() so that these values are not populated when instance_groups is configured. The SageMaker API treats instance_type/instance_count and instance_groups as mutually exclusive in ResourceConfig, and unconditionally setting defaults causes a ValidationException. Fixes aws#5555
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.
Issue
Fixes #5555
Description
When creating a
ModelTrainerwith aComputeconfig that usesinstance_groups(heterogeneous cluster),TrainDefaults.get_compute()andJumpStartTrainDefaults.get_compute()unconditionally inject defaultinstance_type(ml.m5.xlarge) andinstance_count(1) when those fields areNone.With heterogeneous clusters,
instance_typeandinstance_countare intentionallyNonebecause they are mutually exclusive withinstance_groupsin the SageMakerCreateTrainingJobAPI. This causes the API call to include bothInstanceType/InstanceCountandInstanceGroupsin theResourceConfig, which SageMaker rejects with:Changes
Wrapped the default
instance_typeandinstance_countinjection in both methods with aif not compute.instance_groups:guard so defaults are only applied for homogeneous cluster configurations.TrainDefaults.get_compute()— skips settinginstance_typeandinstance_countdefaults wheninstance_groupsis present.JumpStartTrainDefaults.get_compute()— same guard applied.volume_size_in_gbdefault is still set regardless since it applies to both cluster types.Testing
This change is a minimal guard condition. When
instance_groupsis not set, behavior is identical to before. Wheninstance_groupsis set,instance_typeandinstance_countremainNoneas intended by the caller.