Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mhc_rank
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Patrick Skillman-Lawrence
mhc_rank
Commits
b82888ef
Commit
b82888ef
authored
5 years ago
by
Tim O'Donnell
Browse files
Options
Downloads
Patches
Plain Diff
fix
parent
7df3a99e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mhcflurry/local_parallelism.py
+1
-1
1 addition, 1 deletion
mhcflurry/local_parallelism.py
mhcflurry/train_pan_allele_models_command.py
+22
-25
22 additions, 25 deletions
mhcflurry/train_pan_allele_models_command.py
with
23 additions
and
26 deletions
mhcflurry/local_parallelism.py
+
1
−
1
View file @
b82888ef
...
...
@@ -21,7 +21,7 @@ def add_local_parallelism_args(parser):
default
=
0
,
type
=
int
,
metavar
=
"
N
"
,
help
=
"
Number of processes to parallelize training over.
Experimental.
"
help
=
"
Number of
local
processes to parallelize training over.
"
"
Set to 0 for serial run. Default: %(default)s.
"
)
group
.
add_argument
(
"
--backend
"
,
...
...
This diff is collapsed.
Click to expand it.
mhcflurry/train_pan_allele_models_command.py
+
22
−
25
View file @
b82888ef
...
...
@@ -398,7 +398,7 @@ def train_models(args):
print
(
"
Found %d work items, of which %d are incomplete and will run now.
"
%
(
len
(
all_work_items
),
len
(
work_items
)))
serial_run
=
args
.
num_jobs
==
0
serial_run
=
not
args
.
cluster_parallelism
and
args
.
num_jobs
==
0
# The estimated time to completion is more accurate if we randomize
# the order of the work.
...
...
@@ -415,7 +415,19 @@ def train_models(args):
start
=
time
.
time
()
if
args
.
cluster_parallelism
:
worker_pool
=
None
if
serial_run
:
# Run in serial. Every worker is passed the same predictor,
# which it adds models to, so no merging is required. It also saves
# as it goes so no saving is required at the end.
print
(
"
Processing %d work items in serial.
"
%
len
(
work_items
))
for
_
in
tqdm
.
trange
(
len
(
work_items
)):
item
=
work_items
.
pop
(
0
)
# want to keep freeing up memory
work_predictor
=
train_model
(
**
item
)
assert
work_predictor
is
predictor
assert
not
work_items
results_generator
=
None
elif
args
.
cluster_parallelism
:
# Run using separate processes HPC cluster.
results_generator
=
cluster_results_from_args
(
args
,
...
...
@@ -423,35 +435,21 @@ def train_models(args):
work_items
=
work_items
,
constant_data
=
GLOBAL_DATA
,
result_serialization_method
=
"
save_predictor
"
)
worker_pool
=
None
else
:
worker_pool
=
worker_pool_with_gpu_assignments_from_args
(
args
)
print
(
"
Worker pool
"
,
worker_pool
)
assert
worker_pool
is
not
None
if
worker_pool
:
print
(
"
Processing %d work items in parallel.
"
%
len
(
work_items
))
assert
not
serial_run
print
(
"
Processing %d work items in parallel.
"
%
len
(
work_items
))
assert
not
serial_run
results_generator
=
worker_pool
.
imap_unordered
(
partial
(
call_wrapped_kwargs
,
train_model
),
work_items
,
chunksize
=
1
)
else
:
# Run in serial. In this case, every worker is passed the same predictor,
# which it adds models to, so no merging is required. It also saves
# as it goes so no saving is required at the end.
print
(
"
Processing %d work items in serial.
"
%
len
(
work_items
))
assert
serial_run
for
_
in
tqdm
.
trange
(
len
(
work_items
)):
item
=
work_items
.
pop
(
0
)
# want to keep freeing up memory
work_predictor
=
train_model
(
**
item
)
assert
work_predictor
is
predictor
assert
not
work_items
results_generator
=
None
results_generator
=
worker_pool
.
imap_unordered
(
partial
(
call_wrapped_kwargs
,
train_model
),
work_items
,
chunksize
=
1
)
if
results_generator
:
#for new_predictor in tqdm.tqdm(results_generator, total=len(work_items)):
for
new_predictor
in
results_generator
:
for
new_predictor
in
tqdm
.
tqdm
(
results_generator
,
total
=
len
(
work_items
)):
save_start
=
time
.
time
()
(
new_model_name
,)
=
predictor
.
merge_in_place
([
new_predictor
])
predictor
.
save
(
...
...
@@ -465,7 +463,6 @@ def train_models(args):
time
.
time
()
-
save_start
,
args
.
out_models_dir
))
print
(
"
Saving final predictor to: %s
"
%
args
.
out_models_dir
)
# We want the final predictor to support all alleles with sequences, not
# just those we actually used for model training.
predictor
.
allele_to_sequence
=
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment