qiskit/setup.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

142 lines
6.2 KiB
Python
Raw Normal View History

# This code is part of Qiskit.
Revise travis configuration, using cmake * Revise the travis configuration for using `cmake` for the several targets, and use "stages" instead of parallel jobs: * define three stages that are executed if the previous one suceeds: 1. "linter and pure python test": executes the linter and a test without compiling the binaries, with the idea of providing quick feedback for PRs. 2. "test": launch the test, including the compilation of binaries, under GNU/Linux Python 3.6 and 3.6; and osx Python 3.6. 3. "deploy doc and pypi": for the stable branch, deploy the docs to the landing page, and when using a specific commit message, build the GNU/Linux and osx wheels, uploading them to test.pypi. * use yaml anchors and definitions to avoid repeating code (and working around travis limitations). * Modify the `cmake``configuration to accomodate the stages flow: * allow conditional creation of compilation and QA targets, mainly for saving some time in some jobs. * move the tests to `cmake/tests.cmake`. * Update the tests: * add a `requires_qe_access` decorator that retrieves QE_TOKEN and QE_URL and appends them to the parameters in an unified manner. * add an environment variable `SKIP_ONLINE_TESTS` that allows to skip the tests that need network access. * replace `TRAVIS_FORK_PULL_REQUEST` with the previous two mechanisms, adding support for AppVeyor as well. * fix a problem with matplotlib under osx headless, effectively skipping `test_visualization.py` during the travis osx jobs. * Move Sphinx to `requirements-dev.txt`.
2018-02-13 05:11:28 +08:00
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
Revise travis configuration, using cmake * Revise the travis configuration for using `cmake` for the several targets, and use "stages" instead of parallel jobs: * define three stages that are executed if the previous one suceeds: 1. "linter and pure python test": executes the linter and a test without compiling the binaries, with the idea of providing quick feedback for PRs. 2. "test": launch the test, including the compilation of binaries, under GNU/Linux Python 3.6 and 3.6; and osx Python 3.6. 3. "deploy doc and pypi": for the stable branch, deploy the docs to the landing page, and when using a specific commit message, build the GNU/Linux and osx wheels, uploading them to test.pypi. * use yaml anchors and definitions to avoid repeating code (and working around travis limitations). * Modify the `cmake``configuration to accomodate the stages flow: * allow conditional creation of compilation and QA targets, mainly for saving some time in some jobs. * move the tests to `cmake/tests.cmake`. * Update the tests: * add a `requires_qe_access` decorator that retrieves QE_TOKEN and QE_URL and appends them to the parameters in an unified manner. * add an environment variable `SKIP_ONLINE_TESTS` that allows to skip the tests that need network access. * replace `TRAVIS_FORK_PULL_REQUEST` with the previous two mechanisms, adding support for AppVeyor as well. * fix a problem with matplotlib under osx headless, effectively skipping `test_visualization.py` during the travis osx jobs. * Move Sphinx to `requirements-dev.txt`.
2018-02-13 05:11:28 +08:00
"The Qiskit Terra setup file."
import os
import re
from setuptools import setup, find_packages
Implement multithreaded stochastic swap in rust (#7658) * Implement multithreaded stochastic swap in rust This commit is a rewrite of the core swap trials functionality in the StochasticSwap transpiler pass. Previously this core routine was written using Cython (see #1789) which had great performance, but that implementation was single threaded. The core of the stochastic swap algorithm by it's nature is well suited to be executed in parallel, it attempts a number of random trials and then picks the best result from all the trials and uses that for that layer. These trials can easily be run in parallel as there is no data dependency between the trials (there are shared inputs but read-only). As the algorithm generally scales exponentially the speed up from running the trials in parallel can offset this and improve the scaling of the pass. Running the pass in parallel was previously tried in #4781 using Python multiprocessing but the overhead of launching an additional process and serializing the input arrays for each trial was significantly larger than the speed gains. To run the algorithm efficiently in parallel multithreading is needed to leverage shared memory on shared inputs. This commit rewrites the cython routine using rust. This was done for two reasons. The first is that rust's safety guarantees make dealing with and writing parallel code much easier and safer. It's also multiplatform because the rust language supports native threading primatives in language. The second is while writing parallel cython code using open-mp there are limitations with it, mainly on windows. In practice it was also difficult to write and maintain parallel cython code as it has very strict requirements on python and c code interactions. It was much faster and easier to port it to rust and the performance for each iteration (outside of parallelism) is the same (in some cases marginally faster) in rust. The implementation here reuses the data structures that the previous cython implementation introduced (mainly flattening all the terra objects into 1d or 2d numpy arrays for efficient access from C). The speedups from this PR can be significant, calling transpile() on a 400 qubit (with a depth of 10) QV model circuit targetting a 409 heavy hex coupling map goes from ~200 seconds with the single threaded cython to ~60 seconds with this PR locally on a 32 core system, When transpiling a 1000 qubit (also with a depth of 10) QV model circuit targetting a 1081 qubit heavy hex coupling map goes from taking ~6500 seconds to ~720 seconds. The tradeoff with this PR is for local qiskit-terra development a rust compiler needs to be installed. This is made trivial using rustup (https://rustup.rs/), but it is an additional burden and one that we might not want to make. If so we can look at turning this PR into a separate repository/package that qiskit-terra can depend on. The tradeoff here is that we'll be adding friction to the api boundary between the pass and the core swap trials interface. But, it does ease the dependency on development for qiskit-terra. * Sanitize packaging to support future modules This commit fixes how we package the compiled rust module in qiskit-terra. As a single rust project only gives us a single compiled binary output we can't use the same scheme we did previously with cython with a separate dynamic lib file for each module. This shifts us to making the rust code build a `qiskit._accelerate` module and in that we have submodules for everything we need from compiled code. For this PR there is only one submodule, `stochastic_swap`, so for example the parallel swap_trials routine can be imported from `qiskit._accelerate.stochastic_swap.swap_trials`. In the future we can have additional submodules for other pieces of compiled code in qiskit. For example, the likely next candidate is the pauli expectation value cython module, which we'll likely port to rust and also make parallel (for sufficiently large number of qubits). In that case we'd add a new submodule for that functionality. * Adjust random normal distribution to use correct mean This commit corrects the use of the normal distribution to have the mean set to 1.0. Previously we were doing this out of band for each value by adding 1 to the random value which wasn't necessary because we could just generate it with a mean of 1.0. * Remove unecessary extra scope from locked read This commit removes an unecessary extra scope around the locked read for where we store the best solution. The scope was previously there to release the lock after we check if there is a solution or not. However this wasn't actually needed as we can just do the check inline and the lock will release after the condition block. * Remove unecessary explicit type from opt_edges variable * Fix indices typo in NLayout constructor Co-authored-by: Jake Lishman <jake@binhbar.com> * Remove explicit lifetime annotation from swap_trials Previously the swap_trials() function had an explicit lifetime annotation `'p` which wasn't necessary because the compiler can determine this on it's own. Normally when dealing with numpy views and a Python object (i.e. a GIL handle) we need a lifetime annotation to tell the rust compiler the numpy view and the python gil handle will have the same lifetime. But since swap_trials doesn't take a gil handle and operates purely in rust we don't need this lifetime and the rust compiler can deal with the lifetime of the numpy views on their own. * Use sum() instead of fold() * Fix lint and add rust style and lint checks to CI This commit fixes the python lint failures and also updates the ci configuration for the lint job to also run rust's style and lint enforcement. * Fix returned layout mapping from NLayout This commit fixes the output list from the `layout_mapping()` method of `NLayout`. Previously, it incorrectly would return the wrong indices it should be a list of virtual -> physical to qubit pairs. This commit corrects this error Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com> * Tweak tox configuration to try and reliably build rust extension * Make swap_trials parallelization configurable This commit makes the parallelization of the swap_trials() configurable. This is dones in two ways, first a new argument parallel_threshold is added which takes an optional int which is the number of qubits to switch between a parallel and serial version. The second is that it takes into account the the state of the QISKIT_IN_PARALLEL environment variable. This variable is set to TRUE by parallel_map() when we're running in a multiprocessing context. In those cases also running stochastic swap in parallel will likely just cause too much load as we're potentially oversubscribing work to the number of available CPUs. So, if QISKIT_IN_PARALLEL is set to True we run swap_trials serially. * Revert "Make swap_trials parallelization configurable" This reverts commit 57790c84b03da10fd7296c57b38b54c5bccebf4c. That commit attempted to sovle some issues in test running, mainly around multiple parallel dispatch causing exceess load. But in practice it was broken and caused more issues than it fixed. We'll investigate and add control for the parallelization in a future commit separately after all the tests are passing so we have a good baseline. * Add docs to swap_trials() and remove unecessary num_gates arg * Fix race condition leading to non-deterministic behavior Previously, in the case of circuits that had multiple best possible depth == 1 solutions for a layer, there was a race condition in the fast exit path between the threads which could lead to a non-deterministic result even with a fixed seed. The output was always valid, but which result was dependent on which parallel thread with an ideal solution finished last and wrote to the locked best result last. This was causing weird non-deterministic test failures for some tests because of #1794 as the exact match result would change between runs. This could be a bigger issue because user expectations are that with a fixed seed set on the transpiler that the output circuit will be deterministically reproducible. To address this is issue this commit trades off some performance to ensure we're always returning a deterministic result in this case. This is accomplished by updating/checking if a depth==1 solution has been found in another trial thread we only act (so either exit early or update the already found depth == 1 solution) if that solution already found has a trial number that is less than this thread's trial number. This does limit the effectiveness of the fast exit, but in practice it should hopefully not effect the speed too much. As part of this commit some tests are updated because the new deterministic behavior is slightly different from the previous results from the cython serial implementation. I manually verified that the new output circuits are still valid (it also looks like the quality of the results in some of those cases improved, but this is strictly anecdotal and shouldn't be taken as a general trend with this PR). * Apply suggestions from code review Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com> * Fix compiler errors in previous commit * Revert accidental commit of parallel reduction in compute_cost This was only a for local testing to prove it was a bad idea and was accidently included in the branch. We should not nest the parallel execution like this. * Eliminate short circuit for depth == 1 swap_trial() result This commit eliminates the short circuit fast return in swap_trial() when another trial thread has found an ideal solution. Trying to do this in a parallel context is tricky to make deterministic because in cases of >1 depth == 1 solutions there is an inherent race condition between the threads for writing out their depth == 1 result to the shared location. Different strategies were tried to make this reliably deterministic but there wa still a race condition. Since this was just a performance optimization to avoid doing unnecessary work this commit removes this step. Weighing improved performance against repeatability in the output of the compiler, the reproducible results are more important. After we've adopted a multithreaded stochastic swap we can investigate adding this back as a potential future optimization. * Add missing docstrings * Add section to contributing on installing form source * Make rust python classes pickleable * Add rust compiler install to linux wheel jobs * Try more tox changes to fix docs builds * Revert "Eliminate short circuit for depth == 1 swap_trial() result" This reverts commit c510764a770cb610661bdb3732337cd45ab587fd. The removal there was premature and we had a fix for the non-determinism in place, ignoring a typo which was preventing it from working. Co-Authored-By: Georgios Tsilimigkounakis <45130028+georgios-ts@users.noreply.github.com> * Fix submodule declaration and module attribute on rust classes * Fix rust lint * Fix docs job definition * Disable multiprocessing parallelism in unit tests This commit disables the multiprocessing based parallelism when running unittest jobs in CI. We historically have defaulted the use of multiprocessing in environments only where the "fork" start method is available because this has the best performance and has no caveats around how it is used by users (you don't need an `if __name__ == "__main__"` guard). However, the use of the "fork" method isn't always 100% reliable (see https://bugs.python.org/issue40379), which we saw on Python 3.9 #6188. In unittest CI (and tox) by default we use stestr which spawns (not using fork) parallel workers to run tests in parallel. With this PR this means in unittest we're now running multiple test runner subprocesses, which are executing parallel dispatched code using multiprocessing's fork start method, which is executing multithreaded rust code. This three layers of nesting is fairly reliably hanging as Python's fork doesn't seem to be able to handle this many layers of nested parallelism. There are 2 ways I've been able to fix this, the first is to change the start method used by `parallel_map()` to either "spawn" or "forkserver" either of these does not suffer from random hanging. However, doing this in the unittest context causes significant overhead and slows down test executing significantly. The other is to just disable the multiprocessing which fixes the hanging and doesn't impact runtime performance signifcantly (and might actually help in CI so we're not oversubscribing the limited resources. As I have not been able to reproduce `parallel_map()` hanging in a standalone context with multithreaded stochastic swap this commit opts for just disabling multiprocessing in CI and documenting the known issue in the release notes as this is the simpler solution. It's unlikely that users will nest parallel processes as it typically hurts performance (and parallel_map() actively guards against it), we only did it in testing previously because the tests which relied on it were a small portion of the test suite (roughly 65 tests) and typically did not have a significant impact on the total throughput of the test suite. * Fix typo in azure pipelines config * Remove unecessary extension compilation for image tests * Add test script to explicitly verify parallel dispatch In an earlier commit we disabled the use of parallel dispatch in parallel_map() to avoid a bug in cpython associated with their fork() based subprocess launch. Doing this works around the bug which was reliably triggered by running multiprocessing in parallel subprocesses. It also has the side benefit of providing a ~2x speed up for test suite execution in CI. However, this meant we lost our test coverage in CI for running parallel_map() with actual multiprocessing based parallel dispatch. To ensure we don't inadvertandtly regress this code path moving forward this commit adds a dedicated test script which runs a simple transpilation in parallel and verifies that everything works as expected with the default parallelism settings. * Avoid multi-threading when run in a multiprocessing context This commit adds a switch on running between a single threaded and a multithreaded variant of the swap_trials loop based on whether the QISKIT_IN_PARALLEL flag is set. If QISKIT_IN_PARALLEL is set to TRUE this means the `parallel_map()` function is running in the outer python context and we're running in multiprocessing already. This means we do not want to be running in multiple threads generally as that will lead to potential resource exhaustion by spawn n processes each potentially running with m threads where `n` is `min(num_phys_cpus, num_tasks)` and `m` is num_logical_cpus (although only `min(num_logical_cpus, num_trials)` will be active) which on the typical system there aren't enough cores to leverage both multiprocessing and multithreading. However, in case a user does have such an environment they can set the `QISKIT_FORCE_THREADS` env variable to `TRUE` which will use threading regardless of the status of `QISKIT_IN_PARALLEL`. * Apply suggestions from code review Co-authored-by: Jake Lishman <jake@binhbar.com> * Minor fixes from review comments This commits fixes some minor details found during code review. It expands the section on building from source to explain how to build a release optimized binary with editable mode, makes the QISKIT_PARALLEL env variable usage consistent across all jobs, and adds a missing shebang to the `install_rush.sh` script which is used to install rust in the manylinux container environment. * Simplify tox configuration In earlier commits the tox configuration was changed to try and fix the docs CI job by going to great effort to try and enforce that setuptools-rust was installed in all situations, even before it was actually needed. However, the problem with the docs ci job was unrelated to the tox configuration and this reverts the configuration to something that works with more versions of tox and setuptools-rust. * Add missing pieces of cargo configuration Co-authored-by: Jake Lishman <jake@binhbar.com> Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-03-01 05:49:54 +08:00
from setuptools_rust import Binding, RustExtension
Implement multithreaded stochastic swap in rust (#7658) * Implement multithreaded stochastic swap in rust This commit is a rewrite of the core swap trials functionality in the StochasticSwap transpiler pass. Previously this core routine was written using Cython (see #1789) which had great performance, but that implementation was single threaded. The core of the stochastic swap algorithm by it's nature is well suited to be executed in parallel, it attempts a number of random trials and then picks the best result from all the trials and uses that for that layer. These trials can easily be run in parallel as there is no data dependency between the trials (there are shared inputs but read-only). As the algorithm generally scales exponentially the speed up from running the trials in parallel can offset this and improve the scaling of the pass. Running the pass in parallel was previously tried in #4781 using Python multiprocessing but the overhead of launching an additional process and serializing the input arrays for each trial was significantly larger than the speed gains. To run the algorithm efficiently in parallel multithreading is needed to leverage shared memory on shared inputs. This commit rewrites the cython routine using rust. This was done for two reasons. The first is that rust's safety guarantees make dealing with and writing parallel code much easier and safer. It's also multiplatform because the rust language supports native threading primatives in language. The second is while writing parallel cython code using open-mp there are limitations with it, mainly on windows. In practice it was also difficult to write and maintain parallel cython code as it has very strict requirements on python and c code interactions. It was much faster and easier to port it to rust and the performance for each iteration (outside of parallelism) is the same (in some cases marginally faster) in rust. The implementation here reuses the data structures that the previous cython implementation introduced (mainly flattening all the terra objects into 1d or 2d numpy arrays for efficient access from C). The speedups from this PR can be significant, calling transpile() on a 400 qubit (with a depth of 10) QV model circuit targetting a 409 heavy hex coupling map goes from ~200 seconds with the single threaded cython to ~60 seconds with this PR locally on a 32 core system, When transpiling a 1000 qubit (also with a depth of 10) QV model circuit targetting a 1081 qubit heavy hex coupling map goes from taking ~6500 seconds to ~720 seconds. The tradeoff with this PR is for local qiskit-terra development a rust compiler needs to be installed. This is made trivial using rustup (https://rustup.rs/), but it is an additional burden and one that we might not want to make. If so we can look at turning this PR into a separate repository/package that qiskit-terra can depend on. The tradeoff here is that we'll be adding friction to the api boundary between the pass and the core swap trials interface. But, it does ease the dependency on development for qiskit-terra. * Sanitize packaging to support future modules This commit fixes how we package the compiled rust module in qiskit-terra. As a single rust project only gives us a single compiled binary output we can't use the same scheme we did previously with cython with a separate dynamic lib file for each module. This shifts us to making the rust code build a `qiskit._accelerate` module and in that we have submodules for everything we need from compiled code. For this PR there is only one submodule, `stochastic_swap`, so for example the parallel swap_trials routine can be imported from `qiskit._accelerate.stochastic_swap.swap_trials`. In the future we can have additional submodules for other pieces of compiled code in qiskit. For example, the likely next candidate is the pauli expectation value cython module, which we'll likely port to rust and also make parallel (for sufficiently large number of qubits). In that case we'd add a new submodule for that functionality. * Adjust random normal distribution to use correct mean This commit corrects the use of the normal distribution to have the mean set to 1.0. Previously we were doing this out of band for each value by adding 1 to the random value which wasn't necessary because we could just generate it with a mean of 1.0. * Remove unecessary extra scope from locked read This commit removes an unecessary extra scope around the locked read for where we store the best solution. The scope was previously there to release the lock after we check if there is a solution or not. However this wasn't actually needed as we can just do the check inline and the lock will release after the condition block. * Remove unecessary explicit type from opt_edges variable * Fix indices typo in NLayout constructor Co-authored-by: Jake Lishman <jake@binhbar.com> * Remove explicit lifetime annotation from swap_trials Previously the swap_trials() function had an explicit lifetime annotation `'p` which wasn't necessary because the compiler can determine this on it's own. Normally when dealing with numpy views and a Python object (i.e. a GIL handle) we need a lifetime annotation to tell the rust compiler the numpy view and the python gil handle will have the same lifetime. But since swap_trials doesn't take a gil handle and operates purely in rust we don't need this lifetime and the rust compiler can deal with the lifetime of the numpy views on their own. * Use sum() instead of fold() * Fix lint and add rust style and lint checks to CI This commit fixes the python lint failures and also updates the ci configuration for the lint job to also run rust's style and lint enforcement. * Fix returned layout mapping from NLayout This commit fixes the output list from the `layout_mapping()` method of `NLayout`. Previously, it incorrectly would return the wrong indices it should be a list of virtual -> physical to qubit pairs. This commit corrects this error Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com> * Tweak tox configuration to try and reliably build rust extension * Make swap_trials parallelization configurable This commit makes the parallelization of the swap_trials() configurable. This is dones in two ways, first a new argument parallel_threshold is added which takes an optional int which is the number of qubits to switch between a parallel and serial version. The second is that it takes into account the the state of the QISKIT_IN_PARALLEL environment variable. This variable is set to TRUE by parallel_map() when we're running in a multiprocessing context. In those cases also running stochastic swap in parallel will likely just cause too much load as we're potentially oversubscribing work to the number of available CPUs. So, if QISKIT_IN_PARALLEL is set to True we run swap_trials serially. * Revert "Make swap_trials parallelization configurable" This reverts commit 57790c84b03da10fd7296c57b38b54c5bccebf4c. That commit attempted to sovle some issues in test running, mainly around multiple parallel dispatch causing exceess load. But in practice it was broken and caused more issues than it fixed. We'll investigate and add control for the parallelization in a future commit separately after all the tests are passing so we have a good baseline. * Add docs to swap_trials() and remove unecessary num_gates arg * Fix race condition leading to non-deterministic behavior Previously, in the case of circuits that had multiple best possible depth == 1 solutions for a layer, there was a race condition in the fast exit path between the threads which could lead to a non-deterministic result even with a fixed seed. The output was always valid, but which result was dependent on which parallel thread with an ideal solution finished last and wrote to the locked best result last. This was causing weird non-deterministic test failures for some tests because of #1794 as the exact match result would change between runs. This could be a bigger issue because user expectations are that with a fixed seed set on the transpiler that the output circuit will be deterministically reproducible. To address this is issue this commit trades off some performance to ensure we're always returning a deterministic result in this case. This is accomplished by updating/checking if a depth==1 solution has been found in another trial thread we only act (so either exit early or update the already found depth == 1 solution) if that solution already found has a trial number that is less than this thread's trial number. This does limit the effectiveness of the fast exit, but in practice it should hopefully not effect the speed too much. As part of this commit some tests are updated because the new deterministic behavior is slightly different from the previous results from the cython serial implementation. I manually verified that the new output circuits are still valid (it also looks like the quality of the results in some of those cases improved, but this is strictly anecdotal and shouldn't be taken as a general trend with this PR). * Apply suggestions from code review Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com> * Fix compiler errors in previous commit * Revert accidental commit of parallel reduction in compute_cost This was only a for local testing to prove it was a bad idea and was accidently included in the branch. We should not nest the parallel execution like this. * Eliminate short circuit for depth == 1 swap_trial() result This commit eliminates the short circuit fast return in swap_trial() when another trial thread has found an ideal solution. Trying to do this in a parallel context is tricky to make deterministic because in cases of >1 depth == 1 solutions there is an inherent race condition between the threads for writing out their depth == 1 result to the shared location. Different strategies were tried to make this reliably deterministic but there wa still a race condition. Since this was just a performance optimization to avoid doing unnecessary work this commit removes this step. Weighing improved performance against repeatability in the output of the compiler, the reproducible results are more important. After we've adopted a multithreaded stochastic swap we can investigate adding this back as a potential future optimization. * Add missing docstrings * Add section to contributing on installing form source * Make rust python classes pickleable * Add rust compiler install to linux wheel jobs * Try more tox changes to fix docs builds * Revert "Eliminate short circuit for depth == 1 swap_trial() result" This reverts commit c510764a770cb610661bdb3732337cd45ab587fd. The removal there was premature and we had a fix for the non-determinism in place, ignoring a typo which was preventing it from working. Co-Authored-By: Georgios Tsilimigkounakis <45130028+georgios-ts@users.noreply.github.com> * Fix submodule declaration and module attribute on rust classes * Fix rust lint * Fix docs job definition * Disable multiprocessing parallelism in unit tests This commit disables the multiprocessing based parallelism when running unittest jobs in CI. We historically have defaulted the use of multiprocessing in environments only where the "fork" start method is available because this has the best performance and has no caveats around how it is used by users (you don't need an `if __name__ == "__main__"` guard). However, the use of the "fork" method isn't always 100% reliable (see https://bugs.python.org/issue40379), which we saw on Python 3.9 #6188. In unittest CI (and tox) by default we use stestr which spawns (not using fork) parallel workers to run tests in parallel. With this PR this means in unittest we're now running multiple test runner subprocesses, which are executing parallel dispatched code using multiprocessing's fork start method, which is executing multithreaded rust code. This three layers of nesting is fairly reliably hanging as Python's fork doesn't seem to be able to handle this many layers of nested parallelism. There are 2 ways I've been able to fix this, the first is to change the start method used by `parallel_map()` to either "spawn" or "forkserver" either of these does not suffer from random hanging. However, doing this in the unittest context causes significant overhead and slows down test executing significantly. The other is to just disable the multiprocessing which fixes the hanging and doesn't impact runtime performance signifcantly (and might actually help in CI so we're not oversubscribing the limited resources. As I have not been able to reproduce `parallel_map()` hanging in a standalone context with multithreaded stochastic swap this commit opts for just disabling multiprocessing in CI and documenting the known issue in the release notes as this is the simpler solution. It's unlikely that users will nest parallel processes as it typically hurts performance (and parallel_map() actively guards against it), we only did it in testing previously because the tests which relied on it were a small portion of the test suite (roughly 65 tests) and typically did not have a significant impact on the total throughput of the test suite. * Fix typo in azure pipelines config * Remove unecessary extension compilation for image tests * Add test script to explicitly verify parallel dispatch In an earlier commit we disabled the use of parallel dispatch in parallel_map() to avoid a bug in cpython associated with their fork() based subprocess launch. Doing this works around the bug which was reliably triggered by running multiprocessing in parallel subprocesses. It also has the side benefit of providing a ~2x speed up for test suite execution in CI. However, this meant we lost our test coverage in CI for running parallel_map() with actual multiprocessing based parallel dispatch. To ensure we don't inadvertandtly regress this code path moving forward this commit adds a dedicated test script which runs a simple transpilation in parallel and verifies that everything works as expected with the default parallelism settings. * Avoid multi-threading when run in a multiprocessing context This commit adds a switch on running between a single threaded and a multithreaded variant of the swap_trials loop based on whether the QISKIT_IN_PARALLEL flag is set. If QISKIT_IN_PARALLEL is set to TRUE this means the `parallel_map()` function is running in the outer python context and we're running in multiprocessing already. This means we do not want to be running in multiple threads generally as that will lead to potential resource exhaustion by spawn n processes each potentially running with m threads where `n` is `min(num_phys_cpus, num_tasks)` and `m` is num_logical_cpus (although only `min(num_logical_cpus, num_trials)` will be active) which on the typical system there aren't enough cores to leverage both multiprocessing and multithreading. However, in case a user does have such an environment they can set the `QISKIT_FORCE_THREADS` env variable to `TRUE` which will use threading regardless of the status of `QISKIT_IN_PARALLEL`. * Apply suggestions from code review Co-authored-by: Jake Lishman <jake@binhbar.com> * Minor fixes from review comments This commits fixes some minor details found during code review. It expands the section on building from source to explain how to build a release optimized binary with editable mode, makes the QISKIT_PARALLEL env variable usage consistent across all jobs, and adds a missing shebang to the `install_rush.sh` script which is used to install rust in the manylinux container environment. * Simplify tox configuration In earlier commits the tox configuration was changed to try and fix the docs CI job by going to great effort to try and enforce that setuptools-rust was installed in all situations, even before it was actually needed. However, the problem with the docs ci job was unrelated to the tox configuration and this reverts the configuration to something that works with more versions of tox and setuptools-rust. * Add missing pieces of cargo configuration Co-authored-by: Jake Lishman <jake@binhbar.com> Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-03-01 05:49:54 +08:00
with open("requirements.txt") as f:
REQUIREMENTS = f.read().splitlines()
# Read long description from README.
README_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), "README.md")
with open(README_PATH) as readme_file:
README = re.sub(
"<!--- long-description-skip-begin -->.*<!--- long-description-skip-end -->",
"",
readme_file.read(),
flags=re.S | re.M,
)
qasm3_import_extras = [
"qiskit-qasm3-import>=0.1.0",
]
visualization_extras = [
"matplotlib>=3.3",
"ipywidgets>=7.3.0",
"pydot",
"pillow>=4.2.1",
"pylatexenc>=1.4",
"seaborn>=0.9.0",
"pygments>=2.4",
]
z3_requirements = [
"z3-solver>=4.7",
]
Prepare 0.18.0 release (#6652) * Prepare 0.18.0 release To prepare for the upcoming 0.18.0 release this commit moves all the release notes into a 0.18 subdirectory to keep them separate from future development notes post-release. It also adds a release note with the prelude section providing the high level overview of the release. When this merges it should be the commit used to tag the 0.18.0 release. * Move new release note * Start rewriting release notes * More updates * Fix RZXCalibrationBuilderNoEcho docs * Fix formatting issue * Update more release notes * Finish first pass of feature release notes * Apply suggestions from code review Co-authored-by: Julien Gacon <gaconju@gmail.com> * Finish first pass of upgrade and deprecation notes * Start rewriting fix notes * Remove accidentally committed file * Update releasenotes/notes/0.18/prepare-0.18-9a0fb87005e314fd.yaml Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Remove 0.17.x stable release notes * More fix note rewrites * Move new release notes * Move new release notes * Add bip mapper extras to all extra * Finish first pass of release notes * Revert changes to tox.ini * Move and rewrite new release notes * Fix typos * Fix another typo * Remove new fix note as it only was an issue on unreleased code * Apply suggestions from code review Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Expand prelude * Fix alignment release note example * Remove double requirement on tweedledum in ci * Move and update new release notes * Move new release notes * Fix lint * Move and update new release notes * Apply suggestions from code review Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * Move and update new release notes * Apply suggestions from code review Co-authored-by: Kevin Krsulich <kevin@krsulich.net> * Update releasenotes/notes/0.18/TensoredMeasFitter-d327f0e2d736efdd.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Apply suggestions from code review Co-authored-by: Kevin Krsulich <kevin@krsulich.net> * Update alignment release note * Remove release note that shouldn't be advertised yet * Fix alignment pass release note * Move and update the last release note * Apply suggestions from code review Co-authored-by: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> Co-authored-by: Luciano Bello <bel@zurich.ibm.com> Co-authored-by: Kevin Krsulich <kevin@krsulich.net>
2021-07-13 03:22:26 +08:00
bip_requirements = ["cplex", "docplex"]
csp_requirements = ["python-constraint>=1.4"]
toqm_requirements = ["qiskit-toqm>=0.1.0"]
Prepare 0.18.0 release (#6652) * Prepare 0.18.0 release To prepare for the upcoming 0.18.0 release this commit moves all the release notes into a 0.18 subdirectory to keep them separate from future development notes post-release. It also adds a release note with the prelude section providing the high level overview of the release. When this merges it should be the commit used to tag the 0.18.0 release. * Move new release note * Start rewriting release notes * More updates * Fix RZXCalibrationBuilderNoEcho docs * Fix formatting issue * Update more release notes * Finish first pass of feature release notes * Apply suggestions from code review Co-authored-by: Julien Gacon <gaconju@gmail.com> * Finish first pass of upgrade and deprecation notes * Start rewriting fix notes * Remove accidentally committed file * Update releasenotes/notes/0.18/prepare-0.18-9a0fb87005e314fd.yaml Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Remove 0.17.x stable release notes * More fix note rewrites * Move new release notes * Move new release notes * Add bip mapper extras to all extra * Finish first pass of release notes * Revert changes to tox.ini * Move and rewrite new release notes * Fix typos * Fix another typo * Remove new fix note as it only was an issue on unreleased code * Apply suggestions from code review Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Expand prelude * Fix alignment release note example * Remove double requirement on tweedledum in ci * Move and update new release notes * Move new release notes * Fix lint * Move and update new release notes * Apply suggestions from code review Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * Move and update new release notes * Apply suggestions from code review Co-authored-by: Kevin Krsulich <kevin@krsulich.net> * Update releasenotes/notes/0.18/TensoredMeasFitter-d327f0e2d736efdd.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Apply suggestions from code review Co-authored-by: Kevin Krsulich <kevin@krsulich.net> * Update alignment release note * Remove release note that shouldn't be advertised yet * Fix alignment pass release note * Move and update the last release note * Apply suggestions from code review Co-authored-by: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> Co-authored-by: Luciano Bello <bel@zurich.ibm.com> Co-authored-by: Kevin Krsulich <kevin@krsulich.net>
2021-07-13 03:22:26 +08:00
setup(
name="qiskit-terra",
version="0.24.0",
description="Software for developing quantum computing programs",
long_description=README,
long_description_content_type="text/markdown",
url="https://github.com/Qiskit/qiskit-terra",
author="Qiskit Development Team",
2020-09-16 03:52:41 +08:00
author_email="hello@qiskit.org",
license="Apache 2.0",
classifiers=[
"Environment :: Console",
"License :: OSI Approved :: Apache Software License",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
Add python 3.8 support and deprecate python 3.5 (#3268) * Add python 3.8 support and deprecate python 3.5 This commit adds support for running terra under python 3.8. It does this by adding the trove classifiers to the package metadata and adding a test job for python 3.8 (only travis for now this can be expanded in the future when azure pipelines adds it to their image). At the same time this commit starts the deprecation window for python 3.5. Python 3.5 goes end of life by upstream python in Sept. 2020. We should give our users running with python 3.5 (which is about 10% of our users based on pypi data) fair notice that when upstream python stops supporting it we do as well. * Fix lint * Add back empty cache detection As part of the refactors the empty stestr timing cache removal code was removed from the travis config, but the cache wasn't removed. Adding the python 3.8 job causes a failure because travis has no cached timing data but still creates the empty directory which triggers mtreinish/stestr#266. This adds back the empty cache removal to workaround it so we can use the timing data for scheduling in future runs. * Add azure-pipelines python 3.8 jobs too * Fix python 3.8 dictionary keys changed error Starting in python 3.8 a new RuntimeError is raised, RuntimeError: dictionary keys changed during iteration. This is caused by modifying an iterator while looping over it. We were doing that in the optimize_swap_before_measure pass. This commit fixes this by wrapping the iterator in list() to make a copy of it for looping. This way we don't modify the contents of what we're iterating over in the pass. * Revert "Add azure-pipelines python 3.8 jobs too" The missing matplotlib wheels are blockers for windows and osx environment. Since we do not have the necessary dependencies installed in those ci envs to compile matplotlib from source. We'll rely on just travis for 3.8 testing until the matplotlib 3.2.0 release is pushed so we don't have to compile it. This reverts commit 40157621b135a03b291b93e5d9b801237a14c015. * Add skip for failing matplotlib test The image comparison tests which are quite flaky are failing with matplotlib compiled on 3.8. Looking at the image output from these failures are very subtle (looks like resolution differences) again questioning the value of these tests. This commit just skips the test that is failing here to unblock the PR. * Add azure 3.8 test jobs * Pin to pre-release mpl for python 3.8 * Add spawn guard for python3.8 osx in examples When running examples with execute, transpile, or any other calls using parallel_map() the new default for spawn instead of fork requires that scripts have a __name__ == "__main__" check in them to function properly. If not calls to parallel_map fail errors around the bootstrapping phase. To avoid this in the ci jobs this commit adds the necessary checks to the example scripts we run in ci as part of test_examples. * Remove cryptography pin from constraints file We pinned the cryptography package version back during the cryptography 2.6 release which broke our ci. It was a temporary step to avoid a packaging issue in CI that was blocking development. However, when the issue was resolved we never circled back to fix the issue. Now trying to enable python 3.8 support to terra cryptography >=2.8 is needed for python 3.8 on windows (to get a precompiled binary). This commit removes the unecessary pin to unblock windows 3.8 ci. * Bump cibuildwheel version to build 3.8 wheels cibuildwheel 1.0.0 was released in early November [1] and added support for building python 3.8 wheels. This commit bumps the cibuildwheel version we use in the wheel build jobs at release time to also build 3.8 wheels for upload to pypi. * Add skip and release note about macos py38 issues This commit adds a skip for the failing python 3.8 test on osx and windows so that we don't block everything over a small issue in the tests. It also add a release note documenting the limitation with python 3.8 on macos with regardess to parallel_map/multiprocessing. Since this limitation is new for this release (being the first release with python 3.8 support) we should document it as a known issue in the release notes, especially since it likely won't be resolved until a python 3.8.1 release. * Revert "Add spawn guard for python3.8 osx in examples" While we can fix the tests to work on osx python3.8 by adjusting the example scripts to only call functions using parallel_map from inside a block run via if __name__ == '__main__': this unecessarily changes the scripts for the quirks of a single environment. This commit reverts the example scripts back to their original form and instead just skips the unittest that executes them on python 3.8 macOS. We already have documented this limitation in the release notes. When/if we have an alternative solution for how we launch additional processes in python 3.8 on macOS that does not require this workaround we can look at removing the skip. This reverts commit 76ae197631247f5b18eb322b1482da9b31d5391b. * Apply suggestions from code review Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>
2019-12-11 04:43:58 +08:00
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
Add python 3.8 support and deprecate python 3.5 (#3268) * Add python 3.8 support and deprecate python 3.5 This commit adds support for running terra under python 3.8. It does this by adding the trove classifiers to the package metadata and adding a test job for python 3.8 (only travis for now this can be expanded in the future when azure pipelines adds it to their image). At the same time this commit starts the deprecation window for python 3.5. Python 3.5 goes end of life by upstream python in Sept. 2020. We should give our users running with python 3.5 (which is about 10% of our users based on pypi data) fair notice that when upstream python stops supporting it we do as well. * Fix lint * Add back empty cache detection As part of the refactors the empty stestr timing cache removal code was removed from the travis config, but the cache wasn't removed. Adding the python 3.8 job causes a failure because travis has no cached timing data but still creates the empty directory which triggers mtreinish/stestr#266. This adds back the empty cache removal to workaround it so we can use the timing data for scheduling in future runs. * Add azure-pipelines python 3.8 jobs too * Fix python 3.8 dictionary keys changed error Starting in python 3.8 a new RuntimeError is raised, RuntimeError: dictionary keys changed during iteration. This is caused by modifying an iterator while looping over it. We were doing that in the optimize_swap_before_measure pass. This commit fixes this by wrapping the iterator in list() to make a copy of it for looping. This way we don't modify the contents of what we're iterating over in the pass. * Revert "Add azure-pipelines python 3.8 jobs too" The missing matplotlib wheels are blockers for windows and osx environment. Since we do not have the necessary dependencies installed in those ci envs to compile matplotlib from source. We'll rely on just travis for 3.8 testing until the matplotlib 3.2.0 release is pushed so we don't have to compile it. This reverts commit 40157621b135a03b291b93e5d9b801237a14c015. * Add skip for failing matplotlib test The image comparison tests which are quite flaky are failing with matplotlib compiled on 3.8. Looking at the image output from these failures are very subtle (looks like resolution differences) again questioning the value of these tests. This commit just skips the test that is failing here to unblock the PR. * Add azure 3.8 test jobs * Pin to pre-release mpl for python 3.8 * Add spawn guard for python3.8 osx in examples When running examples with execute, transpile, or any other calls using parallel_map() the new default for spawn instead of fork requires that scripts have a __name__ == "__main__" check in them to function properly. If not calls to parallel_map fail errors around the bootstrapping phase. To avoid this in the ci jobs this commit adds the necessary checks to the example scripts we run in ci as part of test_examples. * Remove cryptography pin from constraints file We pinned the cryptography package version back during the cryptography 2.6 release which broke our ci. It was a temporary step to avoid a packaging issue in CI that was blocking development. However, when the issue was resolved we never circled back to fix the issue. Now trying to enable python 3.8 support to terra cryptography >=2.8 is needed for python 3.8 on windows (to get a precompiled binary). This commit removes the unecessary pin to unblock windows 3.8 ci. * Bump cibuildwheel version to build 3.8 wheels cibuildwheel 1.0.0 was released in early November [1] and added support for building python 3.8 wheels. This commit bumps the cibuildwheel version we use in the wheel build jobs at release time to also build 3.8 wheels for upload to pypi. * Add skip and release note about macos py38 issues This commit adds a skip for the failing python 3.8 test on osx and windows so that we don't block everything over a small issue in the tests. It also add a release note documenting the limitation with python 3.8 on macos with regardess to parallel_map/multiprocessing. Since this limitation is new for this release (being the first release with python 3.8 support) we should document it as a known issue in the release notes, especially since it likely won't be resolved until a python 3.8.1 release. * Revert "Add spawn guard for python3.8 osx in examples" While we can fix the tests to work on osx python3.8 by adjusting the example scripts to only call functions using parallel_map from inside a block run via if __name__ == '__main__': this unecessarily changes the scripts for the quirks of a single environment. This commit reverts the example scripts back to their original form and instead just skips the unittest that executes them on python 3.8 macOS. We already have documented this limitation in the release notes. When/if we have an alternative solution for how we launch additional processes in python 3.8 on macOS that does not require this workaround we can look at removing the skip. This reverts commit 76ae197631247f5b18eb322b1482da9b31d5391b. * Apply suggestions from code review Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>
2019-12-11 04:43:58 +08:00
"Programming Language :: Python :: 3.8",
Add support for Python 3.9 (#5189) * Add support for Python 3.9 Python 3.9.0 was released on 10-05-2020, this commits marks the support of Python 3.9 in qiskit-terra. It adds the supported python version in the package metadata and updates the CI configuration to run test jobs on Python 3.9 and build python 3.9 wheels. * Also deprecate 3.6 * Use latest nodes for CI * Remove Python 3.6 deprecation The Python 3.6 deprecation is being handled separately in #5301 to decouple it from adding python 3.9 support. This commit removes the 3.6 deprecation accordingly. * Bump cibuildwheel version to the latest release * Remove unused assertNoLogs method The assertNoLogs methods was built using a private class from python's stdlib unittest library. This should never have been done as it's explicitly marked as private. Accordingly in Python 3.9 this private class has been removed and no longer exists. It turns out this method was not used anywhere in all of qiskit (not just terra). Since the implementation is not sound and nothing uses it this commit just removes the class and method. * Fix lint * Remove aer from macOS and windows jobs * Remove IBMQ provider from ci jobs The ibmq provider is not used by anything in CI anymore. It was an historical artifact when some of the visualization and jupyter tests required it. This is no longer true. However, installing the ibmq provider in the linux 3.9 job is blocking CI because of an unrelated requests library issue with urllib3. To resolve this, this commit just removes the unecessary install. * Add back ibmqprovider to tutorials job, it's needed for aqua tutorials * Fix jupyter test skip * Update test/python/tools/jupyter/test_notebooks.py Co-authored-by: Christian Clauss <cclauss@me.com> * Fix lint * Add back pbars macOS test skip Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-12-02 12:51:32 +08:00
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Add support for Python 3.11 (#9028) * Add support for Python 3.11 Python 3.11.0 was released on 10-24-2022, this commit marks the start of support for Python 3.11 in qiskit. It adds the supported Python version in the package metadata and updates the CI configuration to run test jobs on Python 3.11 and build Python 3.11 wheels on release. * Fix inspect.Parameter usage for API change in 3.11 Per the Python 3.11.0 release notes inspect.Parameter now raises a ValueError if the name argument is a Python identifier. This was causing a test failure in one case where a parameter named `lambda` was used. This commit adjusts the parameter name in the tests to be lam to avoid this issue. * Set a version cap on the jax dev requirement Currently jax doesn't publish Python 3.11 wheels which is blocking test runs with python 3.11. Since jax is an optional package only used for the gradient package we can just skip it as isn't a full blocker for using python 3.11. This commit sets an environment marker on the jax dev requirements to only try to install it on Python < 3.11. * Set python version cap on cplex in CI * DNM: Test wheel builds work * Skip tests on i686/win32 wheel buids with python 3.11 * Revert "DNM: Test wheel builds work" This reverts commit 725c21b46527a04488f4b047e5c2641b41432dc0. * Run QPY backwards compat tests on trailing edge Python version This commit moves the qpy backwards compatibility testing from the leading edge python version, which in this PR branch is Python 3.11, to the trailing edge Python version which is currently 3.7. Trying to add support for a new Python version has demonstrated that we can't use the leading edge version as historical versions of Qiskit used to generate old QPY payloads are not going to be generally installable with newer Python versions. So by using the trailing edge version instead we can install all the older versions of Qiskit as there is Python compatibility for those Qiskit versions. Eventually we will need to raise the minimum Qiskit version we use in the QPY tests, when Python 3.9 goes EoL in October 2025 and Qiskit Terra 0.18.0 no longer has any supported versions of Python it was released for. We probably could get by another year until Python 3.10 goes EoL in 2026 it just means we're building 0.18.x and 0.19.x from source for the testing, but when Python 3.11 becomes our oldest supported version we'll likely have to bump the minimum version. This does go a bit counter to the intent of the test matrix to make the first stage return fast and do a more through check in the second stage. But, in this case the extra runtime is worth the longer term stability in the tests. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-11-04 00:58:14 +08:00
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering",
],
keywords="qiskit sdk quantum",
packages=find_packages(exclude=["test*"]),
install_requires=REQUIREMENTS,
include_package_data=True,
python_requires=">=3.7",
extras_require={
"qasm3-import": qasm3_import_extras,
"visualization": visualization_extras,
Prepare 0.18.0 release (#6652) * Prepare 0.18.0 release To prepare for the upcoming 0.18.0 release this commit moves all the release notes into a 0.18 subdirectory to keep them separate from future development notes post-release. It also adds a release note with the prelude section providing the high level overview of the release. When this merges it should be the commit used to tag the 0.18.0 release. * Move new release note * Start rewriting release notes * More updates * Fix RZXCalibrationBuilderNoEcho docs * Fix formatting issue * Update more release notes * Finish first pass of feature release notes * Apply suggestions from code review Co-authored-by: Julien Gacon <gaconju@gmail.com> * Finish first pass of upgrade and deprecation notes * Start rewriting fix notes * Remove accidentally committed file * Update releasenotes/notes/0.18/prepare-0.18-9a0fb87005e314fd.yaml Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Remove 0.17.x stable release notes * More fix note rewrites * Move new release notes * Move new release notes * Add bip mapper extras to all extra * Finish first pass of release notes * Revert changes to tox.ini * Move and rewrite new release notes * Fix typos * Fix another typo * Remove new fix note as it only was an issue on unreleased code * Apply suggestions from code review Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Expand prelude * Fix alignment release note example * Remove double requirement on tweedledum in ci * Move and update new release notes * Move new release notes * Fix lint * Move and update new release notes * Apply suggestions from code review Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * Move and update new release notes * Apply suggestions from code review Co-authored-by: Kevin Krsulich <kevin@krsulich.net> * Update releasenotes/notes/0.18/TensoredMeasFitter-d327f0e2d736efdd.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Apply suggestions from code review Co-authored-by: Kevin Krsulich <kevin@krsulich.net> * Update alignment release note * Remove release note that shouldn't be advertised yet * Fix alignment pass release note * Move and update the last release note * Apply suggestions from code review Co-authored-by: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> Co-authored-by: Luciano Bello <bel@zurich.ibm.com> Co-authored-by: Kevin Krsulich <kevin@krsulich.net>
2021-07-13 03:22:26 +08:00
"bip-mapper": bip_requirements,
"crosstalk-pass": z3_requirements,
"csp-layout-pass": csp_requirements,
"toqm": toqm_requirements,
# Note: 'all' only includes extras that are stable and work on the majority of Python
# versions and OSes supported by Terra. You have to ask for anything else explicitly.
"all": visualization_extras + z3_requirements + csp_requirements + qasm3_import_extras,
},
project_urls={
"Bug Tracker": "https://github.com/Qiskit/qiskit-terra/issues",
"Documentation": "https://qiskit.org/documentation/",
"Source Code": "https://github.com/Qiskit/qiskit-terra",
},
rust_extensions=[
RustExtension(
"qiskit._accelerate",
"crates/accelerate/Cargo.toml",
binding=Binding.PyO3,
# If RUST_DEBUG is set, force compiling in debug mode. Else, use the default behavior
# of whether it's an editable installation.
debug=True if os.getenv("RUST_DEBUG") == "1" else None,
)
],
zip_safe=False,
Add unitary synthesis plugin interface (#6124) * Add unitary synthesis plugin interface This commit adds the initial steps for a unitary synthesis plugin interface. It enables external packages to ship plugin packages that then integrate cleanly into qiskit's transpiler without any need for extra imports or qiskit changes. The user can then just specify the 'unitary_synthesis_method' kwarg on the transpile() call and use the name of the external plugin and the UnitarySynthesis pass will leverage that plugin for synthesizing the unitary. * Also add qubits in payload with coupling map * Fix lint * Fix logic * Add documentation about the plugin interface * Export get_unitary_synthesis_plugin_names from qiskit.transpiler.passes * Fix lint * Tweak doc organization slightly * Use UnitarySynthesis for unroll3q step The usefulness of the plugin for unitaries >2q in the default pass manager pipelines was limited by the fact that previously the pass managers were all setup to run unroll3q before the unitary synthesis pass is ever run. The unroll3q pass just calls the circuit.data to decompose gates >=3q which for unitary gate objects just calls an inlined equivalent of the 'default' plugin. The purpose of this is to ensure later passes only ever need to deal with 2q gates. However with plugins now if a plugin only works on > 2q we'll never actually be passing an >= 3q unitaries to the plugin in the default pipelines. To fix this issue, this commit calls unitary synthesis before unroll 3q to use the synthesis pass to unroll any unitary gates instead of relying on the gate class's internal decomposition method which will always use the qiskit decomposition techniques. * Run black * Tweak doc organization slightly * Fix lint * Fix pylint errors * Apply suggestions from code review Co-authored-by: Jake Lishman <jake@binhbar.com> * Update plugin interface docs * Review comment updates on UnitarySynthesis pass * Fix typos * Include release notes * Fix docstring typo * Update qiskit/transpiler/passes/synthesis/unitary_synthesis.py Co-authored-by: Kevin Krsulich <kevin@krsulich.net> * Ignore deprecation warnings from importlib metadata Since the importlib metadata 4.8.0 release in late August 2021, stevedore <= 4.8.0 has raised a deprecation warning around using tuple based access (which was deprecated in 4.8.1 after 4.8.0 removed it and broke everything using stevedore). While this has been fixed on the master branch of stevedore (see: https://opendev.org/openstack/stevedore/commit/11da137e3fc34861be8ac3e664ee60a22e66b44c ) Until that fix is released this commit adds a deprecation warning ignore because there isn't anything we can do about the warning in qiskit. Once stevedore has a release that includes this fix we can remove the ignore from the tests. * Pin importlib-metadata The previous commit tried to fix the failures in CI around the deprecation warnings but while I'm unable to reproduce those locally with the warning ignore in place it still fails in CI. I expect there is a similar incompatibility around the 4 frequent importlib-metadata releases >=4.7.0 (2 of which were yanked) causing issues in the CI environment. Since things were working fine for the several months this PR was open prior to 4.7.0 this commit just pins the version in the constraints file to fix CI. * Add length units to docstring * Add min and max qubit abstract properties This commit adds 2 new required properties to the plugin class interface for min and max qubits. These enable a plugin author to specify the number of qubits the plugin supports and if the unitary to be synthesized is outside that range it will just fallback to using the ``default`` plugin. * Add option to automatically find basis for a run() call * Fix typo * Update gate errors docstring * Remove approximation degree from plugin interface * Fix docstring typos Co-authored-by: Eric Peterson <peterson.eric.c@gmail.com> * Apply suggestions from code review Co-authored-by: Jake Lishman <jake@binhbar.com> * Update qiskit/transpiler/passes/synthesis/unitary_synthesis.py Co-authored-by: Jake Lishman <jake@binhbar.com> * Update docstrings and naming and default to 'default' plugin in kwarg This commit updates several aspects of the documentation to make it more clear how to use the plugin interface. It also updates the naming of supported_basis to be supported_bases as it's actually plural. The last change in this commit is making the default kwarg value for the unitary synthesis method default to 'default' (for the default built-in method) instead of None. This simplifies the logic in the unitary synthesis pass. * Make coupling_map run() kwarg a tuple * Add comment on why we don't use a shared global instance * Fix straggler basis->bases typos * Apply suggestions from code review Co-authored-by: Jake Lishman <jake@binhbar.com> * Document supported_bases handling of no matching basis Co-authored-by: Jake Lishman <jake@binhbar.com> Co-authored-by: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: Jake Lishman <jake.lishman@ibm.com> Co-authored-by: Eric Peterson <peterson.eric.c@gmail.com>
2021-10-01 03:09:24 +08:00
entry_points={
"qiskit.unitary_synthesis": [
"default = qiskit.transpiler.passes.synthesis.unitary_synthesis:DefaultUnitarySynthesis",
Approximate Quantum Compiler (#6727) * initial version * linting * linting * linting and black * linting * linting * linting * linting * linting * linting * linting * linting * linting * linting * linting * linting * linting * linting * linting * linting * hello * linting * remove debugging * changed variable names, defined d, and moved -1j/2 multiply to the end * linting * linting * checking * changed variable names * corrected typo * corrected typo * commented * typo * typo * check * typo * linting * changed variable names and commented * linting * changed variable names and commented * cleaning mvp * cleaning mvp * cleaning mvp * added plugin * code review * fix types in cnot_structures.py * more on documentation * Update qiskit/transpiler/synthesis/aqc/approximate.py * Update qiskit/transpiler/synthesis/aqc/cnot_unit_objective.py Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * Update test/python/transpiler/aqc/sample_data.py Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * code review * fix cache * updated plugin, more on documentation * restructured documentation * default configuration, aqc plugin setup * added reno * Update setup.py Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * added a test where AQC is invoked via the plugin discovery interface * added a test where AQC is invoked via pass manager * update scipy in requirements.txt * Update qiskit/transpiler/synthesis/aqc/aqc.py Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * added tests for cnot networks * added support for plugin configuration Co-authored-by: Liam Madden <liam.madden2@ibm.com> Co-authored-by: Luciano Bello <bel@zurich.ibm.com> Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2021-11-23 22:47:56 +08:00
"aqc = qiskit.transpiler.synthesis.aqc.aqc_plugin:AQCSynthesisPlugin",
Add the Solovay-Kitaev algorithm to the transpiler passes (#5657) * add sk pass * add utils * add sk skeleton * add example test file * Add implementations initial version * make the test run * fix lint * fix phase, add test * fix the phase calculation * add accuracy test * cleanup of unused methods, append more efficient * Add unittests for Solovay Kitaev Utils * Add unitttests for commutator_decompose * Remove unittests for non-public functions * Fix pylint issues * refactor simplify * fix the test imports * improve and add docstrings * fix lint in testfile * fix lint in utils * fix lint in sk * Add unittests * fix phase, lint and allow basis gates as strings * rm print * fix adjoint and dot * Fix unittests and add docstring to them * move to circuit to GateSequence * Fix assertion * allow caching the basic approxs * Fix bug in append from GateSequence * Remove unnecesssary code * Fix bug in test setup * Add unittests for multiqubit QFT-circuit * Add unittests for QFT with more qubits * make compatible with current tests * Remove unnecessary testcases * Remove unnecessary unittests * Fix bug in unittests * Add release notes * import scipy; scipy.optimize.fsolve() does not work scipy.optimize has to be imported, since it is not imported when scipy is imported * numpy * Update qiskit/transpiler/passes/synthesis/solovay_kitaev_utils.py Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * document ValueError * rm unused methods, add GateSequence tests * fix lint * try fixing lint and docs * cleanup * improve readability of math * move commutator_decompose into utils * rm tests that are never run * rm trailing todos and commented code * add default dataset, cleanup tests * rm unused imports * replace diamond norm by trace distance * rm unused imports * fix deprecated use of DAGNode.type * black * really black! * fail nicely * test * attempt to fix default approx path * Move decompositions into py file dict * speed up the basic approx generation * add candidate checking by string further reduces the runtime by a factor of about 1.8! * use a tree for basic approx generation Co-authored-by: Jake Lishman <jake.lishman@ibm.com> * fix tests * more speedups! * use kdtree! * refactor: generation as sep. function * remove this masssssive file! * start plugin work * first attempt at synthesis plugin * plugin itself works -- but not when called via transpile or the UnitarySynthesis * unitary synth works! * use class-level method for SolovayKitaev * docstrings * add tests which cover still missing feature * rename to SKSynth and better reno * re-organize files - algorithm to qiskit.synthesis - plugin to qiskit.transpiler.passes.synthesis * cover sklearn-free case * missing future import * move sk pass to transpiler subdirectory * reno & try fixing slow optional module-level imports * attempt 2 to fix sklearn import * comments from Matthew's review * directly construct dag * (previous commit incomplete: missed this here) * add SK to plugin toctree * try fixing sphinx * Apply Jake's comments Removed the SK plugin from the plugin.py docs for now * Fix doc example * Update docs * Fix tests * Fix docs error Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Luciano Bello <bel@zurich.ibm.com> Co-authored-by: Jake Lishman <jake.lishman@ibm.com> Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2022-12-10 06:04:59 +08:00
"sk = qiskit.transpiler.passes.synthesis.solovay_kitaev_synthesis:SolovayKitaevSynthesis",
Add stage plugin interface for transpile (#8305) * Add stage plugin interface for transpile This commit adds a new plugin interface to qiskit for enabling external packages to write plugins that will replace a stage in the transpilation pipeline. For example, if an external package had a custom layout pass that they wanted to integrate into transpile() they could export a plugin using this new interface and then users would just need to run transpile(.., layout_method=foo) This adds long asked for extensibility to the transpiler so that to cleanly integrate new transpiler passes we're no longer required to merge the features into terra. This should hopefully make it easier for downstream pass authors to integrate their passes into terra and make it easier for the terra maintainers to evaluate new transpiler passes. * Fix docs builds * Fix doc warning * Make routing methods all plugins This commit converts all the built-in routing method options into separate plugins and also adds a default plugin for the default behavior at each optimization level. To support using plugins for routing method adding the optimization_level to the passmanager config was necessary so that the plugin has sufficient context on how to construct the routing pass used for the routing stage. As depending on the optimization level the settings for each pass differs. For example on stochastic swap the number of stochastic trials increases for level 3 to try and find a better solution at the cost of more runtime. * Add plugin usage to level 3 * Add plugin support to level 0 preset pass manager * Add default plugin to reserved routing methods list * Add release notes * Add tests * Apply suggestions from code review Co-authored-by: Alexander Ivrii <alexi@il.ibm.com> * Apply suggestions from code review Co-authored-by: Alexander Ivrii <alexi@il.ibm.com> * Remove raise on non-builtin layout method argument * Fix typo * Deduplicate code in built-in routing plugins This commit deduplicates the code in the built-in routing stage plugins. First it removes the default plugin which was duplicated with the stochastic and sabre plugins. There was no functional difference between just setting the implicit default method name and using a per method plugin and having a standalone default plugin. Secondly all the vf2 call limit code is abstracted into a helper function which reduces code duplication. * Make vf2 call limit function private * Deduplicate code in stochastic swap plugin * Expand example plugin documentation to show more complete use case * Update qiskit/transpiler/preset_passmanagers/level1.py Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * Add missing TODO comment * Unify vf2 call limit handling * Remove default plugin from entry points * Simplify level 3 optimization stage logic * Update qiskit/transpiler/preset_passmanagers/plugin.py Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * Prefer toqm plugin if one is available The qiskit-toqm project will be one of the first users of this plugin interface. Once this is released in qiskit, qiskit-toqm will likely publish their own plugin soon after and if they do we want that plugin to be used instead of the hardcoded stage in terra. This commit updates the logic for toqm handling to only use the built-in toqm if a version of qiskit-toqm is installed without a plugin present. * Apply suggestions from code review Co-authored-by: Kevin Hartman <kevin@hart.mn> Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com> * Fix lint * Remove unnecessary elses in builtin plugins * Apply suggestions from code review Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * Make optimization level a plugin argument * Add test coverage for all built-in routing plugins * Reorder stage variables to execution order Co-authored-by: Alexander Ivrii <alexi@il.ibm.com> Co-authored-by: Luciano Bello <bel@zurich.ibm.com> Co-authored-by: Kevin Hartman <kevin@hart.mn> Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-08-31 02:16:51 +08:00
],
Implementing pluggable HighLevelSynthesis (#8548) * Initial implementation of pluggable HighLevelSynthesis * typo * black * fix merge error * Reorganizing entry points for high-level-synthesis plugins based on the comments * fixing some typos * HLSConfig now accepts a list of methods for each operation; also allowing to specify these lists in config's __init__ * running black * removing hls_config from __str__ in PassManagerConfig * Adding abc interface for high-level-synthesis plugins * improving docs and comments * fix * adding tests; removing print statements * removing external test file * remove redundant print * Passing HLSConfig in all transpiler optimization levels * Fix for is_parameterized as Operations don't have to support this * Replacing node.op.copy by copy.deepcopy(node.op) to avoid Operations implementing copy method * release notes * adding a link to HLSConfig class * Temporarily removing high-level-synthesis from optimization loop * Adding example from release notes to HighLevelSynthesis documentation * fixing random typo * adding references to documentation: * Further trying to improve documentation following the review comments * removing usused import * minor docs changes * Docs consolidation following review comments * added test * fixing title underline in docs * minor output tweaks * Update setup.py Co-authored-by: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-10-01 04:08:21 +08:00
"qiskit.synthesis": [
"clifford.default = qiskit.transpiler.passes.synthesis.high_level_synthesis:DefaultSynthesisClifford",
"clifford.ag = qiskit.transpiler.passes.synthesis.high_level_synthesis:AGSynthesisClifford",
"clifford.bm = qiskit.transpiler.passes.synthesis.high_level_synthesis:BMSynthesisClifford",
"clifford.greedy = qiskit.transpiler.passes.synthesis.high_level_synthesis:GreedySynthesisClifford",
"clifford.layers = qiskit.transpiler.passes.synthesis.high_level_synthesis:LayerSynthesisClifford",
"clifford.lnn = qiskit.transpiler.passes.synthesis.high_level_synthesis:LayerLnnSynthesisClifford",
Implementing pluggable HighLevelSynthesis (#8548) * Initial implementation of pluggable HighLevelSynthesis * typo * black * fix merge error * Reorganizing entry points for high-level-synthesis plugins based on the comments * fixing some typos * HLSConfig now accepts a list of methods for each operation; also allowing to specify these lists in config's __init__ * running black * removing hls_config from __str__ in PassManagerConfig * Adding abc interface for high-level-synthesis plugins * improving docs and comments * fix * adding tests; removing print statements * removing external test file * remove redundant print * Passing HLSConfig in all transpiler optimization levels * Fix for is_parameterized as Operations don't have to support this * Replacing node.op.copy by copy.deepcopy(node.op) to avoid Operations implementing copy method * release notes * adding a link to HLSConfig class * Temporarily removing high-level-synthesis from optimization loop * Adding example from release notes to HighLevelSynthesis documentation * fixing random typo * adding references to documentation: * Further trying to improve documentation following the review comments * removing usused import * minor docs changes * Docs consolidation following review comments * added test * fixing title underline in docs * minor output tweaks * Update setup.py Co-authored-by: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-10-01 04:08:21 +08:00
"linear_function.default = qiskit.transpiler.passes.synthesis.high_level_synthesis:DefaultSynthesisLinearFunction",
"linear_function.kms = qiskit.transpiler.passes.synthesis.high_level_synthesis:KMSSynthesisLinearFunction",
"linear_function.pmh = qiskit.transpiler.passes.synthesis.high_level_synthesis:PMHSynthesisLinearFunction",
High-level-synthesis for permutations (#9157) * Adding permutation synthesis algorithm for LNN * release notes * Checking that the synthesized permutation adheres to the LNN connectivity and has depth guaranteed by the algorithm * Adding tests for 15 qubits Co-authored-by: Nir Gavrielov <nirgavrielov@gmail.com> * Changing Permutation to be a Gate rather than QuantumCircuit * Adding the property pattern to Permutation class * fixing assert * improving description message for _get_ordered_swap * applying suggestions from code review * minor * attempt to fix docstring * Another attempt to fix docsting * another attempt to fix docstring * temporarily simplifying docstring to see if this passes docs build * adding blank line * another attempt * Restoring docstring * removing extra line * adding __array__ method for permutation + tests * HLS permutation plugin based on the original synthesis algorithm for permutations * speeding up _get_ordered_swap based on review comments * Adding depth-2 synthesis algorithm for permutations for all-to-all connectivity; including tests and plugin * release notes * Adding example to release notes * Update documentation of Permutation * add missing import * drawing decomposed circuit with permutations * forgot parenthesis * restoring qasm for circuits containing Permutations * Adding permutation method to QuantumCircuit * Adding test for quantum circuit with permutations * pylint * adding inverse() method to permutations * qpy support for permutations * tests for quantum circuits with permutations * checking depth bound on the ACG method * Adding tests for new Permutation functionality * black * Following review, keeping the old Permutation quantum circuit for backward compatibility, and naming the new permutation gate class as PermutationGate * additional fixes * updating release notes * docs fix * Removing permutation method from QuantumCircuit * Adding QPY test for circuits with permutation gates * Update qiskit/circuit/quantumcircuit.py Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Set default qasm name override to None Co-authored-by: Nir Gavrielov <nirgavrielov@gmail.com> Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-01-20 01:38:44 +08:00
"permutation.default = qiskit.transpiler.passes.synthesis.high_level_synthesis:BasicSynthesisPermutation",
"permutation.kms = qiskit.transpiler.passes.synthesis.high_level_synthesis:KMSSynthesisPermutation",
"permutation.basic = qiskit.transpiler.passes.synthesis.high_level_synthesis:BasicSynthesisPermutation",
"permutation.acg = qiskit.transpiler.passes.synthesis.high_level_synthesis:ACGSynthesisPermutation",
Implementing pluggable HighLevelSynthesis (#8548) * Initial implementation of pluggable HighLevelSynthesis * typo * black * fix merge error * Reorganizing entry points for high-level-synthesis plugins based on the comments * fixing some typos * HLSConfig now accepts a list of methods for each operation; also allowing to specify these lists in config's __init__ * running black * removing hls_config from __str__ in PassManagerConfig * Adding abc interface for high-level-synthesis plugins * improving docs and comments * fix * adding tests; removing print statements * removing external test file * remove redundant print * Passing HLSConfig in all transpiler optimization levels * Fix for is_parameterized as Operations don't have to support this * Replacing node.op.copy by copy.deepcopy(node.op) to avoid Operations implementing copy method * release notes * adding a link to HLSConfig class * Temporarily removing high-level-synthesis from optimization loop * Adding example from release notes to HighLevelSynthesis documentation * fixing random typo * adding references to documentation: * Further trying to improve documentation following the review comments * removing usused import * minor docs changes * Docs consolidation following review comments * added test * fixing title underline in docs * minor output tweaks * Update setup.py Co-authored-by: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-10-01 04:08:21 +08:00
],
Add stage plugin interface for transpile (#8305) * Add stage plugin interface for transpile This commit adds a new plugin interface to qiskit for enabling external packages to write plugins that will replace a stage in the transpilation pipeline. For example, if an external package had a custom layout pass that they wanted to integrate into transpile() they could export a plugin using this new interface and then users would just need to run transpile(.., layout_method=foo) This adds long asked for extensibility to the transpiler so that to cleanly integrate new transpiler passes we're no longer required to merge the features into terra. This should hopefully make it easier for downstream pass authors to integrate their passes into terra and make it easier for the terra maintainers to evaluate new transpiler passes. * Fix docs builds * Fix doc warning * Make routing methods all plugins This commit converts all the built-in routing method options into separate plugins and also adds a default plugin for the default behavior at each optimization level. To support using plugins for routing method adding the optimization_level to the passmanager config was necessary so that the plugin has sufficient context on how to construct the routing pass used for the routing stage. As depending on the optimization level the settings for each pass differs. For example on stochastic swap the number of stochastic trials increases for level 3 to try and find a better solution at the cost of more runtime. * Add plugin usage to level 3 * Add plugin support to level 0 preset pass manager * Add default plugin to reserved routing methods list * Add release notes * Add tests * Apply suggestions from code review Co-authored-by: Alexander Ivrii <alexi@il.ibm.com> * Apply suggestions from code review Co-authored-by: Alexander Ivrii <alexi@il.ibm.com> * Remove raise on non-builtin layout method argument * Fix typo * Deduplicate code in built-in routing plugins This commit deduplicates the code in the built-in routing stage plugins. First it removes the default plugin which was duplicated with the stochastic and sabre plugins. There was no functional difference between just setting the implicit default method name and using a per method plugin and having a standalone default plugin. Secondly all the vf2 call limit code is abstracted into a helper function which reduces code duplication. * Make vf2 call limit function private * Deduplicate code in stochastic swap plugin * Expand example plugin documentation to show more complete use case * Update qiskit/transpiler/preset_passmanagers/level1.py Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * Add missing TODO comment * Unify vf2 call limit handling * Remove default plugin from entry points * Simplify level 3 optimization stage logic * Update qiskit/transpiler/preset_passmanagers/plugin.py Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * Prefer toqm plugin if one is available The qiskit-toqm project will be one of the first users of this plugin interface. Once this is released in qiskit, qiskit-toqm will likely publish their own plugin soon after and if they do we want that plugin to be used instead of the hardcoded stage in terra. This commit updates the logic for toqm handling to only use the built-in toqm if a version of qiskit-toqm is installed without a plugin present. * Apply suggestions from code review Co-authored-by: Kevin Hartman <kevin@hart.mn> Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com> * Fix lint * Remove unnecessary elses in builtin plugins * Apply suggestions from code review Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * Make optimization level a plugin argument * Add test coverage for all built-in routing plugins * Reorder stage variables to execution order Co-authored-by: Alexander Ivrii <alexi@il.ibm.com> Co-authored-by: Luciano Bello <bel@zurich.ibm.com> Co-authored-by: Kevin Hartman <kevin@hart.mn> Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-08-31 02:16:51 +08:00
"qiskit.transpiler.routing": [
"basic = qiskit.transpiler.preset_passmanagers.builtin_plugins:BasicSwapPassManager",
"stochastic = qiskit.transpiler.preset_passmanagers.builtin_plugins:StochasticSwapPassManager",
"lookahead = qiskit.transpiler.preset_passmanagers.builtin_plugins:LookaheadSwapPassManager",
"sabre = qiskit.transpiler.preset_passmanagers.builtin_plugins:SabreSwapPassManager",
"none = qiskit.transpiler.preset_passmanagers.builtin_plugins:NoneRoutingPassManager",
],
Add unitary synthesis plugin interface (#6124) * Add unitary synthesis plugin interface This commit adds the initial steps for a unitary synthesis plugin interface. It enables external packages to ship plugin packages that then integrate cleanly into qiskit's transpiler without any need for extra imports or qiskit changes. The user can then just specify the 'unitary_synthesis_method' kwarg on the transpile() call and use the name of the external plugin and the UnitarySynthesis pass will leverage that plugin for synthesizing the unitary. * Also add qubits in payload with coupling map * Fix lint * Fix logic * Add documentation about the plugin interface * Export get_unitary_synthesis_plugin_names from qiskit.transpiler.passes * Fix lint * Tweak doc organization slightly * Use UnitarySynthesis for unroll3q step The usefulness of the plugin for unitaries >2q in the default pass manager pipelines was limited by the fact that previously the pass managers were all setup to run unroll3q before the unitary synthesis pass is ever run. The unroll3q pass just calls the circuit.data to decompose gates >=3q which for unitary gate objects just calls an inlined equivalent of the 'default' plugin. The purpose of this is to ensure later passes only ever need to deal with 2q gates. However with plugins now if a plugin only works on > 2q we'll never actually be passing an >= 3q unitaries to the plugin in the default pipelines. To fix this issue, this commit calls unitary synthesis before unroll 3q to use the synthesis pass to unroll any unitary gates instead of relying on the gate class's internal decomposition method which will always use the qiskit decomposition techniques. * Run black * Tweak doc organization slightly * Fix lint * Fix pylint errors * Apply suggestions from code review Co-authored-by: Jake Lishman <jake@binhbar.com> * Update plugin interface docs * Review comment updates on UnitarySynthesis pass * Fix typos * Include release notes * Fix docstring typo * Update qiskit/transpiler/passes/synthesis/unitary_synthesis.py Co-authored-by: Kevin Krsulich <kevin@krsulich.net> * Ignore deprecation warnings from importlib metadata Since the importlib metadata 4.8.0 release in late August 2021, stevedore <= 4.8.0 has raised a deprecation warning around using tuple based access (which was deprecated in 4.8.1 after 4.8.0 removed it and broke everything using stevedore). While this has been fixed on the master branch of stevedore (see: https://opendev.org/openstack/stevedore/commit/11da137e3fc34861be8ac3e664ee60a22e66b44c ) Until that fix is released this commit adds a deprecation warning ignore because there isn't anything we can do about the warning in qiskit. Once stevedore has a release that includes this fix we can remove the ignore from the tests. * Pin importlib-metadata The previous commit tried to fix the failures in CI around the deprecation warnings but while I'm unable to reproduce those locally with the warning ignore in place it still fails in CI. I expect there is a similar incompatibility around the 4 frequent importlib-metadata releases >=4.7.0 (2 of which were yanked) causing issues in the CI environment. Since things were working fine for the several months this PR was open prior to 4.7.0 this commit just pins the version in the constraints file to fix CI. * Add length units to docstring * Add min and max qubit abstract properties This commit adds 2 new required properties to the plugin class interface for min and max qubits. These enable a plugin author to specify the number of qubits the plugin supports and if the unitary to be synthesized is outside that range it will just fallback to using the ``default`` plugin. * Add option to automatically find basis for a run() call * Fix typo * Update gate errors docstring * Remove approximation degree from plugin interface * Fix docstring typos Co-authored-by: Eric Peterson <peterson.eric.c@gmail.com> * Apply suggestions from code review Co-authored-by: Jake Lishman <jake@binhbar.com> * Update qiskit/transpiler/passes/synthesis/unitary_synthesis.py Co-authored-by: Jake Lishman <jake@binhbar.com> * Update docstrings and naming and default to 'default' plugin in kwarg This commit updates several aspects of the documentation to make it more clear how to use the plugin interface. It also updates the naming of supported_basis to be supported_bases as it's actually plural. The last change in this commit is making the default kwarg value for the unitary synthesis method default to 'default' (for the default built-in method) instead of None. This simplifies the logic in the unitary synthesis pass. * Make coupling_map run() kwarg a tuple * Add comment on why we don't use a shared global instance * Fix straggler basis->bases typos * Apply suggestions from code review Co-authored-by: Jake Lishman <jake@binhbar.com> * Document supported_bases handling of no matching basis Co-authored-by: Jake Lishman <jake@binhbar.com> Co-authored-by: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: Jake Lishman <jake.lishman@ibm.com> Co-authored-by: Eric Peterson <peterson.eric.c@gmail.com>
2021-10-01 03:09:24 +08:00
},
)