7
7
using one of the tools provided below:
8
8
9
9
<h2 >Argument Parser</h2 >
10
-
11
10
<ul >
12
- <li >
11
+ <li v-show = " argparserOptions.options.includes('argparse') " >
13
12
<a href =" https://docs.python.org/3/library/argparse.html" id =" arg"
14
13
>Argparse</a
15
14
>
16
15
- is a python built-in tool to handle command-line arguments
17
16
</li >
18
- <li >
17
+ <li v-show = " argparserOptions.options.includes('fire') " >
19
18
<a
20
19
href =" https://github.com/google/python-fire/blob/master/docs/guide.md"
21
20
id =" arg"
24
23
- transforms Python functions into user-friendly command-line tools,
25
24
ideal for DL experimentation.
26
25
</li >
27
- <li >
26
+ <li v-show = " argparserOptions.options.includes('hydra') " >
28
27
<a href =" https://hydra.cc" id =" arg" >Hydra</a >
29
28
- Simplifying deep learning experiments through flexible configuration
30
29
management
31
30
</li >
32
31
</ul >
33
32
<FormSelect
34
- :label =" argparser.description"
35
- :options =" argparser.options"
36
- :saveKey =" argparser.name"
37
- :defaultV =" argparser.default"
38
- />
39
- <h2 class =" training" >Deterministic Training</h2 >
40
- <FormCheckbox
41
- :label =" deterministic.description"
42
- :saveKey =" deterministic.name"
33
+ :label =" argparserOptions.description"
34
+ :options =" argparserOptions.options"
35
+ :saveKey =" argparserOptions.name"
36
+ :defaultV =" argparserOptions.default"
37
+ v-show =" argparserOptions.options.length > 0"
43
38
/>
44
- <h2 class =" training" >Distributed Training</h2 >
45
- <FormCheckbox label =" Use distributed training" saveKey =" use_dist" />
46
- <div v-show =" store.config.use_dist" >
47
- <FormSelect
48
- required
49
- :saveKey =" backend.name"
50
- :label =" backend.description"
51
- :options =" backend.options"
52
- :defaultV =" backend.default"
53
- />
54
- <FormRadio
55
- :options =" [torchrun, spawn]"
56
- saveKey =" dist"
57
- defaultV =" torchrun"
58
- />
59
- <FormInput
60
- :label =" nproc_per_node.description"
61
- :type =" nproc_per_node.type"
62
- :saveKey =" nproc_per_node.name"
63
- :defaultV =" nproc_per_node.default"
64
- />
65
- <FormInput
66
- :label =" nnodes.description"
67
- :type =" nnodes.type"
68
- :saveKey =" nnodes.name"
69
- :defaultV =" nnodes.default"
70
- />
71
- <FormInput
72
- :label =" master_addr.description"
73
- :type =" master_addr.type"
74
- :saveKey =" master_addr.name"
75
- :defaultV =" master_addr.default"
76
- v-show =" store.config.nnodes > 1"
77
- />
78
- <FormInput
79
- :label =" master_port.description"
80
- :type =" master_port.type"
81
- :saveKey =" master_port.name"
82
- :defaultV =" master_port.default"
83
- v-show =" store.config.nnodes > 1"
39
+ <!-- Deterministic Options -->
40
+ <div v-show =" templateOptions.deterministic" >
41
+ <h2 class =" training" >Deterministic Training</h2 >
42
+ <FormCheckbox
43
+ :label =" deterministic.description"
44
+ :saveKey =" deterministic.name"
84
45
/>
85
46
</div >
47
+ <!-- Distributed Training -->
48
+ <div v-show =" templateOptions.distTraining" >
49
+ <h2 class =" training" >Distributed Training</h2 >
50
+ <FormCheckbox label =" Use distributed training" saveKey =" use_dist" />
51
+ <div v-show =" store.config.use_dist && templateOptions.distTraining" >
52
+ <FormSelect
53
+ required
54
+ :saveKey =" backendOptions.name"
55
+ :label =" backendOptions.description"
56
+ :options =" backendOptions.options"
57
+ :defaultV =" backendOptions.default"
58
+ />
59
+ <FormRadio
60
+ :options =" distOptions"
61
+ saveKey =" dist"
62
+ :defaultV =" distOptions.length > 0 ? distOptions[0].name : 'spawn'"
63
+ v-show =" distOptions.length > 0"
64
+ />
65
+ <FormInput
66
+ :label =" nproc_per_node.description"
67
+ :type =" nproc_per_node.type"
68
+ :saveKey =" nproc_per_node.name"
69
+ :defaultV =" nproc_per_node.default"
70
+ />
71
+ <FormInput
72
+ :label =" nnodes.description"
73
+ :type =" nnodes.type"
74
+ :saveKey =" nnodes.name"
75
+ :defaultV =" nnodes.default"
76
+ />
77
+ <FormInput
78
+ :label =" master_addr.description"
79
+ :type =" master_addr.type"
80
+ :saveKey =" master_addr.name"
81
+ :defaultV =" master_addr.default"
82
+ v-show =" store.config.nnodes > 1"
83
+ />
84
+ <FormInput
85
+ :label =" master_port.description"
86
+ :type =" master_port.type"
87
+ :saveKey =" master_port.name"
88
+ :defaultV =" master_port.default"
89
+ v-show =" store.config.nnodes > 1"
90
+ />
91
+ </div >
92
+ </div >
86
93
</div >
87
94
</template >
88
95
89
96
<script >
90
- import { computed , ref } from ' vue'
97
+ import { computed , ref , watch , reactive } from ' vue'
91
98
import { training } from ' ../metadata/metadata.json'
92
99
import FormCheckbox from ' ./FormCheckbox.vue'
93
100
import FormInput from ' ./FormInput.vue'
94
101
import FormRadio from ' ./FormRadio.vue'
95
102
import FormSelect from ' ./FormSelect.vue'
96
- import { store } from ' ../store.js'
103
+ import { saveConfig , store } from ' ../store.js'
104
+ import { templates } from ' ../templates/template_options.json'
97
105
98
106
export default {
99
107
components: { FormCheckbox, FormInput, FormRadio, FormSelect },
@@ -112,30 +120,76 @@ export default {
112
120
const isDeterministic = ref (false )
113
121
114
122
// computed properties
123
+ const templateOptions = computed (() => {
124
+ return templates[store .config .template ][' training' ]
125
+ })
126
+ const argparserOptions = computed (() => {
127
+ return findAvailableOptions (argparser, templateOptions)
128
+ })
129
+ const backendOptions = computed (() => {
130
+ // To check the state of distTraining
131
+ if (templateOptions .value .distTraining == false ) {
132
+ saveConfig (' backend' , null )
133
+ return backend
134
+ }
135
+ return findAvailableOptions (backend, templateOptions)
136
+ })
137
+ const distOptions = computed (() => {
138
+ let dist_options = []
139
+ if (templateOptions .value .distOptions == ' all' ) {
140
+ return [torchrun, spawn]
141
+ }
142
+ for (const option of [torchrun, spawn]) {
143
+ if (templateOptions .value .distOptions .includes (option .name )) {
144
+ dist_options .push (option)
145
+ }
146
+ }
147
+ return dist_options
148
+ })
149
+
115
150
const saveDeterministic = computed (() => {
116
151
saveConfig (deterministic .name , isDeterministic .value )
117
152
})
153
+
118
154
return {
119
155
store,
120
- argparser ,
156
+ argparserOptions ,
121
157
deterministic,
122
- backend,
123
- torchrun,
124
- spawn,
158
+ backendOptions,
159
+ distOptions,
125
160
nproc_per_node,
126
161
nnodes,
127
162
master_addr,
128
163
master_port,
129
164
isDeterministic,
130
165
saveDeterministic,
131
- saveDistributed
166
+ templateOptions
132
167
}
133
168
}
134
169
}
135
170
136
171
function saveDistributed (key , value ) {
137
172
saveConfig (key, value)
138
173
}
174
+
175
+ function findAvailableOptions (tempKey , templateOptions ) {
176
+ const key = tempKey .name
177
+ if (
178
+ templateOptions .value [key] == ' all' ||
179
+ ! templateOptions .value .hasOwnProperty (key)
180
+ ) {
181
+ return tempKey
182
+ } else {
183
+ store .config [key] = templateOptions .value [key][0 ]
184
+ }
185
+ return reactive ({
186
+ options: templateOptions .value [key],
187
+ default: templateOptions .value [key][0 ],
188
+ description: tempKey .description ,
189
+ name: key,
190
+ type: tempKey .type
191
+ })
192
+ }
139
193
</script >
140
194
141
195
<style scoped>
0 commit comments