@@ -3219,10 +3219,11 @@ def run_body(args, executable, dest_proj, dest_path, preset_inputs=None, input_n
32193219 if args .instance_count :
32203220 # Validate that we're not mixing clusterSpec with instanceTypeSelector
32213221 # clusterSpec and instanceTypeSelector are mutually exclusive at build time
3222- # If runtime provides instance-count, we should not have instanceTypeSelector from cloned job
3223- if cloned_instance_type_selector .as_dict ():
3224- raise DXCLIError ("Cannot specify --instance-count when cloning a job that uses instanceTypeSelector. "
3225- "instanceTypeSelector and clusterSpec are mutually exclusive." )
3222+ # However, if instanceType is provided (either from runtime or cloned job), it overrides instanceTypeSelector
3223+ # So we only raise an error if instanceTypeSelector exists AND no instanceType override is present
3224+ if cloned_instance_type_selector .as_dict () and not requested_instance_type .as_dict ():
3225+ raise DXCLIError ("Cannot specify --instance-count when cloning a job that uses instanceTypeSelector "
3226+ "without providing --instance-type. instanceTypeSelector and clusterSpec are mutually exclusive." )
32263227 # retrieve the full cluster spec defined in executable's runSpec.systemRequirements
32273228 # and overwrite the field initialInstanceCount with the runtime mapping
32283229 requested_instance_count = SystemRequirementsDict .from_instance_count (args .instance_count )
@@ -3244,10 +3245,10 @@ def run_body(args, executable, dest_proj, dest_path, preset_inputs=None, input_n
32443245 requested_nvidia_driver = cloned_nvidia_driver
32453246
32463247 # Validate mutual exclusivity: instanceTypeSelector and clusterSpec cannot coexist
3247- # Note: instanceType can override instanceTypeSelector, so we only check clusterSpec here
3248+ # Note: instanceType can override instanceTypeSelector, so we only raise error if no instanceType is present
32483249 # instanceTypeSelector is build-time only and should never be in runtime systemRequirements
3249- if cloned_instance_type_selector .as_dict () and requested_cluster_spec .as_dict ():
3250- raise DXCLIError ("Cannot combine clusterSpec with instanceTypeSelector. "
3250+ if cloned_instance_type_selector .as_dict () and requested_cluster_spec .as_dict () and not requested_instance_type . as_dict () :
3251+ raise DXCLIError ("Cannot combine clusterSpec with instanceTypeSelector without providing instanceType . "
32513252 "instanceTypeSelector and clusterSpec are mutually exclusive." )
32523253
32533254 # combine the requested instance type, full cluster spec, fpga spec, nvidia spec
0 commit comments