forked from davidbenjamin/permutect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
permutect_train_base_model.wdl
251 lines (225 loc) · 8.52 KB
/
permutect_train_base_model.wdl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
version 1.0
workflow TrainPermutectBaseModel {
input {
File train_tar
File? pretrained_model
Int num_epochs
Int batch_size
Int inference_batch_size
Int? num_workers
Float dropout_p
Int? alt_downsample
Float reweighting_range
Array[Int] read_layers
Int num_transformer_heads
Int transformer_hidden_dimension
Int num_transformer_layers
Array[Int] info_layers
Array[Int] aggregation_layers
Array[String] ref_seq_layer_strings
String? train_m3_extra_args
Boolean use_gpu
Int? gpu_count
String permutect_docker
Int? preemptible
Int? max_retries
}
if (use_gpu) {
call TrainPermutectBaseGPU {
input:
train_tar = train_tar,
pretrained_model = pretrained_model,
permutect_docker = permutect_docker,
preemptible = preemptible,
max_retries = max_retries,
num_epochs = num_epochs,
batch_size = batch_size,
inference_batch_size = inference_batch_size,
num_workers = num_workers,
gpu_count = gpu_count,
dropout_p = dropout_p,
alt_downsample = alt_downsample,
reweighting_range = reweighting_range,
read_layers = read_layers,
num_transformer_heads = num_transformer_heads,
transformer_hidden_dimension = transformer_hidden_dimension,
num_transformer_layers = num_transformer_layers,
info_layers = info_layers,
aggregation_layers = aggregation_layers,
ref_seq_layer_strings = ref_seq_layer_strings,
extra_args = train_m3_extra_args
}
}
if (!use_gpu) {
call TrainPermutectBaseCPU {
input:
train_tar = train_tar,
pretrained_model = pretrained_model,
permutect_docker = permutect_docker,
preemptible = preemptible,
max_retries = max_retries,
num_epochs = num_epochs,
batch_size = batch_size,
inference_batch_size = inference_batch_size,
num_workers = num_workers,
dropout_p = dropout_p,
alt_downsample = alt_downsample,
reweighting_range = reweighting_range,
read_layers = read_layers,
num_transformer_heads = num_transformer_heads,
transformer_hidden_dimension = transformer_hidden_dimension,
num_transformer_layers = num_transformer_layers,
info_layers = info_layers,
aggregation_layers = aggregation_layers,
ref_seq_layer_strings = ref_seq_layer_strings,
extra_args = train_m3_extra_args
}
}
output {
File base_model = select_first([TrainPermutectBaseGPU.base_model, TrainPermutectBaseCPU.base_model])
File training_tensorboard_tar = select_first([TrainPermutectBaseGPU.tensorboard_tar, TrainPermutectBaseCPU.tensorboard_tar])
}
}
## HORRIBLE HACK: because there is no way in Terra to set gpuCount to 0, in order to optionally use GPU we have to write
## two nearly-identical tasks, one for CPU and one for GPU. See https://github.com/broadinstitute/cromwell/issues/6679
task TrainPermutectBaseGPU {
input {
File train_tar
File? pretrained_model
Int num_epochs
Int batch_size
Int inference_batch_size
Int? num_workers
Int? gpu_count
Float dropout_p
Int? alt_downsample
Float reweighting_range
Array[Int] read_layers
Int num_transformer_heads
Int transformer_hidden_dimension
Int num_transformer_layers
Array[Int] info_layers
Array[Int] aggregation_layers
Array[String] ref_seq_layer_strings
String? extra_args
String permutect_docker
Int? preemptible
Int? max_retries
Int? disk_space
Int? cpu
Int? mem
Boolean use_ssd = false
}
# Mem is in units of GB but our command and memory runtime values are in MB
Int machine_mem = if defined(mem) then mem * 1000 else 16000
Int command_mem = machine_mem - 500
command <<<
set -e
train_base_model \
--train_tar ~{train_tar} \
~{"--pretrained_model " + pretrained_model} \
--read_layers ~{sep=' ' read_layers} \
--num_transformer_heads ~{num_transformer_heads} \
--transformer_hidden_dimension ~{transformer_hidden_dimension} \
--num_transformer_layers ~{num_transformer_layers} \
--info_layers ~{sep=' ' info_layers} \
--aggregation_layers ~{sep=' ' aggregation_layers} \
--ref_seq_layer_strings ~{sep=' ' ref_seq_layer_strings} \
--dropout_p ~{dropout_p} \
~{"--alt_downsample " + alt_downsample} \
--reweighting_range ~{reweighting_range} \
--batch_size ~{batch_size} \
--inference_batch_size ~{inference_batch_size} \
~{"--num_workers " + num_workers} \
--num_epochs ~{num_epochs} \
--output base_model.pt \
--tensorboard_dir tensorboard \
~{extra_args}
tar cvf tensorboard.tar tensorboard/
>>>
runtime {
docker: permutect_docker
bootDiskSizeGb: 12
memory: machine_mem + " MB"
disks: "local-disk " + select_first([disk_space, 100]) + if use_ssd then " SSD" else " HDD"
preemptible: select_first([preemptible, 10])
maxRetries: select_first([max_retries, 0])
cpu: select_first([cpu, 1])
gpuType: "nvidia-tesla-t4"
gpuCount: select_first([gpu_count, 1])
nvidiaDriverVersion: "535.183.01"
zones : ["us-central1-a", "us-central1-b", "us-central1-c"]
}
output {
File base_model = "base_model.pt"
File tensorboard_tar = "tensorboard.tar"
}
}
task TrainPermutectBaseCPU {
input {
File train_tar
File? pretrained_model
Int num_epochs
Int batch_size
Int inference_batch_size
Int? num_workers
Float dropout_p
Int? alt_downsample
Float reweighting_range
Array[Int] read_layers
Int num_transformer_heads
Int transformer_hidden_dimension
Int num_transformer_layers
Array[Int] info_layers
Array[Int] aggregation_layers
Array[String] ref_seq_layer_strings
String? extra_args
String permutect_docker
Int? preemptible
Int? max_retries
Int? disk_space
Int? cpu
Int? mem
Boolean use_ssd = false
}
# Mem is in units of GB but our command and memory runtime values are in MB
Int machine_mem = if defined(mem) then mem * 1000 else 16000
Int command_mem = machine_mem - 500
command <<<
set -e
train_base_model \
--train_tar ~{train_tar} \
~{"--pretrained_model " + pretrained_model} \
--read_layers ~{sep=' ' read_layers} \
--num_transformer_heads ~{num_transformer_heads} \
--transformer_hidden_dimension ~{transformer_hidden_dimension} \
--num_transformer_layers ~{num_transformer_layers} \
--info_layers ~{sep=' ' info_layers} \
--aggregation_layers ~{sep=' ' aggregation_layers} \
--ref_seq_layer_strings ~{sep=' ' ref_seq_layer_strings} \
--dropout_p ~{dropout_p} \
~{"--alt_downsample " + alt_downsample} \
--reweighting_range ~{reweighting_range} \
--batch_size ~{batch_size} \
--inference_batch_size ~{inference_batch_size} \
~{"--num_workers " + num_workers} \
--num_epochs ~{num_epochs} \
--output base_model.pt \
--tensorboard_dir tensorboard \
~{extra_args}
tar cvf tensorboard.tar tensorboard/
>>>
runtime {
docker: permutect_docker
bootDiskSizeGb: 12
memory: machine_mem + " MB"
disks: "local-disk " + select_first([disk_space, 100]) + if use_ssd then " SSD" else " HDD"
preemptible: select_first([preemptible, 10])
maxRetries: select_first([max_retries, 0])
cpu: select_first([cpu, 1])
}
output {
File base_model = "base_model.pt"
File tensorboard_tar = "tensorboard.tar"
}
}