77 using one of the tools provided below:
88
99 <h2 >Argument Parser</h2 >
10-
1110 <ul >
12- <li >
11+ <li v-show = " argparserOptions.options.includes('argparse') " >
1312 <a href =" https://docs.python.org/3/library/argparse.html" id =" arg"
1413 >Argparse</a
1514 >
1615 - is a python built-in tool to handle command-line arguments
1716 </li >
18- <li >
17+ <li v-show = " argparserOptions.options.includes('fire') " >
1918 <a
2019 href =" https://github.com/google/python-fire/blob/master/docs/guide.md"
2120 id =" arg"
2423 - transforms Python functions into user-friendly command-line tools,
2524 ideal for DL experimentation.
2625 </li >
27- <li >
26+ <li v-show = " argparserOptions.options.includes('hydra') " >
2827 <a href =" https://hydra.cc" id =" arg" >Hydra</a >
2928 - Simplifying deep learning experiments through flexible configuration
3029 management
3130 </li >
3231 </ul >
3332 <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"
4338 />
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"
8445 />
8546 </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 >
8693 </div >
8794</template >
8895
8996<script >
90- import { computed , ref } from ' vue'
97+ import { computed , ref , watch , reactive } from ' vue'
9198import { training } from ' ../metadata/metadata.json'
9299import FormCheckbox from ' ./FormCheckbox.vue'
93100import FormInput from ' ./FormInput.vue'
94101import FormRadio from ' ./FormRadio.vue'
95102import 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'
97105
98106export default {
99107 components: { FormCheckbox, FormInput, FormRadio, FormSelect },
@@ -112,30 +120,76 @@ export default {
112120 const isDeterministic = ref (false )
113121
114122 // 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+
115150 const saveDeterministic = computed (() => {
116151 saveConfig (deterministic .name , isDeterministic .value )
117152 })
153+
118154 return {
119155 store,
120- argparser ,
156+ argparserOptions ,
121157 deterministic,
122- backend,
123- torchrun,
124- spawn,
158+ backendOptions,
159+ distOptions,
125160 nproc_per_node,
126161 nnodes,
127162 master_addr,
128163 master_port,
129164 isDeterministic,
130165 saveDeterministic,
131- saveDistributed
166+ templateOptions
132167 }
133168 }
134169}
135170
136171function saveDistributed (key , value ) {
137172 saveConfig (key, value)
138173}
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+ }
139193 </script >
140194
141195<style scoped>
0 commit comments