Skip to content

Commit 7d1e510

Browse files
committed
fix: change back to have previous UI (#126)
- have default value in `output_dir` and `log_every_iters` - distributed training checkbox - distributed default values (`nproc_per_node`, `nnodes`, `master_addr`, and `master_port`) - updated READMEs - updated config.yaml
1 parent b37164b commit 7d1e510

File tree

12 files changed

+103
-30
lines changed

12 files changed

+103
-30
lines changed

src/components/FormCheckbox.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:id="checkboxId"
88
:required="required"
99
v-model="checked"
10-
@change="saveChecked"
10+
@change.prevent="saveChecked"
1111
/>
1212
{{ label }}
1313
</label>

src/components/FormInput.vue

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<form class="inputs-wrapper" @submit.prevent="saveInput">
2+
<div class="inputs-wrapper">
33
<p class="label-wrapper">
44
<label :for="inputId">
55
{{ label }}
@@ -13,24 +13,27 @@
1313
:type="type"
1414
:id="inputId"
1515
:required="required"
16+
@change.prevent="saveInput"
1617
/>
1718
<input
18-
min="0"
19+
min="1"
1920
v-else-if="type === 'number'"
2021
v-model.number="inputted"
2122
:type="type"
2223
:id="inputId"
2324
:required="required"
25+
@change.prevent="saveInput"
2426
/>
2527
<input
2628
v-else
2729
v-model="inputted"
2830
:type="type"
2931
:id="inputId"
3032
:required="required"
33+
@change.prevent="saveInput"
3134
/>
3235
<span class="expand"></span>
33-
</form>
36+
</div>
3437
</template>
3538

3639
<script>
@@ -53,11 +56,19 @@ export default {
5356
saveKey: {
5457
type: String,
5558
required: true
59+
},
60+
defaultV: {
61+
type: [String, Number],
62+
default: ''
5663
}
5764
},
5865
setup(props) {
59-
const { label, type, saveKey, required } = toRefs(props)
66+
const { label, type, saveKey, required, defaultV } = toRefs(props)
6067
const inputted = ref('')
68+
if (defaultV.value.length > 0 || defaultV.value) {
69+
inputted.value = defaultV.value
70+
saveConfig(saveKey.value, inputted.value)
71+
}
6172
6273
const saveInput = () => saveConfig(saveKey.value, inputted.value)
6374
const inputId = computed(() => label.value + '-input-' + type.value)

src/components/FormRadio.vue

+9-1
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,19 @@ export default {
3434
options: {
3535
type: Array,
3636
required: true
37+
},
38+
defaultV: {
39+
type: String,
40+
default: ''
3741
}
3842
},
3943
setup(props) {
40-
const { options, saveKey, required } = toRefs(props)
44+
const { options, saveKey, required, defaultV } = toRefs(props)
4145
const picked = ref('')
46+
if (defaultV.value.length > 0) {
47+
picked.value = defaultV.value
48+
saveConfig(saveKey.value, picked.value)
49+
}
4250
4351
const saveInput = () => saveConfig(saveKey.value, picked.value)
4452
const isRequired = computed(() => (required.value ? '*' : ''))

src/components/TabLoggers.vue

+2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
type="text"
66
:label="output_dir.description"
77
:saveKey="output_dir.name"
8+
:defaultV="output_dir.default"
89
required
910
/>
1011
<FormInput
1112
type="number"
1213
:label="log_every_iters.description"
1314
:saveKey="log_every_iters.name"
15+
:defaultV="log_every_iters.default"
1416
required
1517
/>
1618
<FormSelect

src/components/TabTraining.vue

+46-9
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,36 @@
77
:saveKey="deterministic.name"
88
/>
99
<h2 class="training">Distributed Training (NCCL backend)</h2>
10-
<FormRadio :options="[launch, spawn]" saveKey="dist" />
11-
<template v-for="(d, index) in distributedConfigs" :key="index">
12-
<FormInput :label="d.description" :type="d.type" :saveKey="d.name" />
13-
</template>
10+
<FormCheckbox label="Use distributed training" saveKey="use_dist" />
11+
<div v-show="store.config.use_dist">
12+
<FormRadio :options="[launch, spawn]" saveKey="dist" defaultV="launch" />
13+
<FormInput
14+
:label="nproc_per_node.description"
15+
:type="nproc_per_node.type"
16+
:saveKey="nproc_per_node.name"
17+
:defaultV="nproc_per_node.default"
18+
/>
19+
<FormInput
20+
:label="nnodes.description"
21+
:type="nnodes.type"
22+
:saveKey="nnodes.name"
23+
:defaultV="nnodes.default"
24+
/>
25+
<FormInput
26+
:label="master_addr.description"
27+
:type="master_addr.type"
28+
:saveKey="master_addr.name"
29+
:defaultV="master_addr.default"
30+
v-show="store.config.nnodes > 1"
31+
/>
32+
<FormInput
33+
:label="master_port.description"
34+
:type="master_port.type"
35+
:saveKey="master_port.name"
36+
:defaultV="master_port.default"
37+
v-show="store.config.nnodes > 1"
38+
/>
39+
</div>
1440
</div>
1541
</template>
1642

@@ -20,26 +46,37 @@ import { training } from '../metadata/metadata.json'
2046
import FormCheckbox from './FormCheckbox.vue'
2147
import FormInput from './FormInput.vue'
2248
import FormRadio from './FormRadio.vue'
49+
import { store } from '../store.js'
2350
2451
export default {
2552
components: { FormCheckbox, FormInput, FormRadio },
2653
setup() {
27-
const { deterministic, launch, spawn, ...distributedConfigs } = training
54+
const {
55+
deterministic,
56+
launch,
57+
spawn,
58+
nproc_per_node,
59+
nnodes,
60+
master_addr,
61+
master_port
62+
} = training
2863
const isDeterministic = ref(false)
29-
const distributedValue = ref({})
3064
3165
// computed properties
3266
const saveDeterministic = computed(() => {
3367
saveConfig(deterministic.name, isDeterministic.value)
3468
})
3569
return {
70+
store,
71+
deterministic,
3672
launch,
3773
spawn,
38-
deterministic,
74+
nproc_per_node,
75+
nnodes,
76+
master_addr,
77+
master_port,
3978
isDeterministic,
4079
saveDeterministic,
41-
distributedConfigs,
42-
distributedValue,
4380
saveDistributed
4481
}
4582
}

src/metadata/metadata.json

+12-6
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,28 @@
1919
"name": "nproc_per_node",
2020
"type": "number",
2121
"description": "Number of processes to launch on each node (mandatory for single node, multi gpus distributed training)",
22-
"min": 1
22+
"min": 1,
23+
"default": 2
2324
},
2425
"nnodes": {
2526
"name": "nnodes",
2627
"type": "number",
2728
"description": "Number of nodes to use for distributed training (mandatory for multi nodes, multi gpus distributed training)",
28-
"min": 1
29+
"min": 1,
30+
"default": 1
2931
},
3032
"master_addr": {
3133
"name": "master_addr",
3234
"type": "text",
33-
"description": "Master node TCP/IP address for torch native backends (mandatory if you have filled number of nodes)"
35+
"description": "Master node TCP/IP address for torch native backends (mandatory if you have filled number of nodes)",
36+
"default": "127.0.0.1"
3437
},
3538
"master_port": {
3639
"name": "master_port",
3740
"type": "number",
3841
"description": "Master node port for torch native backends (mandatory if you have filled number of nodes)",
39-
"min": 0
42+
"min": 0,
43+
"default": 8080
4044
}
4145
},
4246
"handlers": {
@@ -93,12 +97,14 @@
9397
"output_dir": {
9498
"name": "output_dir",
9599
"type": "text",
96-
"description": "Directory to save all outputs"
100+
"description": "Directory to save all outputs",
101+
"default": "./logs"
97102
},
98103
"log_every_iters": {
99104
"name": "log_every_iters",
100105
"type": "number",
101-
"description": "Logging interval for training statistics"
106+
"description": "Logging interval for training statistics",
107+
"default": 2
102108
},
103109
"logger": {
104110
"name": "logger",

src/templates/template-common/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#::: if (it.use_dist) { :::#
12
#::: if (it.dist === 'launch') { :::#
23
#::: if (it.nproc_per_node) { :::#
3-
#::: if (it.nnodes && it.master_addr && it.master_port) { :::#
4+
#::: if (it.nnodes > 1 && it.master_addr && it.master_port) { :::#
45

56
### Multi Node, Multi GPU Training (`torch.distributed.launch`) (recommended)
67

@@ -56,7 +57,7 @@ python -m torch.distributed.launch \
5657

5758
#::: if (it.dist === 'spawn') { :::#
5859
#::: if (it.nproc_per_node) { :::#
59-
#::: if (it.nnodes && it.master_addr && it.master_port) { :::#
60+
#::: if (it.nnodes > 1 && it.master_addr && it.master_port) { :::#
6061

6162
### Multi Node, Multi GPU Training (`torch.multiprocessing.spawn`)
6263

@@ -110,7 +111,7 @@ python main.py \
110111
#::: } :::#
111112
#::: } :::#
112113

113-
#::: if (!it.nproc_per_node) { :::#
114+
#::: } else { :::#
114115

115116
### 1 GPU Training
116117

src/templates/template-common/config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ nproc_per_node: #:::= it.nproc_per_node :::#
1717
#::: if (it.nnodes) { :::#
1818
# distributed multi node spawn
1919
nnodes: #:::= it.nnodes :::#
20+
#::: if (it.nnodes > 1) { :::#
2021
node_rank: 0
2122
master_addr: #:::= it.master_addr :::#
2223
master_port: #:::= it.master_port :::#
2324
#::: } :::#
2425
#::: } :::#
26+
#::: } :::#
2527

2628
#::: if (it.filename_prefix) { :::#
2729
filename_prefix: #:::= it.filename_prefix :::#

src/templates/template-vision-classification/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ pip install -r requirements.txt --progress-bar off -U
1010

1111
## Training
1212

13+
#::: if (it.use_dist) { :::#
1314
#::: if (it.dist === 'launch') { :::#
1415
#::: if (it.nproc_per_node) { :::#
15-
#::: if (it.nnodes && it.master_addr && it.master_port) { :::#
16+
#::: if (it.nnodes > 1 && it.master_addr && it.master_port) { :::#
1617

1718
### Multi Node, Multi GPU Training (`torch.distributed.launch`) (recommended)
1819

@@ -68,7 +69,7 @@ python -m torch.distributed.launch \
6869

6970
#::: if (it.dist === 'spawn') { :::#
7071
#::: if (it.nproc_per_node) { :::#
71-
#::: if (it.nnodes && it.master_addr && it.master_port) { :::#
72+
#::: if (it.nnodes > 1 && it.master_addr && it.master_port) { :::#
7273

7374
### Multi Node, Multi GPU Training (`torch.multiprocessing.spawn`)
7475

@@ -122,7 +123,7 @@ python main.py \
122123
#::: } :::#
123124
#::: } :::#
124125

125-
#::: if (!it.nproc_per_node) { :::#
126+
#::: } else { :::#
126127

127128
### 1 GPU Training
128129

src/templates/template-vision-classification/config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ nproc_per_node: #:::= it.nproc_per_node :::#
1717
#::: if (it.nnodes) { :::#
1818
# distributed multi node spawn
1919
nnodes: #:::= it.nnodes :::#
20+
#::: if (it.nnodes > 1) { :::#
2021
node_rank: 0
2122
master_addr: #:::= it.master_addr :::#
2223
master_port: #:::= it.master_port :::#
2324
#::: } :::#
2425
#::: } :::#
26+
#::: } :::#
2527

2628
#::: if (it.filename_prefix) { :::#
2729
filename_prefix: #:::= it.filename_prefix :::#

src/templates/template-vision-dcgan/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ pip install -r requirements.txt --progress-bar off -U
1010

1111
## Training
1212

13+
#::: if (it.use_dist) { :::#
1314
#::: if (it.dist === 'launch') { :::#
1415
#::: if (it.nproc_per_node) { :::#
15-
#::: if (it.nnodes && it.master_addr && it.master_port) { :::#
16+
#::: if (it.nnodes > 1 && it.master_addr && it.master_port) { :::#
1617

1718
### Multi Node, Multi GPU Training (`torch.distributed.launch`) (recommended)
1819

@@ -68,7 +69,7 @@ python -m torch.distributed.launch \
6869

6970
#::: if (it.dist === 'spawn') { :::#
7071
#::: if (it.nproc_per_node) { :::#
71-
#::: if (it.nnodes && it.master_addr && it.master_port) { :::#
72+
#::: if (it.nnodes > 1 && it.master_addr && it.master_port) { :::#
7273

7374
### Multi Node, Multi GPU Training (`torch.multiprocessing.spawn`)
7475

@@ -122,7 +123,7 @@ python main.py \
122123
#::: } :::#
123124
#::: } :::#
124125

125-
#::: if (!it.nproc_per_node) { :::#
126+
#::: } else { :::#
126127

127128
### 1 GPU Training
128129

src/templates/template-vision-dcgan/config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ nproc_per_node: #:::= it.nproc_per_node :::#
2020
#::: if (it.nnodes) { :::#
2121
# distributed multi node spawn
2222
nnodes: #:::= it.nnodes :::#
23+
#::: if (it.nnodes > 1) { :::#
2324
node_rank: 0
2425
master_addr: #:::= it.master_addr :::#
2526
master_port: #:::= it.master_port :::#
2627
#::: } :::#
2728
#::: } :::#
29+
#::: } :::#
2830

2931
#::: if (it.filename_prefix) { :::#
3032
filename_prefix: #:::= it.filename_prefix :::#

0 commit comments

Comments
 (0)