@@ -51,20 +51,13 @@ const scheduleTypeTips = [
5151 }
5252] ;
5353
54- const gpuAllocateTypeTips = [
54+ const GPUsPerReplicaTips = [
5555 {
5656 title : {
57- text : 'models.form.gpusAllocationType .auto' ,
57+ text : 'common.options .auto' ,
5858 locale : true
5959 } ,
6060 tips : 'models.form.gpusAllocationType.auto.tips'
61- } ,
62- {
63- title : {
64- text : 'models.form.gpusAllocationType.custom' ,
65- locale : true
66- } ,
67- tips : 'models.form.gpusAllocationType.custom.tips'
6861 }
6962] ;
7063
@@ -98,7 +91,11 @@ const ScheduleTypeForm: React.FC = () => {
9891 } ;
9992
10093 const handleGpusPerReplicasChange = ( val : string | number | null ) => {
101- form . setFieldValue ( [ 'gpu_selector' , 'gpus_per_replica' ] , val ) ;
94+ if ( val === null ) {
95+ form . setFieldValue ( [ 'gpu_selector' , 'gpus_per_replica' ] , - 1 ) ;
96+ } else {
97+ form . setFieldValue ( [ 'gpu_selector' , 'gpus_per_replica' ] , val ) ;
98+ }
10299
103100 onValuesChange ?.( { } , form . getFieldsValue ( ) ) ;
104101 } ;
@@ -128,23 +125,6 @@ const ScheduleTypeForm: React.FC = () => {
128125 onValuesChange ?.( { } , form . getFieldsValue ( ) ) ;
129126 } ;
130127
131- const handleOnStepReplica = async ( value : number | string | null ) => {
132- if ( value === null ) {
133- await new Promise ( ( resolve ) => {
134- setTimeout ( resolve , 200 ) ;
135- } ) ;
136- form . setFieldValue ( [ 'gpu_selector' , 'gpus_per_replica' ] , 1 ) ;
137- return ;
138- }
139-
140- const isPowerOfTwo = ( n : number ) => ( n & ( n - 1 ) ) === 0 && n !== 0 ; // check power of two
141- if ( ! isPowerOfTwo ( value as number ) ) {
142- const newValue = Math . pow ( 2 , Math . round ( Math . log2 ( value as number ) ) ) ;
143- form . setFieldValue ( [ 'gpu_selector' , 'gpus_per_replica' ] , newValue ) ;
144- onValuesChange ?.( { } , form . getFieldsValue ( ) ) ;
145- }
146- } ;
147-
148128 const onSelectorChange = ( field : string , allowEmpty ?: boolean ) => {
149129 const workerSelector = form . getFieldValue ( field ) ;
150130 // check if all keys have values
@@ -246,15 +226,19 @@ const ScheduleTypeForm: React.FC = () => {
246226 { label : '4' , value : 4 } ,
247227 { label : '8' , value : 8 }
248228 ] }
229+ description = {
230+ < TooltipList list = { GPUsPerReplicaTips } > </ TooltipList >
231+ }
249232 popupRender = { ( originNode ) => (
250233 < div >
251234 { originNode }
252235 < InputWrapper >
253236 < InputNumber
237+ min = { 1 }
254238 step = { 1 }
255239 style = { { width : '100%' } }
256240 defaultValue = {
257- GPUsPerReplicas === null ? - 1 : GPUsPerReplicas
241+ GPUsPerReplicas === - 1 ? null : GPUsPerReplicas
258242 }
259243 value = { GPUsPerReplicas === - 1 ? null : GPUsPerReplicas }
260244 onChange = { handleGpusPerReplicasChange }
@@ -263,7 +247,6 @@ const ScheduleTypeForm: React.FC = () => {
263247 </ InputWrapper >
264248 </ div >
265249 ) }
266- onChange = { handleOnStepReplica }
267250 />
268251 </ Form . Item >
269252 </ >
0 commit comments