Commit Graph

107 Commits

Author SHA1 Message Date
Eric Arellano 041877bfc4
Upgrade Pylint to 2.16.2 (#9615)
* Upgrade Pylint to 2.16.2

* Clarify we don't neccessarily want to enable everything

* Locally disable some checks that only fail in CI and seem bogus

Maybe related to what Python version Pylint is run with
2023-02-20 17:50:15 +00:00
Matthew Treinish a3b359b899
Add tweedledum to requirements-dev.txt (#9477)
* Add tweedledum to requirements-dev.txt

This commit adds a tweedledum to the requirements-dev.txt list. Since
the release of qiskit-terra 0.23.0 the CI docs job has started to fail.
This is because tweedledum is a requirement for the classicalfunction
compiler docs. It turns out we were getting tweedledum installed in docs
build jobs via a weird path. The install order for docs build was
installing packages that require qiskit-terra before terra itself was
being installed. This would cause qiskit-terra from pypi from being
isntalled first, and old versions of terra required tweedledum which
would install it. Then we'd later upgrade terra to the current version
under test. To fix this in the short term this adds add tweedledum to
the requirements list so we unblock CI. One thing to note is that since
the primary reason we removed tweedledum from the requirements list
in #8947 was because macOS users were not able to install it reliably
the new entry in the requirement-dev.txt list does not cause issues for
developers on macOS systems.

Longer term we should make two fixes, first we need to update the
classicalfunction compiler docs so they build without having tweedledum
installed. The second is we should update the CI job to avoid installing
terra from pypi before we build it from source. But, given that CI is
currently broken just adding it to the requirements-dev.txt list is the
fastest fix.

* Exclude tweedledum on Python 3.11 too
2023-01-27 22:36:33 +00:00
Takashi Imamichi 247c29899e
relax ipywidgets (#9414)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-01-23 12:00:43 +00:00
Jake Lishman b2311c4c3d
Add importer for OpenQASM 3 (#9347)
* Add importer for OpenQASM 3

This adds an interface for importing OpenQASM 3 into Qiskit Terra.
Right now, this is provided only as an optional dependency (the
`qasm3-import` optional), using the package `qiskit_qasm3_import`, which
in turn depends on the ANTLR runtime `antlr4-python3-runtime`.

The importer code may in the future be vendored into Terra, and will
likely be replaced completely by a more efficient importer in the
future, once a more concrete strategy has been decided for handling of
classical components in quantum programs.

* Expand capabilities section of release note

* Expand OQ3 import documentation

* Relax exact pin in optional requirement

* Remove superfluous word

* Update link to Qiskit org

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2023-01-19 19:42:20 +00:00
Julien Gacon 5ef95e690e
Pin ``sphinx-autodoc-typehint`` (#9383)
* Pin sphinx autodoc typehint

* pin to 1.23.1

* typo: 1.21.1 not 1.23.1

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-01-18 11:59:32 +00:00
Jake Lishman 3d8a6e0393
Pin sphinx-autodoc-typehints (#9377)
The 1.21.0 release appears to have changed the spacing in its outputs,
which is causing a bunch of Sphinx/docutils warnings for some of our
docstrings.
2023-01-16 13:38:16 +00:00
Matthew Treinish 95a97ec53c
Stop using jupyter-sphinx extension in docs builds (#9346)
* Stop using jupyter-sphinx extension in docs builds

The use of the jupyter-sphinx plugin has been increasingly unreliable
over time. While convinient to use jupyter to print the code and
rendered output in practice this extension is exceedingly fragile. The
nature of how the plugin launches jupyter kernels and executes code
causes it to be prone to failure and weird issues. A race condition in
this machinery is causing a high non-deterministic failure rate in CI
right now preventing us from reliably building documentation. This
commit removes the use of the jupyter-sphinx extension from the
documentation. For the most part a drop-in replacement is the ``plot``
directive from matplotlib that enables executing code and visualizing
the result as part of the documentation build. But it does this more
simply through ``exec()`` which will be much more reliable. In many of
the cases jupyter-execute wasn't even needed because no output was shown
in those cases a simple code-block is used instead.

For release notes, new release notes are updated to use plot where
necessary but for historical release notes all jupyter-execute
directives are converted to code-blocks. This was done for sanity to
avoid having to manually update hundreds of release notes over the past
3 years.

This also enables us to enable parallel builds as jupyter-sphinx was the
extension which was unreliable in a parallel context. Doing this can
greatly speed up documentation builds (although the impact in CI will be
limited as we only have 2 vCPUs in the CI workers).

* Fix tests and lint

* Revert accidental change to tox.ini

* Fix capitalization of GHZ circuit

* Cleanup circuit library visualization function
2023-01-06 16:25:55 +00:00
Julien Gacon 9733fc0ca9
Fix NumPy 1.24.0 compatibility and pin `coverage<7.0` (#9305)
* fix Kraus from (array, None)

* fix triu_to_dense test

* fix instruction comparison

* skip snobfit if numpy 1.24.0 or above is installed

Co-authored-by: ElePT <57907331+ElePT@users.noreply.github.com>

* pin coverage <7.0

* add links to Kraus and snobfit issues

* retrigger CI

Co-authored-by: ElePT <57907331+ElePT@users.noreply.github.com>
2022-12-20 17:49:55 +00:00
Takashi Imamichi b4f4c342c2
pin ipywidgets (#9272) 2022-12-09 15:19:15 +00:00
Jake Lishman a1c5a1bffa
Unpin jaxlib Python-version constraints (#9172)
`jaxlib` released Python 3.11 wheels as of 0.3.24 on 2022-11-04, so we
can release our pin on the constraint in `requirements-dev.txt`.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-11-21 19:44:59 +00:00
Matthew Treinish 75d66dd8ba
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 725c21b465.

* 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-03 16:58:14 +00:00
Matthew Treinish 08969a6c2a
Remove deprecated networkx dag converter functions (#9035)
* Remove deprecated networkx dag converter functions

This commit removes the deprecated DAGCircuit and DAGDependency
networkx converter functions. These functions were deprecated
in #7927 as part of the 0.21.0 release. Since the minimum
deprecation window has elapsed we can now remove these functions and
the last usage of optional networkx usage in qiskit terra.

* Remove unused imports

* Move release note to the correct location

* Add networkx to tutorials job environment

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2022-11-03 12:56:22 +00:00
Matthew Treinish 8999047a2d
Remove qiskit-toqm tests and requirements-dev.txt entry (#9057)
* Remove qiskit-toqm tests and requirements-dev.txt entry

Im #9042 we removed the special case code to enable using toqm as an
optional routing method. This was needed prior to qiskit-terra 0.22.0 as
we didn't have the transpiler stage plugin interface. However, now that
we've added a dedicated interface for external transpiler passes to
integrate into transpile() the toqm passes are using that interface.
However, in #9042 the tests for verifying the previously hard-coded toqm
routing method path worked as before were left intact. In general this
would be a good approach to ensure we're maintaining backwards
compatibilty with the new modular interface with earlier releases.
However, in this specific case this is causing an issue with how tests
are run. Since qiskit-toqm has a necessary dependency on qiskit-terra
this means when we install our development requirements before running
tests toqm is pulling in the latest stable release of qiskit-terra from
pypi. Then we later upgrade that with the source build before running
tests. This however this bi-directional test dependency introduces a
tension in a number of places. For the most recent example, when we're
trying to add support for new platforms (see #9028 for an example)
where the stable version of qiskit-terra does not support the platform.
We're unable to run CI with qiskit-toqm being installed first since
installing stable qiskit-terra won't work/

This commit removes qiskit-toqm from the requirements-dev.txt list and
also removes the test cases using it to fix this conflict. In general
the testing for qiskit-toqm can now be self contained since it's
exercising a stable interface in terra that's tested independently. When
weighing the backwards compatibility coverage vs the CI and build
complexities having the bidirectional test dependency has just removing
the toqm tests and development requirement is the simplest path forward.

* Remove unused imports

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-11-02 19:00:58 +00:00
Kevin Hartman d56ef8c49c
Use TOQM routing staged pass manager. (#9042)
* Update toqm requirements-dev version.

* Remove toqm special casing.

* Remove unused imports from preset pass managers.

* Add release note.

* Apply suggestions from code review

Co-authored-by: Jake Lishman <jake@binhbar.com>

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-11-01 20:16:43 +00:00
Manoel Marques df599dc9b1
Pin sphinx-autodoc-typehints to avoid 1.19.3 (#8795) 2022-09-27 01:17:25 +00:00
Matthew Treinish bdb2e3c15f
Remove stestr cap (#8781)
The recently release stestr 4.0.0 should have fixed the issue we were
encountering in CI that caused us to cap the version <4.0.0. This commit
removes the cap (but excludes the broken 4.0.0 release) so we can
continue getting updated versions of stestr.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-09-22 20:20:03 +00:00
Matthew Treinish ffc811be25
Cap stestr version in CI (#8732)
After the recent release of stestr 4.0.0 CI started failing in a weird
unexpected way 100% of the time. It's not clear why the failure started
and I'm unable to reproduce it locally (which is part of why I pushed
stestr 4.0.0, I did test that I passed tests locally before releasing).
To try and unblock CI this commit caps the stestr version we install in
CI to see if this fixes the failure and potentially unblock CI.
2022-09-12 22:17:54 +00:00
Luciano Bello 8be6f939e3
build the docs in python 3.9 (#8124)
* build the docs in python 3.9

* comment in azure-pipelines.yml

Co-authored-by: jakelishman <jake.lishman@ibm.com>

* sphinx-autodoc-typehints~=1.18

Co-authored-by: jakelishman <jake.lishman@ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-09-10 09:48:51 +00:00
Matthew Treinish f2d228ecd2
Remove stale dev dependencies from requirements-dev.txt (#8501)
* Remove stale dev dependencies from requirements-dev.txt

In looking at the requirements-dev.txt list as part of #8498 there were
a few entries which were not needed and/or are being used anymore. This
commit cleans those up and also removes an unused script for reporting
ci failures. The report script has been completed supersceded by native
comment actions in azure pipelines and github actions so we no longer
need to manually call the github api to report CI failures on periodic
jobs.

* Use pip to install extension for lint

* Update CI config to avoid explicit setup.py usage where not needed

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-08-16 20:01:43 +00:00
Matthew Treinish 82e38d1de0
Pin setuptools in CI (#8526)
* Pin setuptools in CI

The recently released setuptools 64.0.0 release introduced a regression
that prevents editable installs from working (see pypa/setuptools#3498).
This is blocking CI as we use editable installs to build and install
terra for testing. When there is an upstream release fixing this issue
we can remove the pins.

* Remove pip/setuptools/wheel manual install step

* Try venv instead of virtualenv

* Revert "Try venv instead of virtualenv"

This reverts commit 3ada819330.

* Revert "Remove pip/setuptools/wheel manual install step"

This reverts commit 831bc6e0db.

* Pin in constraints.txt too

* Lower version further

* Pin setuptools-rust too

* Set editable install to legacy mode via env var

* Set env variable correctly everywhere we build terra

* Add missing env variable setting for image tests
2022-08-12 09:13:59 +02:00
Luciano Bello e9f2a2b197
Remove upper cap on Sphinx version (undoes #8392) (#8416)
https://github.com/sphinx-doc/sphinx/issues/10701 is fixed
2022-07-28 16:27:07 +00:00
Luciano Bello aa6d359612
Sphinx 5.1 breaks doc building (#8392) 2022-07-25 12:45:51 +00:00
Prakhar Bhatnagar 7e8fe6755b
switched to `sphinx-design` (#8242)
* switch to `sphinx-design`

* set sphinx language to `en`

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-06-27 22:21:00 +00:00
Kevin Hartman a0b9a846f9
Integrate `qiskit-toqm` as an optional package for layout and routing. (#7825)
* Integrate qiskit-toqm as an optional layout and routing pass.

* Run formatting.

* Add release note.

* S

* Exclude Linux aarch64 for qiskit-toqm in requirements-dev.txt.

This is currently necessary since Qiskit TOQM isn't published to PyPI
for Linux aarch64 due to a bug.

* qiskit-toqm performs layout changes always.

...when configured using one of its optimization strategies. This is because
non-optimal configurations (i.e. anything using GreedyMapper under the
hood) aren't compatible with the layout search parameter, and in fact
break when it is provided. These configurations happen to always perform
layout (without the explicit search) through a different means. To make
everything consistent, it should be assumed that no matter which optimization
strategy is used, layout changes will be made via routing.

qiskit-toqm users can still create a custom strategy if they wish to use
an optimal configuration that does not make layout changes, and then
use their own pass manager.

* Add basic testing for TOQM integration.

* Update to use qiskit-toqm 0.0.3 API.

* Add testing of 5 qubit device.

This exercises the optimal mapper code paths of qiskit-toqm
opt levels.

* Update for target awareness.

* Add extra to setup.py for toqm.

* Bump requirement-dev.txt TOQM version.
2022-06-14 19:11:06 -04:00
Matthew Treinish e508729400
Make python-constraint optional (#7733)
* Make python-constraint optional

Since #7213 we no longer have been using the CSPLayout pass by default
in the preset passmanagers or transpile(). This is because it has been
superseded by the VF2Layout pass which is now used everywhere. While we
will keep the CSPLayout pass around for the forseeable future there is
no need to install python-constraint by default anymore since it's only
user is the CSPLayout pass, which isn't going to be commonly used
anymore now that it's not used in the default compilation path anymore.
This commit removes the python-constraint library from the requirements
list and makes it an optional dependency.

Fixes #7726

* Add docstring for HAS_CONSTRAINT

* Add private module to avoid module level optional import

This commit splits the custom solver class definition out into a
separate private module that is not imported until runtime. This enables
us to avoid a module level import for python-constraint meaning we only
try to import if something is actually using CSPLayout.

* Fix rebase issue

* Fix lint

* Fix typo in release note

Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>

* Alphabetize optionals list

Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
2022-05-26 19:20:51 +00:00
Jim Garrison a7d66f9aa7
Remove Cython as a build dependency (#7777)
This follows up on #7702, which removed the last of the Cython code.
The current change was was presumably intended to be part of that
PR, I think, based on the release note added there:

> Cython is no longer a build dependency of Qiskit Terra and is no
> longer required to be installed when building Qiskit Terra from
> source.
2022-03-14 22:18:57 +00:00
Matthew Treinish ccc371f8ff
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 57790c84b0. 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 c510764a77. 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-02-28 21:49:54 +00:00
Matthew Treinish 3763e61f16
Bump black version and relax constraint (#7615)
This commit bumps the black version we pin to the latest release,
22.1.0. This release is also the first release not marked as beta and
with that black has introduced a stability policy where no formatting
changes will be introduced on a major version release (which is the
year). [1] With this new policy in place we no longer need to pin to a
single version and can instead constrain the requirement to just the
major version without worrying about a new release breaking ci or local
development. This commit does that and sets the black version
requirement to be any 22.x.y release so that we'll continue to get
bugfixes moving forward without having to manually bump a pinned version.

[1] https://black.readthedocs.io/en/latest/the_black_code_style/index.html#stability-policy
2022-02-03 18:07:22 +00:00
Matthew Treinish da64649c61
Pin sphinx-autodoc-typehints to unblock docs builds (#7492)
sphinx-autodoc-typehints pushed the 1.14.0 release earlier today and
ever since the docs jobs are failing to build trying failing to
resolve signatures on builtin methods to python. This commit pins the
sphinx-autodoc-typehints version to unblock this until the issue is
reported and fixed upstream.
2022-01-06 19:17:24 +00:00
Jake Lishman 3092929469
Fix documentation for Sphinx 4 (#7469)
Sphinx 4 is more particular about disallowing the same Python object to
be documented in multiple toctree entries.  The culprits were `Barrier`,
`Reset` and `Measure` in the circuit library; the library re-exports
them from their canonical locations, and used `autosummary` to generate
extra links to them.  We still re-export them, but change the
`autosummary` tables to link to the existing definitions.

This then builds the documentation without errors on Sphinx 4, and
consequently the pin on `sphinx-panels` can be removed.  Previously the
pin was applied because an update to that package caused the
documentation build to break; in reality, it's just that
`sphinx-panels<0.6` pinned itself to `Sphinx<4`, whereas version 0.6
allowed Sphinx 4 - there were no breaking changes for us.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-01-04 21:29:13 +00:00
Matthew Treinish cb25699c1a
Add distutils warning ignore from seaborn (#7462)
* Add distutils warning ignore from seaborn

The recent setuptools releases, since 59.6.0 according to the release
notes: https://setuptools.pypa.io/en/latest/history.html#v59-6-0, have
been emitting a deprecation warning about the use of Version classes
from distutils. The seaborn project is still using these in the current
releases which is causing the project to emit these deprecation
warnings. Since the test suite enforces we don't emit deprecation
warnings this is causing test failures when running with newer
setuptools. The deprecated usage has already been fixed upstream in
seaborn but it hasn't been released. To fix test runs and CI while
waiting for a seaborn release this commit adds the distutils version
class deprecation message to the warning ignore list. We should remove
this once seaborn releases.

Fixes #7457

* Pin Sphinx to <4.0

This has been necessary for some time, except the pin was not present
because another dependency (sphinx-panels) also required Sphinx<4. Now,
an update in another dependency (sphinx-autodoc-typehints) requires
Sphinx >4, so we have to be explicit.

* Relax FP tolerance in R(v)-R equivalence test

The two forms do not use exactly the same set of floating-point
operations, so are subject to some potential differences, likely during
vectorisation on different machines.  CI was seeing test failures which
could not be reproduced locally, perhaps due to different SIMD
instruction sets.  The tolerance here should allow enough flexibility
for the slightly different sequences of floating-point operations.

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2022-01-04 11:49:22 +00:00
Jake Lishman 2af1016f7b
Bump black to the latest version (#7363) 2021-12-07 14:57:08 +00:00
Jake Lishman ba8e3f34f0
Fix compatibility with Matplotlib 3.5 (#7301)
* Fix compatibility with Matplotlib 3.5

The problem was `qiskit.visualization.bloch.Arrow3D`, which subclassed
`matplotlib.patches.FancyArrowPatch` (a 2D patch), but not the 3D
machinery.  It is now made an unholy multiple-inherited abomination of
both the 2D patch and `mpl_toolkits.mplot3d.art3d.Patch3D`; the latter
is a relatively thin wrapper (in terms of attributes) around the 2D
patch, so this is not too terrible.

Matplotlib 3.5 calls the `Patch3D.do_3d_projection` method using a
deprecated parameter, triggering two warnings, unless the artist's
module appears to have come from `mpl_toolkits.mplot3d.art3d`, even if
the new calling convention is respected.  The warning is only triggered
when the figure is drawn, which may well be outside of our control, so
we cannot suppress the warnings.  Instead, we just lie about the module
the arrow patch was defined in, to trick it into not warning, because we
use the new calling convention.  This is supported at least as far back
as Matplotlib 3.3, which is the current minimum supported version.  The
nasty hack should be removable once Matplotlib 3.6 is the minimum
version because the deprecation period will expire.

* Remove useless word

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-11-23 19:54:51 +00:00
Jake Lishman 6cd3ed163b
Pin matplotlib <3.5 and remove unused imports (#7273)
* Pin matplotlib <3.5

This is temporary to get CI running again, while we prepare a proper
fix for the latest version.

* Remove unused imports

A bug in pylint can sometimes cause unused imports in certain files to
be ignored if they're used in a module-level comment type hint somewhere
that's imported first.  For more, see:
https://github.com/Qiskit/qiskit-terra/pull/7270/#discussion_r749854451

* Pin matplotlib in setup.py too

* Pin matplotlib in azure-pipelines.yml
2021-11-16 13:31:40 +00:00
Matthew Treinish 4c444a3bba
Bump minimum matplotlib version to 3.3.0 (#7175)
* Bump minimum matplotlib version to 3.3.0

In matplotlib 3.4.0 released on 03/26/2021 there were some deprecations
around our use of Axes3d in the state visualization and bloch sphere
modules. Fixing our usage to avoid these deprecations was previously
attempted in #6136 and #6087 but we did not move forward there because
the supported API we need to use matplotlib 3.3.0 when it was
introduced. We previously did not want to raise our minimum supported
matplotlib version to 3.3.0 to accomodate this. However, recent changes
in transitive dependency of mpl, pyparsing, caused an incompatibility
when running with older mpl versions around mathtex. To fix that we
had to pin pyparsing in the constraints file (see #7174). It appears
that now is a better time to raise our minimum version because the
burden of trying to keep support for older matplotlib versions is higher
than it once was.

This commit bumps the minimum matplotlib version to 3.3.0, updates the
usage of Axes3d to avoid the deprecated usage in matplotlib 3.4.0, and
removes the contraints pinning introduced in #7174. This should get us
on supported releases for matplotlib moving forward and it'll hopefully
be a while before we encounter this kind of version issue in the future.

Fixes #6136

* Run black

* Restore constraints pinning

I was under the mistaken impression that the current mpl releases were
compatible with pyparsing3, but looking at the linked mpl issue it's not
fixed yet only for their development so far. So to unblock CI this
restores the pinning as it's still needed until mpl releases a fix.

* Fix matplotlib 3.3.x compat

* Fix version string comparison typing

* Fix typo

* Fix second `ax` typo

* Fix gatemap tests with newer matplotlib

* Fix lint

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-10-28 13:39:38 +00:00
Jake Lishman 57af21a96d
Disallow `ddt==1.4.3` (#7067)
* Disallow ddt==1.4.3

This version of ddt changed the signature of `ddt.idata`, to add a
second positional argument with no default.  This makes use of that
function incompatible between different versions of `ddt`, so it's no
longer safe to use in CI, and for local builds.

* Move ddt exclusion into requirements-dev.txt

constraints.txt is more typically for specifying constraints on
transitive dependencies, whereas `ddt` is a solid dependency for us.
2021-09-27 21:34:24 +00:00
Matthew Treinish 8066224cda
Bump reno requirement to latest version and set default_branch (#6858)
When we switched to using main as the default branch for qiskit-terra
we encountered a bug in reno that required a branch named master to exist
for traversing the git history. To workaround that issue we temporarily
added back a branch named master while we waited for the fix [1] to be
included in a release. A new reno release has been published [2] and we
can rely on that version and delete the idle master branch now. This
commit makes this change and switches to using reno>=3.4.0 and uses
the new default_branch configuration option added in 3.4.0 to fix the
issue.

[1] ed6bbae82e
[2] https://pypi.org/project/reno/3.4.0/
2021-08-02 18:38:13 -04:00
Matthew Treinish 5ca967557b
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-12 19:22:26 +00:00
itoko cd4a712d8f
BIP mapping pass (#6580)
* wip: initial move

* fix a bug when no coupling_map is supplied

* Improved documentation and parameter settings

* Improved logical/physical qubit mapping

* Better handling of measurements and final layout

* minor fixes

* add unit tests

* wip: start refactoring

* improve layout handling

* simplify dag construction and fix to output all ops

* fix to work with ApplyLayout

* focus on layout+routing

* improve how to call MIPMapping

* simplify the spec

* add an error handling

* fix how to call MIPMapping pass

* update user warning for change of given layout

* wip: refactor mip model

* improve top-level interface

* return original dag if fails to solve MIP

* minor fixes

* care the case no cplex is installed

* fix not to ignore swaps in original layers

* fix mismatch in layer and su4layer indices

* simplify by focusing only on depth objective

* rename MIP to BIP

* lint

lint

lint

lint

* improve interface around dummy steps

* improve error message when cplex fails

* restore level3 preset passmanager

* improve depth objective

* Rework optional dependency and add test configuration

This commit reworks the logic around the optional dependency on cplex.
The pass despite raising an exception if cplex wasn't installed was
unconditionally trying to import cplex from the model module at import
time. To avoid failures from that this adds a try block around the
actual cplex usage in the model module and exports whether it's
available or not. At the same time this is leveraged to add a skip
condition on the tests so we only run them if cplex is installed. Then
to run tests in CI we install cplex in the linux 3.7 job so we at least
run it in one environment. It's not available in all our supported
environments so getting full coverage in every env is not worth trying
for, so just testing the qiskit portion works is enough.

* Fix lint

* Fix test, lint and logging

* Fix lint and test, update docstring

* Fix docstring and improve performance taking the risk of failing to map

* Update docstring

* Replace cplex.Cplex with docplex.mp.model.Model to improve readability

Replace cplex.Cplex with docplex.mp.model.Model to improve readability

fix requiring docplex version

move docplex to requirements-dev

* Improve BIPMappingModel interface

simplify and improve docstring

Improve BIPMappingModel interface

* Update qiskit/transpiler/passes/routing/algorithms/bip_model.py

Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com>

* Fix docplex dependency

* fix unnecessary-comprehension

* lint

* lint

* update how to set cplex params and remove redundant constraints

* skip unless docplex

* fix a bug in arg threads

* remove python version restriction

* Change spec to require the number of virtual and physical qubits are the same

* Update to use 'requires' to require precondition passes

* Update qiskit/transpiler/passes/routing/algorithms/bip_model.py

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

* lint

* Add release note

Add release note

fix typos

* Update docstring

Update docstring

fix typo

* Improve error handling

* Change to return mapped dag for circuits with only 1q-gates

* Revert the spec change in the case of only 1q-gates

* Update releasenotes/notes/add-bip-mapper-f729f2c5672d7f3e.yaml

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* Update releasenotes/notes/add-bip-mapper-f729f2c5672d7f3e.yaml

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* Update qiskit/transpiler/passes/routing/bip_mapping.py

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* Update qiskit/transpiler/passes/routing/bip_mapping.py

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* Update qiskit/transpiler/passes/routing/bip_mapping.py

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* Update qiskit/transpiler/passes/routing/bip_mapping.py

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

Co-authored-by: Giacomo Nannicini <gnannicini@users.noreply.github.com>
Co-authored-by: Giacomo Nannicini <giacomo.n@gmail.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-01 06:29:40 +00:00
Ikko Hamamura ecbb007037
Upgrade to pylint 2.8.3 (#6317)
* Upgrade pylint 2.8.2

* fix lint

* fix lint of test/mock/fake_job

* black

* 2.8.2 to 2.8.3

* fix tools pylint error
2021-06-24 15:53:06 +00:00
Matthew Treinish 54c8c1ec6d
Pin sphinx-panels version for docs builds (#6511)
Since the recent release of the sphinx-panels plugin the docs jobs have
all been failing CI. Since the only recent related release was this
sphinx plugin this commit caps the version to be less than the recent
version to unblock CI.
2021-06-04 15:10:48 -04:00
Matthew Treinish 2eee56616d
Switch to using black for code formatting (#6361)
* make compatible with pylint and pycodestyle

* black config

* flake8 compatible config

* Missing newline

* Add black check to CI and dev requirements

This commit updates the CI configuration and local tox configuration to
leverage black instead of pycodestyle. It adds a check job to ci and the
tox lint job so we can quickly check if black has been run. A tox job
named 'black' is added to run black on all the code in the repo.

* Run black on everything

This commit reformats all the code in the qiskit-terra repository to use
black. It changes no functionality in the project and just adjusts the
code formatting to be consistent and automated. If you are looking at
this commit in the git log you can likely safely ignore any diff from
this commit as it is just the result of running '`black' on the repo
and instead you should look at any commits before or after this for
functional changes.

Co-authored-by: Lev S. Bishop <18673315+levbishop@users.noreply.github.com>
2021-05-05 09:53:39 -04:00
Matthew Treinish 63267df506
Remove sphinx pin (#6220)
In #4556 we pinned sphinx to workaround some CI failures related to new
warnings being emitted by sphinx with the release sphinx 3.1.0. Since
then there have been serveral releases of sphinx with new features and
more importantly several bug fixes, and the warnings previously being
emitted no longer seem to be an issue (at least for local builds on
python 3.8). This commit removes the pin so we can use the latest
version of sphinx in CI and locally.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-04-14 01:03:28 +00:00
Luciano Bello 674a6e2898
Boolean expression object (#5830)
* added dymacs_oracle

* added dimacs_oracle

* added dimacs_oracle

* updated evaluate_bitstring

* simplify logic a bit

* added unittests

* clean up

* added logical_expression_oracle.py

* added comments and unittests

* clean up

* lint

* fix linting

* fixed based on the comments

* boolean expression

* docstring

* converter and dimacs support

* parity decomposition

* phase oracle

* boolean expression as a gate

* simulate to keep it like classical function

* objective_qubits from a phase oracle

* new api

* revert problem touching

* tests

* fixing test.python.classical_function_compiler.test_tweedledum2qiskit

* Update qiskit/circuit/library/__init__.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* revert

* fix simulate

* more testing

* change synth algo

* fixes #5666

* dependency

* linting linting

* circular impport

* testing phase oracle

* phase test

* msg

* similar testing

* lint

* maybe last lint cleaning

* moving docs

* lint

* more linting

* lint

* another lint

* lint!

* adapt test

* new test

* failing in linux

* remote debuging

* more debug

* new tweedledum

* more debugging

* false positive in pylint

* tweedledum==1.0.0b3

* organize HAS_TWEEDLEDUM flag

* linting

* check if the file exists

* release note

* remove state_qubits

* docstring

* no python highlighting?

* Apply suggestions from code review

import error with pinned version

* abstract class for classical elements

* abc

* cleaner Phaseoracle

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* now _build_from_boolean_expression

* ups

* from_dimacs

* MissingOptionalLibraryError

* abstract class should skip

* Update qiskit/circuit/library/phase_oracle.py

* some refactors

* lint

* Update qiskit/circuit/library/phase_oracle.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* reno

* Update releasenotes/notes/bool_expression_phaseoracle-1802be3016c83fa8.yaml

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* type hint

* Update qiskit/circuit/classicalfunction/boolean_expression.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* lint

* more typehints

* hints are getting out of control

* self.qreg

* 3.6

* fix missing whitespace

* lint

* ilnt

Co-authored-by: Atsushi Matsuo <MATSUOA@jp.ibm.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: a-matsuo <47442626+a-matsuo@users.noreply.github.com>
2021-03-31 18:11:32 +00:00
Matthew Treinish 003bac81de
Cap ipython and ipykernel in CI (#6107)
* Cap ipython and ipykernel in CI

ipython and ipykernel have both recently released and since that release
a large portion of our CI jobs have started failing with exceptions in
these packages. In order to unblock CI this commit pins the packages in
the constraints files (as they're not direct dependencies).

* Fix ipykernel version pin

* Switch from a constraint to a requirements cap
2021-03-29 21:17:14 +00:00
Matthew Treinish 2f3b772eda
Pin matlotlib in CI (#6090)
PR #6087 attempted to fix CI by fixing compatibility with the recent
matplotlib release 3.4.0. However to fix the deprecated API usage we
need new features from matplotlib 3.4.0 which would break compatibility
for users on older matplotlib (as our tutorials job caught since it pins
mpl to avoid a performance regression). As an alternative to that this
commit just pins matplotlib in CI so we do not install the version
emitting deprecation warnings. This means that users will see
deprecation warnings when they use some function (mainly qsphere and
bloch sphere), but until we're ready to raise our minimum supported
matplotlib version to 3.4.0 that is unavoidable.
2021-03-26 19:47:51 +00:00
Luciano Bello 48a5764948
scikit-quant 0.8 is not installable (#6041)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-03-17 22:43:17 +00:00
Ikko Hamamura d396a91520
Upgrade to pylint 2.7 (#5630)
* upgrade astroid, pylint

* update for pylint 2.6

* Apply suggestions from code review

* update to pylint 2.6.2

* upgrade pylint 2.6.2 in requirements-dev.txt

* Bump to latest pylint version 2.7.0

This commit bumps the pylint version to pylint 2.7.0 which adds python
3.9 compatibility. It fixes issues identified by new and changed rules
in this new version. These fall into 3 primary categories,
'use-a-generator' fixes which remove intermediate lists or other
containers inside a generator function, disables in places where pylint
incorrectly thinks a QuantumCircuit is list and fails on no-member, and
disables in places where pylint is unable to correctly resolve a kwarg.

* Fix new errors from rebase

* Upgrade to 2.7.1

* revert unnecessary change

* Revert

* fix linter error

* fix linter error

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Manoel Marques <Manoel.Marques@ibm.com>
2021-02-25 13:01:34 -05:00
Luciano Bello 0b30218df2
pin tweedledum version (#5853)
* pin tweedledum version

* setup
2021-02-16 18:06:19 -05:00
Matthew Treinish 61e819eba3
Add test requirements for aqua migrated tests (#5527)
* Add test requirements for aqua migrated tests

In #5479 we migrated a number of tests for the algorithms/ and opflow/
directories as part of the final step of the code migration from
qiskit-aqua. However, as part of that change we didn't add the
additional optional dependencies added as part of that migration. This
means a subset of tests have been skipped since we added the tests. This
commit fixes this issue by adding the optional dependencies to the
requirements-dev.txt list so that we're running as many tests as are
reasonable during the CI runs.

* Exclude jax on windows envs

* Also exclude scikit-quant on Windows
2021-01-08 13:38:05 +01:00