Commit Graph

5732 Commits

Author SHA1 Message Date
Matthew Treinish 7bb2b1e0b1
Bump version strings post release (#6722)
Now that qiskit-terra 0.18.0 is out the door we should bump the version
string on master to show the source version we're installing is newer
than what's been released.
2021-07-13 07:40:28 -04:00
Matthew Treinish f69e397588
Handle complex parameters and blueprint circuits in QPY (#6713)
This commit fixes an issue with generating and loading QPY files with
complex instruction parameters (initialize) or blueprint circuits that
were in a circuit. Normally complex parameter types aren't valid on
gates or instructions, however initialize uses them as the statevector
elements are stored as the parameter list for the object (instead of as
a numpy array parameter like unitary). So to fix this we need to be able
to handle this edge case and save complex numbers for parameters too.

Similarly there was an issue found when trying to deserialize a blueprint
circuit object. It doesn't seem possible to reconstruct an instance of a
blueprint circuit reliably from just the parameters list for the
circuit. This causes an issue when deserializing as the gate
reconstructed from the qpy data is not valid. The only way to fix this
is to treat any blueprint circuit as a custom gate or instruction
instead of a discrete library element.

In case this merges after 0.18.0 and needs to be backported to 0.18.1
this is still a backwards compatible change from the QPY guarantee PoV.
While the complex parameter type wasn't present prior to this commit it
does not change the file format at all, and works with in the
constraints of QPY v1. Any QPY file generated with 0.18.0 will still be
loadable by 0.18.1 (assuming this commit is included in a 0.18.1
release). This is really just a bug fix because you could not generate a
QPY in 0.18.0 with initialize using complex parameters. It's also worth
pointing out from a compatibility PoV a QFT in a circuit would generate
a QPY file in 0.18.0 however this QPY file could never be loaded as we
can't create a QFT from what 0.18.0 stored in the qpy data.

Fixes #6710

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-13 09:48:52 +00:00
Matthew Treinish 4403b6af74
Use ddt for test_transpile_across_optimization_levels (#6685)
This commit updates the test_transpile_across_optimization_levels in the
TestParameters test class to leverage ddt instead of a for loop for
testing each optimization level. Right now we're hitting sporadic
failures in CI related to that test case and the only candidate for
causing a performance issue is only applicable to optimization level 3.
To get better data about the failure mode it is important to know which
optimization level a failure is occuring at. By using ddt and
parameterizing the test over each optimization level, each opt level
becomes a separate test method with a unique test id (which identifies
the optimization level) so we can easily verify if the failures only
occur at level 3 or not.
2021-07-12 23:10:37 +00: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
ewinston 5e2de04db6
Pulse optimal decomposition of su4 for CNOT (#6581)
* pulse optimization for 3-cnot working

* 2 cnot effecient decomp working

* for pulse efficient ZSX decomp make sure all gates are in in basis

* make pulse optimal decomposition two-qubit direction aware.

On devices where the CNOT occurs with greater fidelity in one direction than the opposite direction, this PR does the decomposition two qubit pulse optimal decomposition in the way which improves fidelity.

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

* minor typo

* tab

* black linting

* add tests for multiple registers, coupling_map.

Also adds index method to registers

* add swap to pulse optimal synthesis

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

* fix bug synthesizing swap when it's in basis

* lint

* handle empty basis gates

* Pulse optimal decomposition is done if not specified

and raises an exception if requested but not possible.

Clean the syntax a bit.

Co-authored-by: Lev S. Bishop <18673315+levbishop@users.noreply.github.com>

* linting

* add xzx decomposition. Fix global phase.

* linting

* standard handling for circuit_xzx

* ci test to find mac/windows bug

* test

* test ci known decomp

* linting

* improve phase handling

* clean debug code. add tests.

* add release notes. add "synth_gates" option to unitary synthesis pass.

* linting

* linting, update docs

* missed global phase addition. linting. docstring.

* linting

* try to fix doc timeout

* add XZX to known ONE_QUBIT_EULER_BASIS_GATES

This makes the UnitarySynthesis and Optimize1qGatesDecomposition passes
aware of the xzx decomposition.

* resolved bug in natural_direction flag

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

* Fix test skip condition and lint

* increase size of qv circuit

* Update test/python/transpiler/test_unitary_synthesis.py

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

* Update test/python/transpiler/test_unitary_synthesis.py

* Fix tests and lint

* remove register.index(). Cache indexing in test.

* linting

* add coupling_map to UnitarySynthesis in preset passmanagers.

* raise if non-optimal decomposition encountered and pulse_optimize=True

* fix optimization in special case of 3 cnot decomp.

* testing

* missed line

* linting

* catch another special case of decomp

* typo

* change logic in 2q decomp

* debug code

* more debug code

* global phase

* passing unix test

* linting

* test wrong comp

* linting

* revert qceuler

* update natural_direction documentation

* clean debug code

* formatting

* Revert "formatting"

This reverts commit 2d46f20b24.

* Revert "clean debug code"

This reverts commit a78d848dd0.

* fix flag

* correct global phase in a case

* clean debug code

* catch sign problem

* correct correction

* catch rounding error

* typo

* Update qiskit/transpiler/passes/synthesis/unitary_synthesis.py

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

* Update qiskit/transpiler/passes/synthesis/unitary_synthesis.py

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

* Add backend properties to preset pass managers

* change internal "natural_direction" to "preferred_direction"

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: Lev S. Bishop <18673315+levbishop@users.noreply.github.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-12 16:51:18 +00:00
Matthew Treinish 39d290667b
Pin networkx for CI (#6711)
Networkx 2.6 released a few hours ago and is causing a version conflict
with the matplotlib version we install in the tutorials job. The version
we use in the tutorials job was specifically pinned because of
performance issues we were seeing with newer matplotlib releases
(admittedly a while ago) to side step the issue and get 0.18.0 out the
door this commit pins the networkx version we use in the constraints
file. After 0.18.0 releases we can investigate removing the matplotlib
pin in the tutorials job and this constraint.
2021-07-08 21:33:15 +00:00
Naoki Kanazawa 97d7a7fd62
Alignment to pulse constraints (#6705)
* alignment to pulse constraints

* update docstring

* update reno

* fix pulse validation bug

* add test

* replace naming

* Update qiskit/compiler/transpiler.py

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

* move validation

* fix parser

* black

* update documents

* Update qiskit/transpiler/passmanager_config.py

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2021-07-08 17:22:24 +00:00
Julien Gacon bbc000179e
Wrap probability distributions to `Gate`s, not `Instruction`s (#6704)
* convert probdists to gates, not instructions

* iso is not a Gate

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-08 13:20:01 +00:00
Ali Javadi-Abhari adb207bef8
Fix registers in Layout found by BIP (#6701)
Fixes an oversight in BIP mapper where the Layout was constructed without registers added to it
2021-07-08 06:36:23 -04:00
Matthew Treinish 1104041cfb
Revert "Fix ``QuantumCircuit.assign_parameters`` docstring (#6546)" (#6696)
This PR included a deprecation removal which was invalid as not enough
time has passed. The deprecation occured in 0.17.0 which is not eligible
for removal until the 0.19.0 release. This PR can be repropoposed after
0.18.0 is released and quickly merged into 0.19.0.

This reverts commit 09f9c10daa.

Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-08 09:23:42 +00:00
Julien Gacon ecde4971de
Fix wrapping of ``GroverOperator`` (#6697)
* barrier isn't good enough to check!

* add test

Co-authored-by: Manoel Marques <Manoel.Marques@ibm.com>
2021-07-07 23:14:51 -04:00
Junye Huang d83ce486b4
Fix qasm output for composite gates (#5887)
* fix wrong condition for checking root gates for qasm output

* verify support gate definitions with qelib1.inc in composite circuit output

* add a line break for self.qelib1_gate_names

* add definitions for children gates

* handle exception of instructions without definitions

* move exception handling to _get_composite_circuit_qasm_from_instruction

* generate instruction definitions after all undefinied instructions are identified

* insert gate definition before

* find all undefinied gates and add to the list

* correct C3XGate, C4XGate, RC3XGate, C3SXGate name to match qelib1.inc

* expilictly specify number of control qubits in mcx_gray, mcx_recursive, mcx_vchain

* expilictly specify number of control qubits in mcx_gray, mcx_recursive, mcx_vchain

* remove commented unused code

* recursive generation of composite gate qasm

* remove redundant newline for gate definitions

* add barrier, measure, reset to qelib1_gate_names

* resolve merge conflicts

* Revert "resolve merge conflicts"

This reverts commit f7516973cc.

* remove redundant code after merging

* append instruction id to make it unique for custom instructions that have same name as existing instruction

* use unitary gate definition string

* remove unitary gate definition output from unitary gate and incorprate directly in QuantumCircuit

* remove redundant unitary_gate list in QuantumCircuit.qasm

* modified tests to fit the current format of qasm definition string

* fix linter errors

* add test_circuit_qasm_with_mcx_gate

* add test_circuit_qasm_with_mcx_gate_variants

* add test_circuit_qasm_with_composite_circuit_with_children_composite_circuit

* rename c3sqrtx to c3sx

* black

* accept all incoming changes

* make self.qasm_string_temp a local variable instead of class property

* self.existing_composite_circuits a local variable

* remove self.qelib_gates and revert back to local existing_gate_names

* correct existing_composite_circuits to be empty list

* change _get_composite_circuit_qasm_from_instruction and _insert_composite_gate_definition_qasm to module level private function

* fix linter error

* rename qasm_string_temp back to string_temp

* add missing import for ControlledGate

* fix circular import issue with ControlledGate

* fix insert composite gate definition

* fix recursive generation of composite gate definition

* formating

* revert 2dd3d1983c

* black

* reduce diff

* reduce diff

* import

* even small footprint

* Update qiskit/circuit/quantumcircuit.py

* replace nested conditionals

* match existing_gate_names with qelib1.inc from paper

* remove import qiskit

* Revert "match existing_gate_names with qelib1.inc from paper"

This reverts commit e27f162ec6.

* update test_qasm_unitary_twice and test_qasm_2q_unitary expected qasm output to match qc.qasm() method

* tensor in place

* restore x.py

* modify test_circuit_qasm_with_mcx_gate to match issue 4943 test case

* match expected qasm output in test_circuit_qasm_with_mcx_gate_variants without changing names

* remove print

* restore qelib1.inc from main branch

* restore lexer.py from main branch

* black

* restore unitary.py mat and cmat

* add release note

* lint

* unused import

* black

* seperate _add_to_existing_composite_circuits function from _get_composite_circuit_qasm_from_instruction

* clean up and rename to _add_sub_instruction_to_existing_composite_circuits

* fix typo

parant->parent

* fix lint & test

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2021-07-08 01:10:18 +00:00
Julien Gacon 2c2fea0bc4
Add the option to wrap circuits in ``QuantumCircuit.compose`` (#6659)
* allow wrapping circuits in compose

* add reno

* black

* lint!

* Update releasenotes/notes/compose-can-wrap-e839c29e426051e8.yaml

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.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-07 22:55:59 +00:00
Naoki Kanazawa d9f1a92238
More docstring for align passes (#6681)
* add more docstring

* rewording

* Update qiskit/transpiler/passes/scheduling/instruction_alignment.py

Co-authored-by: Thomas Alexander <thomasalexander2718@gmail.com>

* Update qiskit/transpiler/passes/scheduling/instruction_alignment.py

Co-authored-by: Thomas Alexander <thomasalexander2718@gmail.com>

* lint

* minor change to trigger CI

* minor change to trigger CI

* Update qiskit/transpiler/passes/scheduling/instruction_alignment.py

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

* Update qiskit/transpiler/passes/scheduling/instruction_alignment.py

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

* add documentation for alignment

* fix error

* Fix link sphinx syntax

Co-authored-by: Thomas Alexander <thomasalexander2718@gmail.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-07 20:22:49 +00:00
Matthew Treinish 456d036ade
Fix support for standalone registers in qpy format (#6523)
* Fix support for standalone registers in qpy format

This commit tweaks the qpy register format slightly to enable
differentiating between standalone registers (ones that own their bits)
and registers that contain pre-existing bits. Previously this didn't
work in all cases with standalone registers (it only worked assuming
the qubits in a register were a contiguous set of qubit indices in the
circuit). Normally this type of change would require a format version
bump for backwards compatibility (see #6419 for a PoC showing this)
however because we have yet to include qpy in a release we have an
opportunity to fix this prior to release in the same initial version.

* Fix sphinx syntax

* Fix docstring whitespace

* Fix rebase error

* Update qiskit/circuit/qpy_serialization.py

Co-authored-by: Kevin Krsulich <kevin@krsulich.net>

* Expand docstring

* Fix bugs and expand tests

* Add mixed standalone shared register circuit test

In the process of adding this test a bug was found in the DAGCircuit
__eq__ method (which is used for QuantumCircuit too). The equality of
circuits was failing based on the insertion order of registers which
doesn't matter. As long as the bit indices are in order in the register
(ie qr[2] -> 3 is consistent between both circuits) the order qr was
inserted into the circuit doesn't matter. This was causing a failure in
the new test because qpy deserialization always loads standalone
registers first even though the bit order is properly preserved. To fix
this the dagcircuit __eq__ method is update to only care about the bit
indices (both register and circuit) and ignore register insertion order.

* Add comments on the read register flow

* Preserve register insertion order on circuit deserialization

This commit preserves the register insertion order when deserializing a
circuit form qpy. Previously this wasn't being preserved and standalone
registers were always being added first. This also reverts the change
made to dagcircuit.__eq__ made in an earlier commit to workaround the
earlier limitation.

* Handle out of order register bit insertion

* Fix endianness bug in register index array

* Preserve the label for instructions

This commit modifies the instruction payload format to also include the
label of an instruction in the circuit. Previously we were just ignoring
the label which meant that it was omitted from the qpy data and any
labels would not be present in the deserialized circuit.

* Fix duplicate test_name

* Fix lint

* Assert label equality in label tests

* Fix label init condition

* Remove unecessary condition

* Deduplicate register creation

Co-authored-by: Kevin Krsulich <kevin@krsulich.net>
2021-07-07 13:14:23 -04:00
Julien Gacon fcedd7e17a
Wrap library circuits (#6634)
* start wrapping all plain QC library circuits

* fix more tests

* fix phase estimation test on QFT reverse bits

* black

* name QFT uppercase

* final test fixes

* GroverOp includes the global phase in inner circuit, don't add it to outer circuit
* Make sure ``unitary`` input to PhaseEstimation is a gate and not instruction

* wrap nlocal circuits

* blueprint circuits

* fix gradient tests

* wrap circuit library newcomers

* missing inner name in grover op

* wrap evolved op ansatz + QAOA

* fix qaoa tests

* rename inner->circuit

* add reno

* black
2021-07-07 09:33:27 -04:00
Eric Peterson b32a53174c
Fix `Optimize1qGatesDecomposition` length heuristic (#6553)
* fix 1q optimization heuristic

* drop unnecessary brackets

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

* actually fill out reno template :P

* maker linter happier

* make lev happier

* add a GH link to the sloppy synth warning

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

* improve source linking in changelog

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

* remember target basis name

* update circuit definitions

* improve linter cheerfulness

* increase reluctance to decompose calibrated gates

* change .basis slot to ._decomposers

* my local linter thinks everything is fine :/

* add some U3 special cases

* make black happy

* fix a claimed circular import

* add a couple more rewrite tests

* satisfy black

* avoid lambda = ± pi in 1Q KAK

* optimize on strict length

* more thorough gate elision during 1Q synthesis

* respond to most of Lev's feedback

* add an 'allow_non_canonical' parameters

* normalize K rolls

* Update qiskit/quantum_info/synthesis/one_qubit_decompose.py

Co-authored-by: Lev Bishop <18673315+levbishop@users.noreply.github.com>

* Update qiskit/quantum_info/synthesis/one_qubit_decompose.py

Co-authored-by: Lev Bishop <18673315+levbishop@users.noreply.github.com>

* add some Euler special case tests for pushing a K(pi) through an A(alpha)

* add some Euler special case tests for pushing a K(pi) through an A(alpha)

* Update one_qubit_decompose.py

a by-hand attempt at reformatting the docstring

* ok linter

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Lev Bishop <18673315+levbishop@users.noreply.github.com>
2021-07-07 06:01:25 +00:00
Julien Gacon 09f9c10daa
Fix ``QuantumCircuit.assign_parameters`` docstring (#6546)
* Fix docstring of assign_parameters

and remove the deprecated arguments, as they have been deprecated > 3months ago

* add reno

* lint

* lint

* lint!

Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-07 01:19:51 +00:00
Matthew Treinish 40d7ee24f1
Revert "Performance improvement for Collect2qBlocks (#6534)" (#6686)
Since this #6534 merged we've seen a spike in test failures with
test_transpile_across_optimization levels where the transpile fails to
stabilize on a fixed depth. While we haven't confirmed the root cause of
the failure to be #6534 given the proximity to the release, the relative
timing adds up. The performance improvement the PR made was good, but
not critical as collect_2q_blocks is hardly ever a bottleneck. Given the
proximity to the 0.18.0 release this commit reverts #6534 to try and
relieve pressure on CI. We can reinvestigate adding this back after the
0.18.0 release.

The test that is failing is being improved in #6685 to isolate the test
methods to one for each optimization level. This will hopefully let us
debug the failure more easily when we re-apply #6534

This reverts commit 3bb72d340f.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-06 23:10:14 +00:00
Ali Javadi-Abhari 1270f7c8ad
Add dynamical decoupling transpiler pass (#6619)
* add DD pass

Co-authored-by: Lauren Capelluto <lcapelluto@users.noreply.github.com>

* docstrings + use dag._copy_circuit_metadata

* move pass under passes/scheduling

* add test

* add balanced spacing of pulses

* reno

* add XY4 test

* lint

* review comments

* duration and unit updated with the rest of dag metadata

* lint

* Update qiskit/transpiler/passes/scheduling/dynamical_decoupling.py

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

* add circuits diagrams to test docstrings

* fix equiv check

* add spacing option

* add example of unbalanced spacing

* rebase

* Update qiskit/transpiler/passes/scheduling/dynamical_decoupling.py

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

* add another example to docstring

* matt review

* lint

* fix docs

* last review

Co-authored-by: Lauren Capelluto <lcapelluto@users.noreply.github.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-06 20:09:32 +00:00
Drew e9f06e457b
Pulse: fix minor docstring errors (#6288)
* pulse (transforms): fix pad() docstring formatting

The code sections were extending past ``Delay`` when viewed on the
Qiskit documentation website.

* pulse: fix utilities example

Didn't print the number of qubits at all, as it was clearly designed to.

* pulse (ScheduleBlock): format class docstring

Alignment contexts were not displaying as unique list items, due to
malformatted leading whitespace (leading whitespace for RST lists
should start at the same character as the start of the first list item
line).

* pulse (ScheduleBlock): format class docstring

Fix issues with RST not interpreting the end of interpreted blocks,
and a minor typo.

Co-authored-by: Thomas Alexander <thomasalexander2718@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-06 17:48:39 +00:00
Zoufalc 34b8079844
Add Expectation Converter to Gradient Wrapper (#6274)
* include Expectation Converter in gradient_wrapper

* update gradient test

* update test

* Try fix lint & sphinx

* include Reno, update gradient tests

* fix lint

* Update test/python/opflow/test_gradients.py

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

* Update test/python/opflow/test_gradients.py

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

* Update test/python/opflow/test_gradients.py

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

* more detailed reno

* fix unittest problem gradients

* fix unittest gradients

* set seeds, set specific tolerances

* black

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-06 13:59:58 +00:00
Hiroshi Horii 649fec2cd1
fix bug in layout deletion (#6683) 2021-07-06 07:19:57 +00:00
Tharrmashastha SAPV 15edb0bc4c
Classical condition boxes are now drawn as bullets in text drawer (#6370)
* Classical conditional boxes changed to bullets

* Added condition value in circuit diagram and added tests

* Added reno

* Update change-clcond-boxes-to-bullets-2f1799fc23793929.yaml

* Fixed reverse bits and added tests

Co-authored-by: Edwin Navarro <enavarro@comcast.net>

* Update reno

* Fixed lint

* Refactored #5938

Co-authored-by: Edwin Navarro <enavarro@comcast.net>
Co-authored-by: Abby Mitchell <abby.mitchell@btinternet.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-02 16:43:22 +00:00
Naoki Kanazawa 3e1ca64687
Add align measure pass (#6673)
* add new pass

Co-authored-by: Toshinari Itoko <itoko@jp.ibm.com>

* add pass to transpiler

* fix getter bug

* black & lint

* review comments
- change argment ordering
- update docstring
- move pass adding to each level function
- add circuit drawings to test
- avoid calling other passes from pass

* Update qiskit/transpiler/passes/scheduling/align_measures.py

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

* Update test/python/transpiler/test_align_measure.py

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

* Update test/python/transpiler/test_align_measure.py

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

* minor update to comment

* fix unittest

* add pulse gate validation with alignment

* black & lint

* add reno

* Update releasenotes/notes/add-alignment-management-passes-650b8172e1426a73.yaml

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

* Update test/python/transpiler/test_instruction_alignments.py

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

* Update test/python/transpiler/test_instruction_alignments.py

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

* Update test/python/transpiler/test_instruction_alignments.py

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

* Update qiskit/compiler/transpiler.py

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

* fix delay node returns none

* add more docstring

* drop redundant validation

* add comment about logic

Co-authored-by: Toshinari Itoko <itoko@jp.ibm.com>

* fix alignment missing bug

* Update qiskit/compiler/transpiler.py

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

* fix transpiler argument parser bug

Co-authored-by: Toshinari Itoko <itoko@jp.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-02 14:42:56 +00:00
Julien Gacon 0d9cf38a8c
Add settings property to optimizer classes in ``qiskit.algorithms.optimizers`` (#6545)
* serialize (most) optimizers + test

* reduce duplicated code

* support any iterator in serialization

by converting the learning rates to arrays. This also means we don't need an additional module for iteratos

* test iterators being arrays

* serialize rest of the optimizers

* add reno

* fix lint

* missed return type

* lint

* move from_dict to Optimizer only

* add more tests

- on invalid names
- on initializing QNSPSA w/o "fidelity"

* rename to_dict to settings

and move all the construction logic to Optimizer.from_dict

* fix tests & lint

* try fixing tests

* lint!

* rm name from settings

* include callback & lse_solver in settings

* forgot to black

* update docstring & reno

* fix lint

* add safeguard to GSLS settings

* don't deprecate setting for now

* implement settings for nlopts

* don't make settings abstract

for bkwd compat

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-02 12:55:08 +00:00
Christopher J. Wood cea50ed6f3
Move `Gate.label` to parent `Instruction` class (#6626)
* Move `Gate.label` to parent `Instruction` class

* Add label kwarg to `QuantumCircuit.to_instruction`

* black

* Fix Snapshot label

* fix lint errors

* Run CI to update Aer

* Add temp fix for aer tests

* black

* Update qiskit/circuit/instruction.py

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

Co-authored-by: Kevin Krsulich <kevin@krsulich.net>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-01 19:46:07 +00:00
Matthew Treinish 927fd0226b
Make tweedledum a hard requirement (#6588)
* Make tweedledum a hard requirement

This commit switches the tweedledum requirement from being optional to a
hard requirement for installing qiskit-terra. We rely on tweedledum to
synthesize phase oracles which is commonly used functionality and several
issues have been opened. This use of tweedledum will likely continue to
grow so we should just list it as a requirement moving forward.

We originally made it optional because the functionality depending on
tweedledum was isolated to just the classical function compiler which
wasn't widely used. There were also packaging issues in the past where
the available precompiled binaries for tweedledum didn't support all of
our supported environments, but those have been resolved. There is still
an issue for arm64 macOS binaries but Qiskit doesn't have wide support
for that yet (although there is a job for terra).

At the same time this commit cleans up the optional requirements list
so that aer is no longer listed there and we add an 'all' extra so that
people can have a simple entypoint to install all the optional extras at
once.

Fixes #6333
Fixes Qiskit/qiskit#1253

* Remove unused imports

* Cleanup docstrings

* black setup

* Update requirements.txt

Co-authored-by: Bruno Schmitt <bruno.schmitt@epfl.ch>

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: Bruno Schmitt <bruno.schmitt@epfl.ch>
2021-07-01 14:46:56 +00:00
Tharrmashastha SAPV 8c062c7772
Fixed qc.num_connected_components() for circuits with bit conditioned gates (#6564)
* Fixed num_connected_components

* Added tests and reno

* Fixed num_conn_comp for bit cond with tests.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
2021-07-01 08:56:11 +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 80ea8fe7f3
Replace SnapshotExpectationValue with SaveExpectationValue (#6593)
* replace SnapshotExpectationValue with SaveExpectationValue

* remove unnecessary test

* remove releasenote

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-01 04:10:22 +00:00
Caleb Clothier b3ae1cd700
Fixed issue 6623 by raising errors for negative delay durations (#6625)
* Fixed issue 6623 by raising errors for negative delay durations

* Fixed issue 6623 by raising errors for negative delay durations

* Updated solution to issue 6623 to raise errors for negative bound parameters and added test cases

* Fixed issue 6623 by raising errors for negative Delay gate durations, and adding appropriate test cases to test_delay.py

* Added tests

Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-07-01 02:34:20 +00:00
Steve Wood 6c08d4bfe0
Fix for "Add Operator Settings #6650" (#6670)
* Fix for "Add Operator Settings #6650"

* Fix lint
2021-07-01 00:14:41 +00:00
Jessie Yu 6819cc07c1
Add operator settings (#6650)
* add settings

* add ListOp

* add settings in OperatorBase

* review comments

* make ListOp settings generic

* make ListOp serializable if default combo_fn

* fix combo_fn usage

* fix lint

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-06-30 17:47:20 +00:00
Matthew Treinish a330ca3dae
Add string parameter handling to QPY (#6662)
* Add string parameter handling to QPY

This commit adds string parameter handling to the qpy serialization
format. The PauliGate generalized gate class uses pauli strings as a
parameter to the constructor. If there was a PauliGate in the circuit
the qpy serialization would fail because the string parameters weren't
handled. This commit fixes that by adding string as an allowed type for
qpy parameters.

To fix the reported issue of PauliGate serialization with qpy though the
PauliGate class needs to be exported in the __init__.py for the
qiskit.circuit.library path. Without this qpy doesn't know about the
special PauliGate constructor that allows strings and tries to treat it
as a normal custom gate which will fail when trying to create it with a
string parameter.

Fixes #6660

* Update qiskit/circuit/qpy_serialization.py

Co-authored-by: Kevin Krsulich <kevin@krsulich.net>
Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com>
2021-06-30 13:07:25 +00:00
Naoki Kanazawa dbbb4b65d0
fix format logic (#6664) 2021-06-30 07:56:26 -03:00
Ikko Hamamura 434261f076
Improve the performance of AerExpectationValue (#6629)
* remove unnecessary measurement

* fix wrong test

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-06-29 20:44:02 +00:00
Christopher J. Wood 89c4f6eb5c
Add PauliList class (#5993)
* Add PauliList class

* Fix some rebase errors

* Start adding tests

Co-authored-by: ikkoham <ikkoham@users.noreply.github.com>

* Complete test of PauliList

* Fix type in random_pauli_list

* add from_symplectic and docs

* fix lint and add test for random_pauli_list

* reflect the review

* Add release note

* fix evolve_clifford

* add more test cases

Co-authored-by: ikkoham <ikkoham@users.noreply.github.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2021-06-29 15:51:49 +00:00
Matthew Treinish a2cc56f82e
Remove unused and broken Make.bat script (#6654)
This commit removes the unused Make.bat file. This file was originally
added to provide a similar entrypoint to the makefile for windows users
that do not have automake installed. However, it hasn't really been
updated in some time and also has many issues in (like missing targets
and a hard dependency on conda). Since it clearly isn't used and hasn't
been updated this commit just removes the script. Using tox is a much
more viable solution for windows developers that do not have automake
as it handles everything this script was trying to do but is up to date
and works with any python env.

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
2021-06-29 06:52:49 +00:00
Matthew Treinish 98ef1ca180
Fix calibration handling of transpiler passes on gates with >2 qubits (#6655)
This commit fixes an issue in a couple of transpiler passes where a
multiqubit gate on >2 qubits that has a custom calibration. When a gate
has a calibration it should mostly be treated as a black box because the
pulse definition is passed directly to the backend for that gate.
However, previously for passes that worked on gates > 2 qubits weren't
correctly handling this which would result in an error. This has been
fixed so that if a multiqubit gate is in a circuit with a calibration
set it will be left as a black box and passed directly to the backend.

Fixes #6572
2021-06-28 14:29:29 -04:00
Bruno Schmitt 3bb72d340f
Performance improvement for Collect2qBlocks (#6534)
* This pass can collect block in a single sweep.

There is no need to mark nodes as seen nor to visit successor and
predecessors to collect the blocks.  This commit significantly improves
performance. (IMHO it also greatly simplifies the implementation)

* Remove unnecessary 'continue' after if/else

* Update doc and remove useless test

* Update doc

* Update qiskit/transpiler/passes/optimization/collect_2q_blocks.py

Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.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>
2021-06-28 11:53:39 +00:00
Ikko Hamamura 4c6a0f3e7b
fix 6547 (#6562)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2021-06-26 09:25:05 +00:00
Luciano Bello 10468e6434
Add support for faulty directed gate (#6407)
* support for faulty directed gate

* blacking

* ups

* ups

Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-06-26 04:42:25 +00:00
Luciano Bello f3ee10d151
Delay support when loading from QASM2 (#6594)
* map QASM delay to Delay object

* adding test

* reno

* blacking

Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-06-26 01:57:08 +00:00
Edwin Navarro 33dca140e1
Move gate, control, and param label selections from 3 circuit drawers to utils (#6078)
* Initial move get_gate_ctrl_text to utils

* Add get_gate_ctrl_text to mpl and text

* Update text drawer labels

* Finish text selection and first mathrm try on mpl

* Modify json style files to match default and testing

* Fix text tests 1

* Final testing and cleanup

* Moved param parsing to utils.py for 3 drawers

* Adjust param display

* Update ndigits to current defaults in get_param_str

* Fix mathrms and update style docs

* Fix image refs

* Add user name formatting to mpl and latex drawers

* Lint

* Update more references

* Add user name and label color selection

* Comments and doc

* Fix merge conflicts and testing

* Remove import copy from qcstyle

* Fix Boolean name in latex

* Add BooleanExpression test

* Fix math mode minus

* Test utils merge

* Format all visualization

* Three reformats

* Fix fmt off for black

* Lint

* Update ref images

* Fix wide_params and json files

* Update ref images

* Update 2 latex refs

* Lint

* Added release note

* Updated text drawer and tests for first letter caps

* Lint

* Fix color issue

* Add user label displaytext and displaycolor to user_style image

* Fix text drawer tests after main merge

* Unused imports

* Change op/instruction to node is 3 drawers

* Lint

* Update some docs

* Add some f-strings

* Lint

* Start merge conflict resolution

* Update latex ref files

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-06-26 00:42:24 +00:00
Matthew Treinish e71c53b0c7
Add option to sort by values to plot_histogram (#6592)
* Add option to sort by values to plot_histogram

This commit adds new sorting options for the sort kwarg to the
plot_histogram function, 'value' and 'value_desc', to adjust the order
of the x axis based on the counts for a particular bitstring.

Fixes #6591

* Use max instead of sum

* Run black

* Add release note

* Update docstring

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-06-25 23:26:55 +00:00
Luciano Bello 8f07356ff3
Deprecate the QiskitIndexError exception class (#6642)
* QiskitIndexError deprecation

* Update qiskit/exceptions.py

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

* reno

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-06-25 19:12:40 +00:00
Luciano Bello 6eb8d6605c
Fix in Register.__getitem__ docstring (#6639)
* raise the correct exception (QiskitIndexError) when register index out of range

* docstring
2021-06-25 16:02:29 +00:00
Luciano Bello 1b3aa3995f
%qiskit_version_table with domain specific apps (#6589)
* qiskit_version_table with domain specific apps

* code packages

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-06-25 12:17:36 +00:00
Luciano Bello cf4005ff9f
Removing pending TODO blocked by #3304 (#6638) 2021-06-25 09:03:31 +00:00