Skip to content

FIX nested backend setting n_jobs=-1 - #785

Merged
ogrisel merged 6 commits into
joblib:masterfrom
tomMoral:FIX_nested_backend
Oct 5, 2018
Merged

ogrisel merged 6 commits into
joblib:masterfrom
tomMoral:FIX_nested_backend

Conversation

@tomMoral

@tomMoral tomMoral commented Oct 5, 2018

Copy link
Copy Markdown
Contributor

Fix for #784

@codecov

codecov Bot commented Oct 5, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #785 into master will increase coverage by 0.58%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #785      +/-   ##
==========================================
+ Coverage   94.69%   95.27%   +0.58%     
==========================================
  Files          44       44              
  Lines        6274     6307      +33     
==========================================
+ Hits         5941     6009      +68     
+ Misses        333      298      -35
Impacted Files Coverage Δ
joblib/_parallel_backends.py 93.6% <100%> (-2.41%) ⬇️
joblib/test/test_dask.py 98.28% <100%> (+0.17%) ⬆️
joblib/_dask.py 94.93% <100%> (ø) ⬆️
joblib/test/test_parallel.py 96.91% <100%> (+0.6%) ⬆️
joblib/parallel.py 97.56% <100%> (ø) ⬆️
joblib/test/test_memory.py 98.05% <0%> (-0.14%) ⬇️
joblib/memory.py 95.61% <0%> (+0.06%) ⬆️
joblib/test/test_memmapping.py 99.41% <0%> (+0.29%) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 830dc7d...ae91101. Read the comment docs.

Comment thread joblib/test/test_parallel.py Outdated

with Parallel() as p:
with Parallel(n_jobs=2) as p:
print(p._backend)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover print

Comment thread joblib/parallel.py Outdated
with parallel_backend(self._backend):
# Set the default nested backend to self._backend but do not set the
# change the default number of processes to -1
with parallel_backend(self._backend, n_jobs=None):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worried this might disable nested parallelism for backends that expect

with parallel_backend('dask', n_jobs=-1):
    do_stuff()

Ideally, all the Parallel calls in the do_stuff function and nested calls should inherit the n_jobs=-1.

I am not sure if we can handle this properly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dask is the only backend where this would make sense. Typically, you don't want the nested backend to use n_jobs=-1 as it leads to massive over-subscription.

A way to deal with this is to have get_nested_backend return both a backend and n_jobs. That way, only dask will return n_jobs=-1 and others can have n_jobs=None.

@ogrisel

ogrisel commented Oct 5, 2018

Copy link
Copy Markdown
Contributor

@tomMoral I just pushed a new test to show what is the expected behavior with the dask backend.

@ogrisel ogrisel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but we need an entry to the change log.

@ogrisel
ogrisel merged commit 9db62d5 into joblib:master Oct 5, 2018
@tomMoral
tomMoral deleted the FIX_nested_backend branch October 10, 2018 14:37
yarikoptic added a commit to yarikoptic/joblib that referenced this pull request Apr 12, 2019
* tag '0.13.0':
  Release 0.13.0
  Use https (joblib#805)
  MTN bump loky to 2.4.2 (joblib#804)
  DOC: provide some useful variables for Makefile (joblib#794)
  DOC serialization and processes (joblib#803)
  ENH update loky 2.4.0 (joblib#802)
  FIX backward compatibility for nested backend (joblib#789)
  enable python 3.7 (joblib#795)
  memory: add test for call_and_shelve performance (joblib#791)
  FIX nested backend not changed by SequentialBackend (joblib#792)
  cloudpickle 0.6.0 (joblib#788)
  FIX nested backend setting n_jobs=-1 (joblib#785)
  Raises a more explicit exception when a corrupted MemorizedResult is loaded (joblib#768)
  Back to dev mode
yarikoptic added a commit to yarikoptic/joblib that referenced this pull request Apr 12, 2019
* releases:
  Release 0.13.0
  Use https (joblib#805)
  MTN bump loky to 2.4.2 (joblib#804)
  DOC: provide some useful variables for Makefile (joblib#794)
  DOC serialization and processes (joblib#803)
  ENH update loky 2.4.0 (joblib#802)
  FIX backward compatibility for nested backend (joblib#789)
  enable python 3.7 (joblib#795)
  memory: add test for call_and_shelve performance (joblib#791)
  FIX nested backend not changed by SequentialBackend (joblib#792)
  cloudpickle 0.6.0 (joblib#788)
  FIX nested backend setting n_jobs=-1 (joblib#785)
  Raises a more explicit exception when a corrupted MemorizedResult is loaded (joblib#768)
  Back to dev mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants