Skip to content

Commit 08d6cec

Browse files
committed
Merge remote-tracking branch 'stable/1.3' into 'stable/1.4'
With the release of Qiskit 1.3.3 the stable/1.3 branch should be finished changing at this point. Before we prepare a 1.4.0 release we need to make sure all the backported changes to 1.3 are included in 1.4. This commit merges the contents of the 1.3 branch into the 1.4 branch. The only conflicts were mainly on version numbers because the commits in stable/1.3 including bumping the version strings on new bugfix releases. The one real conflict was in the preset_passmanagers where some of the constructor functions were in filter_warnings context managers and in stable/1.3 the arguments passed to those functions changed. This commit should be merged as a merge commit to preserve the git history. This will require manual intervention at merge time. Conflicts: Cargo.lock Cargo.toml docs/conf.py qiskit/VERSION.txt qiskit/transpiler/preset_passmanagers/builtin_plugins.py
2 parents 71eb989 + c99dd51 commit 08d6cec

File tree

172 files changed

+3029
-1181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+3029
-1181
lines changed

.github/workflows/wheels-build.yml

+3-8
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
os:
9191
- ubuntu-latest
9292
# Used for the x86_64 builds.
93-
- macos-12
93+
- macos-13
9494
# Used for the ARM builds.
9595
- macos-14
9696
- windows-latest
@@ -121,6 +121,7 @@ jobs:
121121
cat >>"$GITHUB_ENV" <<EOF
122122
CIBW_BEFORE_BUILD=bash ./tools/build_pgo.sh $PGO_WORK_DIR $PGO_OUT_PATH
123123
CIBW_ENVIRONMENT=RUSTUP_TOOLCHAIN=stable RUSTFLAGS='-Cprofile-use=$PGO_OUT_PATH -Cllvm-args=-pgo-warn-missing-function'
124+
CIBW_ENVIRONMENT_MACOS=MACOSX_DEPLOYMENT_TARGET='10.12' RUSTUP_TOOLCHAIN=stable RUSTFLAGS='-Cprofile-use=$PGO_OUT_PATH -Cllvm-args=-pgo-warn-missing-function'
124125
CIBW_ENVIRONMENT_LINUX=RUSTUP_TOOLCHAIN=stable RUSTFLAGS='-Cprofile-use=$PGO_OUT_PATH -Cllvm-args=-pgo-warn-missing-function' PATH="\$PATH:\$HOME/.cargo/bin" CARGO_NET_GIT_FETCH_WITH_CLI="true"
125126
EOF
126127
env:
@@ -208,20 +209,14 @@ jobs:
208209
wheels-linux-aarch64:
209210
name: "Wheels / Linux AArch64"
210211
if: (inputs.wheels-linux-aarch64 == 'default' && inputs.default-action || inputs.wheels-linux-aarch64) == 'build'
211-
runs-on: ubuntu-latest
212+
runs-on: ubuntu-24.04-arm
212213
steps:
213214
- uses: actions/checkout@v4
214215
- uses: actions/setup-python@v5
215216
with:
216217
python-version: ${{ inputs.python-version }}
217218
- uses: dtolnay/rust-toolchain@stable
218-
- uses: docker/setup-qemu-action@v3
219-
with:
220-
platforms: all
221219
- uses: pypa/cibuildwheel@v2.21.3
222-
env:
223-
CIBW_ARCHS_LINUX: aarch64
224-
CIBW_TEST_COMMAND: cp -r {project}/test . && QISKIT_PARALLEL=FALSE stestr --test-path test/python run --abbreviate -n test.python.compiler.test_transpiler
225220
- uses: actions/upload-artifact@v4
226221
with:
227222
path: ./wheelhouse/*.whl

DEPRECATION.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Deprecation Policy
22

3-
Starting from the 1.0.0 release, Qiskit follows semantic versioning, with a yearly release cycle for major releases.
3+
Starting from the 1.0 release, Qiskit follows semantic versioning, with a yearly release cycle for major releases.
44
[Full details of the scheduling are hosted with the external public documentation](https://docs.quantum.ibm.com/open-source/qiskit-sdk-version-strategy).
55

66
This document is primarily intended for developers of Qiskit themselves.
@@ -150,11 +150,11 @@ and add the deprecation to that function's docstring so that it shows up in the
150150
```python
151151
from qiskit.utils.deprecation import deprecate_arg, deprecate_func
152152

153-
@deprecate_func(since="0.24.0", additional_msg="No replacement is provided.")
153+
@deprecate_func(since="1.2", additional_msg="No replacement is provided.")
154154
def deprecated_func():
155155
pass
156156

157-
@deprecate_arg("bad_arg", new_alias="new_name", since="0.24.0")
157+
@deprecate_arg("bad_arg", new_alias="new_name", since="1.2")
158158
def another_func(bad_arg: str, new_name: str):
159159
pass
160160
```
@@ -178,7 +178,7 @@ import warnings
178178
def deprecated_function():
179179
warnings.warn(
180180
"The function qiskit.deprecated_function() is deprecated since "
181-
"Qiskit 0.44.0, and will be removed 3 months or more later. "
181+
"Qiskit 1.2, and will be removed in 2.0 or a later major release."
182182
"Instead, you should use qiskit.other_function().",
183183
category=DeprecationWarning,
184184
stacklevel=2,
@@ -235,9 +235,9 @@ def deprecated_function():
235235
"""
236236
Short description of the deprecated function.
237237
238-
.. deprecated:: 0.44.0
238+
.. deprecated:: 1.2
239239
The function qiskit.deprecated_function() is deprecated since
240-
Qiskit 0.44.0, and will be removed 3 months or more later.
240+
Qiskit 1.2, and will be removed in 2.0 or a later major release.
241241
Instead, you should use qiskit.other_function().
242242
243243
<rest of the docstring>

README.md

+18-21
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![License](https://img.shields.io/github/license/Qiskit/qiskit.svg?)](https://opensource.org/licenses/Apache-2.0) <!--- long-description-skip-begin -->
44
[![Current Release](https://img.shields.io/github/release/Qiskit/qiskit.svg?logo=Qiskit)](https://github.com/Qiskit/qiskit/releases)
5-
[![Extended Support Release](https://img.shields.io/github/v/release/Qiskit/qiskit?sort=semver&filter=0.*&logo=Qiskit&label=extended%20support)](https://github.com/Qiskit/qiskit/releases?q=tag%3A0)
5+
<!-- [![Extended Support Release](https://img.shields.io/github/v/release/Qiskit/qiskit?sort=semver&filter=0.*&logo=Qiskit&label=extended%20support)](https://github.com/Qiskit/qiskit/releases?q=tag%3A0) -->
66
[![Downloads](https://img.shields.io/pypi/dm/qiskit.svg)](https://pypi.org/project/qiskit/)
77
[![Coverage Status](https://coveralls.io/repos/github/Qiskit/qiskit/badge.svg?branch=main)](https://coveralls.io/github/Qiskit/qiskit?branch=main)
88
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/qiskit)
@@ -22,9 +22,6 @@ For more details on how to use Qiskit, refer to the documentation located here:
2222

2323
## Installation
2424

25-
> [!WARNING]
26-
> Do not try to upgrade an existing Qiskit 0.* environment to Qiskit 1.0 in-place. [Read more](https://docs.quantum.ibm.com/migration-guides/qiskit-1.0-installation).
27-
2825
We encourage installing Qiskit via ``pip``:
2926

3027
```bash
@@ -40,30 +37,30 @@ To install from source, follow the instructions in the [documentation](https://d
4037
Now that Qiskit is installed, it's time to begin working with Qiskit. The essential parts of a quantum program are:
4138
1. Define and build a quantum circuit that represents the quantum state
4239
2. Define the classical output by measurements or a set of observable operators
43-
3. Depending on the output, use the primitive function `sampler` to sample outcomes or the `estimator` to estimate values.
40+
3. Depending on the output, use the Sampler primitive to sample outcomes or the Estimator primitive to estimate expectation values.
4441

4542
Create an example quantum circuit using the `QuantumCircuit` class:
4643

4744
```python
4845
import numpy as np
4946
from qiskit import QuantumCircuit
5047

51-
# 1. A quantum circuit for preparing the quantum state |000> + i |111>
52-
qc_example = QuantumCircuit(3)
53-
qc_example.h(0) # generate superpostion
54-
qc_example.p(np.pi/2,0) # add quantum phase
55-
qc_example.cx(0,1) # 0th-qubit-Controlled-NOT gate on 1st qubit
56-
qc_example.cx(0,2) # 0th-qubit-Controlled-NOT gate on 2nd qubit
48+
# 1. A quantum circuit for preparing the quantum state |000> + i |111> / √2
49+
qc = QuantumCircuit(3)
50+
qc.h(0) # generate superposition
51+
qc.p(np.pi / 2, 0) # add quantum phase
52+
qc.cx(0, 1) # 0th-qubit-Controlled-NOT gate on 1st qubit
53+
qc.cx(0, 2) # 0th-qubit-Controlled-NOT gate on 2nd qubit
5754
```
5855

59-
This simple example makes an entangled state known as a [GHZ state](https://en.wikipedia.org/wiki/Greenberger%E2%80%93Horne%E2%80%93Zeilinger_state) $(|000\rangle + i|111\rangle)/\sqrt{2}$. It uses the standard quantum gates: Hadamard gate (`h`), Phase gate (`p`), and CNOT gate (`cx`).
56+
This simple example creates an entangled state known as a [GHZ state](https://en.wikipedia.org/wiki/Greenberger%E2%80%93Horne%E2%80%93Zeilinger_state) $(|000\rangle + i|111\rangle)/\sqrt{2}$. It uses the standard quantum gates: Hadamard gate (`h`), Phase gate (`p`), and CNOT gate (`cx`).
6057

61-
Once you've made your first quantum circuit, choose which primitive function you will use. Starting with `sampler`,
58+
Once you've made your first quantum circuit, choose which primitive you will use. Starting with the Sampler,
6259
we use `measure_all(inplace=False)` to get a copy of the circuit in which all the qubits are measured:
6360

6461
```python
6562
# 2. Add the classical output in the form of measurement of all qubits
66-
qc_measured = qc_example.measure_all(inplace=False)
63+
qc_measured = qc.measure_all(inplace=False)
6764

6865
# 3. Execute using the Sampler primitive
6966
from qiskit.primitives import StatevectorSampler
@@ -73,7 +70,7 @@ result = job.result()
7370
print(f" > Counts: {result[0].data["meas"].get_counts()}")
7471
```
7572
Running this will give an outcome similar to `{'000': 497, '111': 503}` which is `000` 50% of the time and `111` 50% of the time up to statistical fluctuations.
76-
To illustrate the power of Estimator, we now use the quantum information toolbox to create the operator $XXY+XYX+YXX-YYY$ and pass it to the `run()` function, along with our quantum circuit. Note the Estimator requires a circuit _**without**_ measurement, so we use the `qc_example` circuit we created earlier.
73+
To illustrate the power of the Estimator, we now use the quantum information toolbox to create the operator $XXY+XYX+YXX-YYY$ and pass it to the `run()` function, along with our quantum circuit. Note that the Estimator requires a circuit _**without**_ measurements, so we use the `qc` circuit we created earlier.
7774

7875
```python
7976
# 2. Define the observable to be measured
@@ -83,7 +80,7 @@ operator = SparsePauliOp.from_list([("XXY", 1), ("XYX", 1), ("YXX", 1), ("YYY",
8380
# 3. Execute using the Estimator primitive
8481
from qiskit.primitives import StatevectorEstimator
8582
estimator = StatevectorEstimator()
86-
job = estimator.run([(qc_example, operator)], precision=1e-3)
83+
job = estimator.run([(qc, operator)], precision=1e-3)
8784
result = job.result()
8885
print(f" > Expectation values: {result[0].data.evs}")
8986
```
@@ -96,17 +93,17 @@ The power of quantum computing cannot be simulated on classical computers and yo
9693
However, running a quantum circuit on hardware requires rewriting to the basis gates and connectivity of the quantum hardware.
9794
The tool that does this is the [transpiler](https://docs.quantum.ibm.com/api/qiskit/transpiler), and Qiskit includes transpiler passes for synthesis, optimization, mapping, and scheduling.
9895
However, it also includes a default compiler, which works very well in most examples.
99-
The following code will map the example circuit to the `basis_gates = ['cz', 'sx', 'rz']` and a linear chain of qubits $0 \rightarrow 1 \rightarrow 2$ with the `coupling_map =[[0, 1], [1, 2]]`.
96+
The following code will map the example circuit to the `basis_gates = ["cz", "sx", "rz"]` and a linear chain of qubits $0 \rightarrow 1 \rightarrow 2$ with the `coupling_map = [[0, 1], [1, 2]]`.
10097

10198
```python
10299
from qiskit import transpile
103-
qc_transpiled = transpile(qc_example, basis_gates = ['cz', 'sx', 'rz'], coupling_map =[[0, 1], [1, 2]] , optimization_level=3)
100+
qc_transpiled = transpile(qc, basis_gates=["cz", "sx", "rz"], coupling_map=[[0, 1], [1, 2]], optimization_level=3)
104101
```
105102

106103
### Executing your code on real quantum hardware
107104

108105
Qiskit provides an abstraction layer that lets users run quantum circuits on hardware from any vendor that provides a compatible interface.
109-
The best way to use Qiskit is with a runtime environment that provides optimized implementations of `sampler` and `estimator` for a given hardware platform. This runtime may involve using pre- and post-processing, such as optimized transpiler passes with error suppression, error mitigation, and, eventually, error correction built in. A runtime implements `qiskit.primitives.BaseSamplerV2` and `qiskit.primitives.BaseEstimatorV2` interfaces. For example,
106+
The best way to use Qiskit is with a runtime environment that provides optimized implementations of Sampler and Estimator for a given hardware platform. This runtime may involve using pre- and post-processing, such as optimized transpiler passes with error suppression, error mitigation, and, eventually, error correction built in. A runtime implements `qiskit.primitives.BaseSamplerV2` and `qiskit.primitives.BaseEstimatorV2` interfaces. For example,
110107
some packages that provide implementations of a runtime primitive implementation are:
111108

112109
* https://github.com/Qiskit/qiskit-ibm-runtime
@@ -146,9 +143,9 @@ to the project at different levels. If you use Qiskit, please cite as per the in
146143

147144
The changelog for a particular release is dynamically generated and gets
148145
written to the release page on Github for each release. For example, you can
149-
find the page for the `0.46.0` release here:
146+
find the page for the `1.2.0` release here:
150147

151-
<https://github.com/Qiskit/qiskit/releases/tag/0.46.0>
148+
<https://github.com/Qiskit/qiskit/releases/tag/1.2.0>
152149

153150
The changelog for the current release can be found in the releases tab:
154151
[![Releases](https://img.shields.io/github/release/Qiskit/qiskit.svg?style=flat&label=)](https://github.com/Qiskit/qiskit/releases)

crates/accelerate/src/circuit_library/pauli_evolution.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -192,22 +192,22 @@ fn multi_qubit_evolution(
192192
/// followed by a CX-chain and then a single Pauli-Z rotation on the last qubit. Then the CX-chain
193193
/// is uncomputed and the inverse basis transformation applied. E.g. for the evolution under the
194194
/// Pauli string XIYZ we have the circuit
195-
/// ┌───┐┌───────┐┌───┐
196-
/// 0: ─────────────┤ X ├┤ Rz(2) ├┤ X ├──────────
197-
/// ──────┐┌───┐└─┬─┘└───────┘└─┬─┘┌───┐┌────┐
198-
/// 1: ┤ √Xdg ├┤ X ├──■─────────────■──┤ X ├┤ √X ├
199-
/// ──────┘└─┬─┘ └─┬─┘└────┘
200-
/// 2: ─────────────────────────────────┼────────
201-
/// ┌───┐ │ │ ┌───┐
202-
/// 3: ─┤ H ├────■───────────────────────■──┤ H ├─
203-
/// ───┘ └───
195+
///
196+
/// ───┐ ┌───┐┌───────┐┌───┐┌───┐
197+
/// 0: ┤ H ├──────┤ X ├┤ Rz(2) ├┤ X ├┤ H ├────────
198+
/// └───┘ └─┬─┘└───────┘└─┬─┘└───┘
199+
/// 1: ─────────────┼─────────────┼───────────────
200+
/// ────┐┌───┐ │ │ ┌───┐┌──────
201+
/// 2: ┤ √X ├┤ X ├──■─────────────■──┤ X ├┤ √Xdg ├
202+
/// ────┘└─┬─┘ └─┬─┘└──────
203+
/// 3: ────────■───────────────────────■──────────
204204
///
205205
/// Args:
206206
/// num_qubits: The number of qubits in the Hamiltonian.
207207
/// sparse_paulis: The Paulis to implement. Given in a sparse-list format with elements
208-
/// ``(pauli_string, qubit_indices, coefficient)``. An element of the form
209-
/// ``("IXYZ", [0,1,2,3], 0.2)``, for example, is interpreted in terms of qubit indices as
210-
/// I_q0 X_q1 Y_q2 Z_q3 and will use a RZ rotation angle of 0.4.
208+
/// ``(pauli_string, qubit_indices, rz_rotation_angle)``. An element of the form
209+
/// ``("XIYZ", [0,1,2,3], 2)``, for example, is interpreted in terms of qubit indices as
210+
/// X_q0 I_q1 Y_q2 Z_q3 and will use a RZ rotation angle of 2.
211211
/// insert_barriers: If ``true``, insert a barrier in between the evolution of individual
212212
/// Pauli terms.
213213
/// do_fountain: If ``true``, implement the CX propagation as "fountain" shape, where each
@@ -244,7 +244,7 @@ pub fn py_pauli_evolution(
244244
}
245245

246246
paulis.push(pauli);
247-
times.push(time); // note we do not multiply by 2 here, this is done Python side!
247+
times.push(time); // note we do not multiply by 2 here, this is already done Python side!
248248
indices.push(tuple.get_item(1)?.extract::<Vec<u32>>()?)
249249
}
250250

@@ -266,12 +266,12 @@ pub fn py_pauli_evolution(
266266
},
267267
);
268268

269-
// When handling all-identity Paulis above, we added the time as global phase.
270-
// However, the all-identity Paulis should add a negative phase, as they implement
271-
// exp(-i t I). We apply the negative sign here, to only do a single (-1) multiplication,
272-
// instead of doing it every time we find an all-identity Pauli.
269+
// When handling all-identity Paulis above, we added the RZ rotation angle as global phase,
270+
// meaning that we have implemented of exp(i 2t I). However, what we want it to implement
271+
// exp(-i t I). To only use a single multiplication, we apply a factor of -0.5 here.
272+
// This is faster, in particular as long as the parameter expressions are in Python.
273273
if modified_phase {
274-
global_phase = multiply_param(&global_phase, -1.0, py);
274+
global_phase = multiply_param(&global_phase, -0.5, py);
275275
}
276276

277277
CircuitData::from_packed_operations(py, num_qubits as u32, 0, evos, global_phase)

0 commit comments

Comments
 (0)