Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel tools and compiling #701

Merged
merged 55 commits into from
Sep 18, 2018
Merged

Parallel tools and compiling #701

merged 55 commits into from
Sep 18, 2018

Conversation

nonhermitian
Copy link
Contributor

@nonhermitian nonhermitian commented Jul 31, 2018

Fix #706

Summary

Introduces the ability to run functions in parallel.

The following routines have been added:

  • Parallel tools parallel_map.

This is supposed to replace #679.

Details and comments

parallel_map uses the multiprocessing library that is not efficient on Windows, and therefore implements a serial loop on Win platforms. In addition, it checks if the input has len(value)==1 and just returns the single execution result.

The parallel_map is smart in the sense that it checks for the QISKIT_IN_PARALLEL env flag and will not execute in parallel if this flag is 'TRUE', as set when the parallel_map is being executed. So you can nest calls to parallel_map, and only the outer one will execute in parallel. This flag is set to 'FALSE' at init, and is reset when a QISKitError is raised.

The number of processes to spawn is set automatically to the number of physical cpus on the local machine. Discovering this value on Windows requires the use of the comtypes module. Although this is an extra dependency, it is installed by default in Anaconda on Windows.

@nonhermitian
Copy link
Contributor Author

@diego-plan9, @atilag, and @ajavadia you probably have thoughts on this PR. Please let me know.

@chunfuchen Does this look like what you aimed to do in #679? Don't want to step on your toes here.

@nonhermitian nonhermitian added this to the 0.6 milestone Jul 31, 2018
@nonhermitian nonhermitian added the type: enhancement It's working, but needs polishing label Jul 31, 2018
@chunfuchen
Copy link
Contributor

@nonhermitian Yes, this way is excellent :), it is what I want to do in #679 .

@nonhermitian nonhermitian changed the title [WIP] Parallel tools and compiling Parallel tools and compiling Jul 31, 2018
@atilag
Copy link
Member

atilag commented Aug 1, 2018

Thanks @nonhermitian
This is going to be actually a great improvement in our compilation times. It won't improve anything on Windows though but this is something we can't fix in the short term, and definitely nothing that the Python concurrent API could tackle.
As commented by @jaygambetta in #704 , let's merge #704 first and then tackle this one.
Anyway, we may need to work out some refactoring of this PR. Splitting it into two PRs could make sense because there are actually two features introduced here:

    • Parallel compilation
    • Jupyter notebook progress bar

So a PR with the first point using some sort of event mechanism (Pub/Sub?) to decouple the progress bar from the compilation could be an option (we can follow up on issue #706)
And another PR implementing the Progress bar into the wrapper, and, possibly, as part of a new Jupyter Notebook tooling (following up on #708?)

Does it make sense @nonhermitian?

@nonhermitian
Copy link
Contributor Author

The refactor is fine by me. I will make a new PR for the parallel parts, and let you handle the progress bar stuff as I am sure you will want to rework that as part of the Pub/Sub framework.

This will also allow me to merge #383 with the parallel components, as that PR gives a nice way of returning the number of physical CPU cores, rather than the number of cores + hyperthreads that is returned by the multiprocessing library. Thus we can avoid dispatching too many processes.

@nonhermitian
Copy link
Contributor Author

@atilag, This has been updated in the direction that you suggested. In addition, the HTMLProgressBar uses Jupyter widgets, and there are new magic functions to make life easier in the notebook env.

@nonhermitian nonhermitian self-assigned this Aug 6, 2018
@nonhermitian nonhermitian dismissed diego-plan9’s stale review September 10, 2018 02:10

This review is a bit out of date with our current plans.

@nonhermitian
Copy link
Contributor Author

@mtreinish, @ajavadia please take a look.

@jaygambetta
Copy link
Member

@nonhermitian can you put all the utils inside the transpiler folder and then we are good to merge this PR. How it talks to other parts of qiskit-terra we will discuss later.

@nonhermitian nonhermitian merged commit c9c4ed5 into Qiskit:master Sep 18, 2018
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
* Parallel tools and compiling

* add blank line

* Add parallel compile test

- Also try to work around lint and optional imports

* disable import-error for optional import

* fix indent

* Major update wiht magics

* fix compile lint

* fix style

* disable import errors

* white space

* Add compile with TextProgressBar test

* Remove jupyter components

* shorten parallel test time

* Minimize the parallel routines

* cleanup merge

* updates

* more updates

* fix comtypes issue

* add comtypes

* make comtypes requirement on windows

* update changelog

* review updates

* more updates

* remove callback function

* fix conflict

* Add progressbars back

* fix lint errors

* better grabbing of progress bars

* grab bars in order created

* Make jupyter tools availabel by default

* fix circular import

* switch used order

* fix move lint disable

* fix signature

* fix changelog and releases

* revert erroneous changes from git history

* revert one more

* add back psutil requirement

* remove high-level imports

* refine changelog

* move everything to transpiler folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement It's working, but needs polishing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parallel circuit compilation
7 participants