Commit Graph

1312 Commits

Author SHA1 Message Date
Abby Mitchell 2ba298481a
Added classical_predecessors method (#9980)
* Added classical_predecessors method

* add accesed method

* Added classsical_successor method

* Added classical predecessors and successors method

* added tol command

* successors method

* add test classical_successor method

* changed DagOutNode

* Apply suggestions from code review from @atharva-satpute. Thanks!

Co-authored-by: atharva-satpute <55058959+atharva-satpute@users.noreply.github.com>

* add assertRaises on test methods

* correct typo variable name

* change the descrption

* change the text on the example

* change the format of yaml

* new example

* new suggestions

* fix test

* new test example and change the release note

* Fixup release note

* Fix typo

---------

Co-authored-by: Maldoalberto <amaldonador1300@alumno.ipn.mx>
Co-authored-by: Maldoalberto <Alberto.Maldonado.Romo@ibm.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: atharva-satpute <55058959+atharva-satpute@users.noreply.github.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2023-06-20 16:35:49 +00:00
daniel-fry f9958143eb
Allow to normalize inputs on ``StatePreparation`` and ``Initialize`` (#7189)
* added normalize func

* remove typecheck

* changed to handle numpy arrays and lists both with complex numbers

* Corrected docstring for normalization function

* Add files via upload

* initializer.py normalize function

* fix line endings

* addressing edits in docstrings and normalize function

* review comments

* attempt 1 to fix sphinx

* add reno and improve error message

* fix passing normalize to stateprep

* Fixup PR

---------

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2023-06-20 15:38:39 +00:00
Artemiy Burov 9ef34b7a46
Add more 1q and 2q Pauli rotation equivalences (#7407)
* added rx to equevalence library

* fixed sign in ry_to_rx

* added rzz to rxx

* gate correction

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

* added ryyrzz, rxxrzz, rzzryy translations, fixed ryrx translation to a more logical variant

* fixed errors

* Add Ryy to Rxx equivalence

* Add release note

---------

Co-authored-by: artemiyburov <artemiy.v.burov@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2023-06-20 15:17:17 +00:00
Elena Peña Tapia 93a8172c3c
Fix VQD's `optimal_values` (#10279)
* Fix optimal values

* Add unittest

* Add reno

* Update unittest

* Revert "Update unittest"

This reverts commit 5000d2fb02.

* Update test

* Make test subtest
2023-06-20 08:25:59 +00:00
Matthew Treinish c1866956b2
Remove deprecated InstructionSet circuit_cregs argument (#10302)
This commit removes the deprecated circuit_cregs argument from the
InstructionSet class. This argument was deprecated in the 0.19.0
release and has been supersceded by the resource_requester.
2023-06-16 20:52:01 +00:00
Jake Lishman 45a1d98802
Add standard 1q Pauli equivalences to standard library (#10300)
* Add standard 1q Pauli equivalences to standard library

This makes `transpile` a little more reliable in cases where people are
trying to use it to convert to a constrained basis.  We can't
necessarily recognise _all_ possible transformations into an incomplete
basis, but simple Pauli relations are things people may well expect.

* Fix test setup
2023-06-16 12:50:44 +00:00
Alexandre 5f271bd480
Fix qasm export for gates with same name (#10286)
* added test for inner sequencial custom gates

* fixed quantum circuit qasm test

* fixed qasm method

* added a function to rename the operation

* updated test docstring

* updated recheck operation.name comment

* eblack fix test

* added docs

* lint test

* updated test string format

* Fixup release note

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2023-06-15 23:25:23 +00:00
Jake Lishman 81964e6499
Fix deprecation warnings emitted by `import qiskit.primitives` (#10287)
The primitives still need to support the legacy
`qiskit.opflow.PauliSumOp` while that object is deprecated but not
removed.  However, we do not want the import of `qiskit.primitives` to
need to import `opflow` to do that, since that will cause the
deprecation warnings emitted by the import of `opflow` to be hidden
(they'll be blamed on Qiskit library code, so hidden by default).

All type-hint usage we can hide behind the `TYPE_CHECKING` static
analysis gate.  For cases where we were actively runtime type-checking
an object, we can gate the `isinstance` check behind a check that
`qiskit.opflow` is already imported; the object cannot be a `PauliSumOp`
if the module isn't initialised.
2023-06-15 13:09:52 +00:00
Evan McKinney 7df290b8f3
Fix BasicSwap FakeRun Typo (#10274)
* fix typo, issue #10147

* create basicswap fake_run test

* release note for #10149 fix

* ensure fake_run modifes layout prop, not the circuit logic

* black formatting, test_basic_swap
2023-06-14 10:24:33 +00:00
Jake Lishman 86df15d3b9
Improve casting and error message for `ParameterExpression` (#10244)
* Improve casting and error message for `ParameterExpression`

Previously, we assumed that the only reason a cast of
`ParameterExpression` to `complex`/`float`/`int` could fail was because
of unbound parameters, and emitted an error accordingly.  This is not
the case; a fully bound complex value will still fail to convert to
`float`.

This PR improves the error messages in these cases, and works around a
difference of Sympy and Symengine, where the latter will fail to convert
real-valued expressions that were symbollically complex at some point in
their binding history to `float`.  Sympy more reliably reduces values
down to real-only values when the imaginary part is exactly cancelled,
which is a use-case our users tend to expect.

* Fix typo in test

* Update releasenotes/notes/parameter-float-cast-48f3731fec5e47cd.yaml

Co-authored-by: Kevin Hartman <kevin@hart.mn>

---------

Co-authored-by: Kevin Hartman <kevin@hart.mn>
2023-06-12 18:08:20 +00:00
Kento Ueda a1615a864f
Dispatch a builder with backendV1 and backendV2 (#10150)
* fix measure_v2

* modify measure_all

* dispatch backend

* add test of the builder with backendV2

* reconfigure test codes and some func

* refactoring

* add reno

* fix _measure_v2

* fix backend.meas_map in measure_v2

* fix reno

* delete get_qubit_channels from utils

* add get_qubits_channels in qubit_channels

* recostruct test about the builder with backendV2

* fix descriptions of test_macros

* fix descriptions of test_macros again

* delete import of backendV2 in utils

* revert no need to modify code

* Update releasenotes/notes/fix-dispatching-backends-28aff96f726ca9c5.yaml

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* Update a commnet in qiskit/pulse/builder.py

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* remove import TYPE_CHECKING

* removed test_builder.py utils.py and test_analyzation.py from pull request

---------

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
2023-06-12 16:17:23 +00:00
Matthew Treinish c463b3c474
Use stable Python C API for building Rust extension (#10120)
* Use stable Python C API for building Rust extension

This commit tweaks the rust extension code to start using the PyO3 abi3
flag to build binaries that are compatible with all python versions, not
just a single release. Previously, we were building against the version
specific C API and that resulted in needing abinary file for each
supported python version on each supported platform/architecture. By
using the abi3 feature flag and marking the wheels as being built with
the limited api we can reduce our packaging overhead to just having one
wheel file per supported platform/architecture.

The only real code change needed here was to update the memory
marginalization function. PyO3's abi3 feature is incompatible with
returning a big int object from rust (the C API they use for that
conversion isn't part of the stable C API). So this commit updates the
function to convert to create a python int manually using the PyO3 api
where that was being done before.

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

* Set minimum version on abi3 flag to Python 3.8

* Fix lint

* Use py_limited_api="auto" on RustExtension

According to the docs for the setuptools-rust RustExtension class:
https://setuptools-rust.readthedocs.io/en/latest/reference.html#setuptools_rust.RustExtension
The best setting to use for the py_limited_api argument is `"auto"` as
this will use the setting in the PyO3 module to determine the correct
value to set. This commit updates the setup.py to follow the
recommendation in the docs.

* Update handling of phase input to expval rust calls

The pauli_expval module in Rust that Statevector and DensityMatrix
leverage when computing defines the input type of the phase argument as
Complex64. Previously, the quantum info code in the Statevector and
DensityMatrix classes were passing in a 1 element ndarray for this
parameter. When using the the version specific Python C API in pyo3 it
would convert the single element array to a scalar value. However when
using abi3 this handling was not done (or was not done correctly) and
this caused the tests to fail. This commit updates the quantum info
module to pass the phase as a complex value instead of a 1 element numpy
array to bypass this behavior change in PyO3 when using abi3.

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

* Set py_limited_api explicitly to True

* DNM: Test cibuildwheel works with abi3

* Add abi3audit to cibuildwheel repair step

* Force setuptools to use abi3 tag

* Add wheel to sdist build

* Workaround abiaudit3 not moving wheels and windows not having a default repair command

* Add source of setup.py hack

* Add comment about pending pyo3 abi3 bigint support

* Revert "DNM: Test cibuildwheel works with abi3"

This reverts commit 8ca24cf1e4.

* Add release note

* Simplify setting abi3 tag in built wheels

* Update releasenotes/notes/use-abi3-4a935e0557d3833b.yaml

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

* Update release note

* Update releasenotes/notes/use-abi3-4a935e0557d3833b.yaml

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Co-authored-by: Jake Lishman <jake@binhbar.com>
2023-06-12 13:45:27 +00:00
Daniel J. Egger b36609befd
FullAncillaAllocation for backends witout a coupling map (#10240)
* * Added support for targets without a coupling map.

* * Removed restrictive raise.

* * Changed order of target and coupling map

* Apply suggestions from code review

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

---------

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2023-06-09 18:59:25 +00:00
Kento Ueda f91136654b
Fix the output macros.measure with backendV2 (#10135)
* fix measure_v2

* modify measure_all

* fix meas_map input in measure_v2

* add reno

* fix reno

* Update reno.

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* fix reno again

---------

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
2023-06-07 11:29:01 +00:00
Junya Nakamura 2d8300c834
Support instruction filtering method in ScheduleBlock class (#9971)
* activate filter method in ScheduleBlock class

* use functools.singledispatch

* add tests for filter method in ScheduleBlock class

* filter out empty schedule_blocks

* update doc

* rm logical_and

* add catch-TypeError functions decorated with singledispatch

* use pulse builder in test

* make another test function for nested block

* add a release note

* Rm optional args

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* add warning

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* update the release note

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* activate exclude method in ScheduleBlock class

---------

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
2023-06-07 11:03:04 +00:00
Mu-Te Joshua Lau 84d13d7795
Fix QuantumCircuit.draw() not outputting pdf in latex mode (#10212)
* Fix QuantumCircuit.draw() not outputting pdf in latex mode

* Added bugfix release note; moved import to the top

* Fixup release note

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2023-06-06 15:29:43 +00:00
Diego Emilio Serrano 6f29d7be78
Fix output of `DensityMatrix.partial_transpose` to match input dimensions (#10163)
* (fix) change output of partial_transpose to return DensityMatrix matching input dimensions

* (test) check output dims match input dims when using DensityMatrix.partial_transpose

* (docs) add bugfix reno

* lint changes

* Fix up release note

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2023-06-06 13:49:28 +00:00
Will Shanks 332bd9fe0b
Assign values directly to fully bound parameters in quantum circuits (#10183)
* Assign circuit parameters as int/float to instructions

* Do not test that fully bound parameters are still ParameterExpressions

* Change int to float in qasm output

pi_check casts integers to floats but not integers inside
ParameterExpressions.

* Workaround symengine ComplexDouble not supporting float

* black

* Update releasenotes/notes/circuit-assign-parameter-to-concrete-value-7cad75c97183257f.yaml

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

* Update releasenotes/notes/circuit-assign-parameter-to-concrete-value-7cad75c97183257f.yaml

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

* Restore assigned parameter value type check to tests

* Add test to check type and value of simple circuit parameter assignment

* Add consistency check between assigned instruction data and calibrations dict keys

* Add regression test

* Add upgrade note

* Remove support for complex instruction parameter assignment

* Restore complex assignment

Complex assignment maybe not be supported but allowing it in the
parameter assignment step lets validate_parameters get the value and
raise an appropriate exception.

* black

* More specific assertion methods

* Use exact floating-point check

---------

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2023-06-01 19:00:25 +00:00
John Lapeyre 174b661d57
Fix unitary synthesis for parameterized basis gates in Target (#10090)
* Fix unitary synthesis for parameterized basis gates in Target

Replace parameterized RXX with RXX(pi / 2) and parameterized RZX with RZX(pi / 4).

* Run black

* Fix dict ordering problem between linux and windows

* Remove unused import

* Try using seed in call to transpile to fix CI fail

Linux and MacOS give one result and Windows another

* Add comments explaining no symbolic gates can be sent to 2q decomposers

* Make test for synthesis in with parameterized basis gate less strict

Windows on the one hand, and MacOS and Linux on other give different circuits
in a simple test of synthesis. Both are correct. This commit makes the test less strict.

* Add release note for fix-issue-10082
2023-06-01 13:17:20 +00:00
Matthew Treinish 4762e26708
Fix PassManagerConfig.from_backend with BackendV1 and no CouplingMap (#10172)
* Fix PassManagerConfig.from_backend with BackendV1 and no CouplingMap

This commit fixes an issue in the PassManagerConfig.from_backend
constructor method when using BackendV1 based simulator backends. The
pass was incorrectly handling the case when the backend configuration
didn't have a coupling map defined and incorrectly creating a coupling
map with 0 qubits instead of using None to indicate the lack of
connectivity. This has been fixed so the coupling map creation is
skipped if there is no coupling map attribute in the backend's
configuration.

Fixes #10171

* Fix tests
2023-05-30 17:21:47 +00:00
Jake Lishman 76850e1fdf
Fix top-level `switch` statements in `QuantumCircuit.compose` (#10164)
* Fix top-level `switch` statements in `QuantumCircuit.compose`

The register-mapping code was not being applied to `SwitchCaseOp.target`
in the same way that it is for conditions.  This commit does not change
any behaviour about recursing into _nested_ control-flow blocks, which
still likely have problems with composition.

* Apply suggestions from review
2023-05-30 16:33:06 +00:00
Alexander Ivrii 788b89d985
Fixing BlockCollapser with Clbits (#9823)
* Bug fix: collapsing blocks with clbits

Co-authored-by: chriseclectic <cjwood@us.ibm.com>

* release notes

* similar fix to DAGDependency

* additional fixes to handle classical bits in conditions

* fixing lint issue

* Fixing handling of conditions over full registers, following review comments

---------

Co-authored-by: chriseclectic <cjwood@us.ibm.com>
2023-05-26 18:49:15 +00:00
Jake Lishman 716b648cb9
Fix `initial_layout` in `transpile` with loose qubits (#10153)
The previous logic around building a `Layout` object from an
`initial_layout` was still couched in the "registers own bits" model, so
could not cope with loose bits.  It's most convenient to just build the
mapping ourselves during the parsing, since the logic is quite specific
to the form of the `initial_layout` argument, rather than being
something that's inherently tied to the `Layout` class.
2023-05-24 19:31:30 +00:00
Evgenii Zheltonozhskii 02502b5d98
Remove undefined variable (#10117)
* Remove undefined variable (fix https://github.com/Qiskit/qiskit-terra/issues/10113)

* Add test and bugfix description
2023-05-24 12:28:01 +00:00
Adenilton Silva 7b677edf15
Fix wrong relative phase of MCRZ (#9836)
* efficient multicontrolled su2 gate decomposition

Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com>
Co-authored-by: IsmaelCesar <leamscesar@gmail.com>
Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com>
Co-authored-by: Adenilton Silva <7927558+adjs@users.noreply.github.com>

* removed optimization flag

Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com>
Co-authored-by: IsmaelCesar <leamscesar@gmail.com>
Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com>
Co-authored-by: Adenilton Silva <7927558+adjs@users.noreply.github.com>

* tox -eblack

* updated docstrings

* Adds `MCSU2Gate` to `__init__`

* fixed circular import

* defined control and inverse methods

* changed MCSU2Gate from Gate to ControlledGate

* adjusted some tests for controlled gates

* reformatting

* Fix regarding the integer `ctrl_state` parameter

* Tests to check the CX count upper bound

* Gate's `label` in the `control` function

* Upd. Qiskit tests to include cases for MCSU2Gate

* Upd. Qiskit tests to include cases for MCSU2Gate

* Revert "Upd. Qiskit tests to include cases for MCSU2Gate"

This reverts commit c1ceaf6b28.

* Revert "Upd. Qiskit tests to include cases for MCSU2Gate"

This reverts commit 7c756111a3.

* Revert "Tests to check the CX count upper bound"

This reverts commit 100a690c3a.

* Update test_controlled_gate.py

* Update test_circuit_operations.py

* remove mcsu2gate class

* remove mcsu2gate class

* fix mcry

* lint

* fix mcrx

* add reference

* Create `s_gate` directly

* Revert "Create `s_gate` directly"

This reverts commit b762b39342.

* review

* release notes

* review 2

* backwards compat

* function signature and number of controls

* fix mcrz

* Update multi_control_rotation_gates.py

* review

* Update test_qpy.py

* Revert "Update test_qpy.py"

This reverts commit fab1c80ab4.

* Update test_qpy.py

* Update multi_control_rotation_gates.py

* Fix `use_basis_gates=True` case

* lint

---------

Co-authored-by: rafaella-vale <26910380+rafaella-vale@users.noreply.github.com>
Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com>
Co-authored-by: IsmaelCesar <leamscesar@gmail.com>
Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com>
Co-authored-by: Rafaella Vale <rfv@cin.ufpe.br>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
2023-05-22 13:49:37 +00:00
Matthew Treinish 9f647c7e42
Fix tweedledum runtime detection in BooleanExpression.from_dimacs_file (#10132)
This commit fixes an oversight in the 0.24.0 release that caused an
accidental change in the exception raised when attempting to use
BooleanExpression.from_dimacs_file without having tweedledum installed.
In #9754 the detection of tweedledum was updated to avoid import time
detection so that the module can be imported even if tweedledum isn't
installed. This was done through the use of the optionals decorators
so that tweedledum is only attempted to be imported when the
classicalfunction modules is used. However, the decorators don't wrap
classmethod constructors by default and this caused the incorrect
exception type to be raised. This commit fixes this by doing the runtime
checking manually inside the from_dimacs_file constructor.
2023-05-22 07:01:06 +00:00
Mirko Amico bedecbdce5
add gaussian square echo pulse (#9370)
* add gaussian square echo pulse

* address some PR comments

* fixed parameters of symbolicpulse

* adding math description and reference

* change variable names

* fix lint

* remove width_echo parameter

* fix lint

* add release notes

* fix conflicts

* address some PR comments

* fixed parameters of symbolicpulse

* adding math description and reference

* change variable names

* fix lint

* remove width_echo parameter

* fix lint

* add release notes

* Update first paragraph

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* Update amp param to float

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* Update angle def param to float

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* Update amp constrain

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* drafting tests

* update docstring

* finish up test

* fix missing pulses from init

* addding Cos

* missing sin

* fixed tests

* black formatting

* break string

* fixing strings

* reformatting

* fix lint

* fixing last things

* fix tests

* fix black

* fix another test

* fix amp validation

* fixing docstring

* Update qiskit/pulse/library/symbolic_pulses.py

Co-authored-by: Will Shanks <wshaos@posteo.net>

* rename to gaussian_square_echo

* fix lint

* Update qiskit/qobj/converters/pulse_instruction.py

Co-authored-by: Will Shanks <wshaos@posteo.net>

* Update releasenotes/notes/gaussian-square-echo-pulse-84306f1a02e2bb28.yaml

Co-authored-by: Will Shanks <wshaos@posteo.net>

---------

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
Co-authored-by: Will Shanks <wshaos@posteo.net>
2023-05-20 01:58:45 +00:00
John Lapeyre c3b0afaab2
Deprecate get_vf2_call_limit in preset_passmanagers (#10065)
* Deprecate get_vf2_call_limit in preset_passmanagers

This has been replaced by get_vf2_limits

* Black formatting

* Add release note for #10065
2023-05-19 15:59:25 +00:00
Vicente P. Soloviev 81d38340d1
Allow access to UDMA optimizer history information (#8695)
* fix issue 8687 by moving history attribute tu public by a getter

* callback function

* tests

* add test and reno

* lint

---------

Co-authored-by: Julien Gacon <gaconju@gmail.com>
2023-05-19 15:23:28 +00:00
Kazuki Tsuoka 1d844eccae
add abs method to ParameterExpression (#9309)
* added abs method to parameterexpression

* fixed wrong call in abs function

* changed definition of abs to __abs__

* additionally implemented __le__, __ge__, __lt__, __gt__ operators

* fixed requested features and implemented more tests for __lt__, __gt__

* fixed lint errors in parameterexpression and its tests

* fixed formatting error in docstrings

* removed __lt__ and friends, fixed recommendations

* added more tests for abs function

* fixed lint

* added a releasenote to document change

* mod function & add more tests

* add new line at the end of file

* fix lint

* add alias of __abs__ for doc

* mod test_compile_with_ufunc

* add test

* fix test

* fix test

* fix test

* fix test

* fix test

* Update test_parameters.py

* Update releasenotes/notes/add-abs-to-parameterexpression-347ffef62946b38b.yaml

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

---------

Co-authored-by: Christopher Zachow <christopher.zachow@sva.de>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
2023-05-17 09:41:48 +00:00
Jake Lishman 5177db6e09
Deprecate circuit-library Jupyter magic (#9940)
* Deprecate circuit-library Jupyter magic

This has not been used since the switch away from using
`jupyter-execute` in gh-9346, so is neither maintained nor necessary.
Any improvements to styling should be made to the new paths, not to
these.  These objects were originally intended only for the
documentation so we expect user impact to be minimal, and the objects
are not maintained anyway.

* Correct versions for deprecation

* Add missing import
2023-05-12 15:49:11 +00:00
Kevin J. Sung 06a5b9e00e
define __getstate__ and __setstate__ for OneQubitGateErrorMap (#10092)
* define __getstate__ and __setstate__ for OneQubitGateErrorMap

* add test

* fix test docstrings

* add assert in test

* add release note
2023-05-10 12:12:26 +00:00
Luciano Bello 7a215f97c4
Add the `qubit_coordinates_map` for `ibm_seattle` (#10089)
* add ibm_seattle qubit_coordinates_map

* Update releasenotes/notes/433_qubit_coordinates_map-8abc318fefdb99ac.yaml

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

---------

Co-authored-by: Kevin Krsulich <kevin@krsulich.net>
2023-05-09 20:56:22 +00:00
Jim Garrison 5ee7ff24ce
Remove deprecated import location `qiskit/util.py` (#10088)
This is a follow up to #7212
2023-05-09 20:01:47 +00:00
Jake Lishman b6fdb19da4
Switch `QuantumCircuit.from_qasm_str` and `from_qasm_file` to new parser (#9955)
This uses the extensibility and the legacy compatiblity data in the new
Rust OpenQASM 2 parser to switch over the old `QuantumCircuit`
constructor methods to the new parser.  This gives users of these
methods large speedups while maintaining the same feature set (and
fixing a long-standing bug surrounding `U` and `CX`!).

One test is removed for the circuit methods; the circuit methods are set
to use `strict=False` mode of the new parser, which is more permissive,
including making the empty string an allowable program.  The alternative
was to set `strict=True`, which would have made an unrelated test in
`SabreLayout` fail instead due to its slightly improper use of
floating-point values in OpenQASM 2 (the OQ2 spec technically requires
decimal points even in constructs like `1e3`, unlike other languages).
Given that the previously OQ2 importer allowed these floats, it seemed
safer to use `strict=False` mode, which is also generally more
convenient for users.

The tests for the old paths are copied, to ensure they continue working
during their potential deprecation and removal.
2023-05-09 15:05:53 +00:00
Matthew Treinish 0e44c5e380
Fix interaction graph vf2 scoring to include 1q component (#10084)
* Fix interaction graph vf2 scoring to include 1q component

In #9148 a bug was introduced into the vf2 scoring code. In that PR the
vf2 passes were changed to treat standalone qubits as a special case to
improve the algorithmic efficiency of the pass. However, that PR
broke the scoring algorithm so that it was no longer factoring in the 1q
component of the interaction graph when scoring a layout. This meant
that when scoring a potential layout only the 2q error rates were been
factored into the score and the pass was potentially selecting worse
performing qubits. This commit fixes this error and ensures the scoring
is looking at all the error rates.

* Update qiskit/transpiler/passes/layout/vf2_utils.py
2023-05-08 14:52:10 +00:00
Jake Lishman 4dfef13085
Drop support for Python 3.7 (#10009)
* Drop support for Python 3.7

This updates our documentation and build processes to set Python 3.8 as
the oldest support version of Python, consistent with our policy on
Python support.

This commit also removes remaining Python-version gating, since we were
principally using this to account for differences between 3.7 and 3.8.
Several backport packages are no longer required for any suppported
Python version, because of this change.

* Remove test for multiprocessing on Mac

With Python 3.7 support now dropped, there are no versions of Python on
macOS that we expect to support with multiprocessing again.  There's no
guarantee that the hypothetical Python 10.11 (???) that this test was
previously checking would be any more valid than existing versions.

---------

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2023-05-05 15:28:34 +00:00
Matthew Treinish 72e7481be8
Undo breaking API change in unitary synthesis plugin interface (#10066)
* Undo breaking API change in unitary synthesis plugin interface

This commit reverts an unecessary breaking API change that was
introduced in #9175. In that PR the data type for two arguments,
gate_lengths and gate_errors, that was potentially passed to
plugins was changed. This change was well intentioned as it was
used by the default plugin as part of the changes to the default
plugin made in that PR. But this neglected the downstream effects
for any existing plugin interface users relying on the input to
those fields. Making this change to existing fields would break
any plugins that were using the old data format and is a violation
of the Qiskit stability and deprecation policy. This commit reverts
that change so that gate_lengths and gate_errors contain the same data
format as in previous releases. Instead to facilitate the new
workflow a new fields, gate_lengths_by_qubit and gate_errors_by_qubit,
were added that leverage the new format introduced by #9175. By adding
this as new optional fields existing users can continue to work as
before, but the default plugin which requires the different data
format can use the new data type.

* Update docstring

* Fix copy paste error
2023-05-03 20:52:41 +00:00
Julien Gacon 08a2b14792
Mark mcsu2 function as private (#10069) 2023-05-03 13:24:20 +00:00
Kevin Hartman f13b1edbfd
Set `max_trials` for `VF2Layout` in preset pass managers. (#10054)
* Set max_trials for VF2Layout in preset pass managers.

By setting max_trials, we limit the number of layouts
enumerated and scored when iterating through vf2_mapping().

This is necessary for scoring to complete in a reasonable
amount of time for circuits with many connected components
on larger (e.g. 400 qubit) devices.

These limits were chosen using a fake 400 qubit device,
using 200 connected components, where each component is
a single CX gate.

Because layout scoring scales linearly
with the number of qubits in the circuit, 250,000 (O3)
takes abount a minute, 25,000 (O2) takes about 6 seconds,
and 2,500 (O1) takes less than a second.

* Address review comments.

* Return tuple of None instead for finer control and a better interface.

* Add deprecation notice to release note.

* Remove deprecation until 0.25.0.

* Remove unused import.
2023-05-02 16:29:40 +00:00
Edwin Navarro 21caf38cde
Remove deprecations from mpl circuit drawer (#10020)
* Remove deprecated args from mpl drawer

* Reno mod
2023-04-27 15:24:12 +00:00
Slope 4df6f3d088
Fix for unintended rounding in 'state_to_latex' latex output (#9300)
* [fix] unintended rounding cause by param max_size

* reformatted

* reformatted

* Deprecated num_to_latex_ket

Replace "numbers_to_latex_terms" with "_numbers_to_latex_terms"

* reformatted
2023-04-27 15:22:53 +00:00
Etienne Wodey 69dc975fde
circuit: narrow the return type of QuantumCircuit.assign_parameters (#10037)
* circuit: add type overload on QuantumCircuit.assign_parameters

* circuit: fix Literal import

* Fixup release note

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2023-04-25 21:46:46 +00:00
Jake Lishman a3aa3aa094
FIx 0q operation handling in `Statevector` (#10031)
The root of the problem was the `OpShape` producing a "vector-like"
shape if it detected that "input size" was 1.  If both the input and
output dimension are 1, it is instead a 0q operator (scalar).
2023-04-25 16:47:35 +00:00
Edwin Navarro 6aa16e497a
Allow decomposing composite gates by name (#9170)
* Fix decompose with a lable or name

* Finish tests and reno

* Lint

* Remove gate arg and fix parens

* Update QuantumCircuit.decompose doc string

* Unused imports
2023-04-25 16:24:23 +00:00
Toshinari Itoko 117d188257
Fix delay padding to respect target's constraints (#10007)
* Add and update tests

* Fix padding passes to respect target's constraints

* Fix transpile with scheduling to respect target's constraints

* Add release note

* fix reno

* use target.instruction_supported

* simplify

* Add check if all DD gates are supported on each qubit

* Add logging

* Update DD tests

* Make DD gates check target-aware

* Fix legacy DD pass
2023-04-25 15:36:47 +00:00
Matthew Treinish 4152009ee6
Set version number to 0.24.0rc1 for first release candidate (#9977)
For the 0.24.0 release we're going to push release candidates
prior to the release to enable testing before we cut the final release.
In preparation for tagging the first release candidate this commit
updates the version string to indicate it's a release candidate. This
commit should be what gets tagged as 0.24.0rc1.
2023-04-20 19:24:00 +00:00
Alexander Ivrii 601bd9a132
Operator apply permutation (#9403)
* adding apply_permutation method to Operator class

* modify from_circuit to use apply_permutation

* declaration fix

* reimplementing based on review suggestions, but missing inversion

* fixing inversion

* fixing front vs back

* adding test for reverse_qargs

* Fixing operator dimensions and adding tests

* Fixing operator dimensions and adding tests

Co-authored-by: Gadi Aleksandrowicz <gadial@gmail.com>

* pylint

* adding tests for one-sided permutations on heterogenous qudit spaces

* improving tests following review

* using ddt

* applying suggestions from review

* applying suggestions from review

---------

Co-authored-by: Gadi Aleksandrowicz <gadial@gmail.com>
2023-04-20 14:15:11 +00:00
Kento Ueda 1203a3b185
Bug fix macros.measure with backendv2 (#9987)
* create measuregrouping class

* add meas_map.setter in MeasureGrouping class

* macros.measure

* get_qubit_groups

* generate_schedule

* target.add_measuregrouping in backend_compat

* target.add_measuregrouping in backend_converter

* reformat and add docs

* on the way of working on generate_schedule_in_measure

* split measure into measure_v1 and measure_v2

macros.py

target

delete raise statement in measure_v2

modify instructions.Acquire to Acquire

* macros.py

* test_measuregrouping

* bug fix schedule with backendV2 for 0.25.0

* modify comments

* fix name of schedule in test_macros

* delete meas_map as a Target attribute

* minor changes in macros.py

* add test to test_macros.py

* make schedule_remapping_memory_slot private

* delete since field from deprecate_arg

* delete deprecate depcorator

* black macros.py

* revert about target

* modify implementation of qubit_mem_slots

* change the definition of meas_group_set

* black macros.py

* fix meas_group_set

* fix qubit_mem_slots

* reno

* modify unassigned_qubit_indices

* remove list() from unassigned_qubit_indices and unassigned_reg_indices
2023-04-20 10:04:44 +00:00
Diego Emilio Serrano 33704ea61f
Fix circuit drawer for instructions with circuit parameters (#9942)
* fix: modify get_param_str to prevent circuit drawer from displaying params of type QuantumCircuit

* fix lint errors

* test: add circuit drawer test for instructions with parameters of type QuantumCircuit

* test: add circuit drawer tests for no parameters and params of type ndarray

* fix lint errors

* remove variable to fix lint error

* add reno

* update releasenotes/notes/fix-circuit-drawer-for-qc-params
2023-04-20 00:48:44 +00:00