From 410715634608d6e7809855b2d29d2c43901b81d1 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Mon, 7 Aug 2023 21:28:11 -0400 Subject: [PATCH 01/54] Update README.md to include sampler and estimator --- README.md | 100 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 34fc552adc1f..b4f12e9f5726 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Qiskit Terra [![License](https://img.shields.io/github/license/Qiskit/qiskit-terra.svg?style=popout-square)](https://opensource.org/licenses/Apache-2.0)[![Release](https://img.shields.io/github/release/Qiskit/qiskit-terra.svg?style=popout-square)](https://github.com/Qiskit/qiskit-terra/releases)[![Downloads](https://img.shields.io/pypi/dm/qiskit-terra.svg?style=popout-square)](https://pypi.org/project/qiskit-terra/)[![Coverage Status](https://coveralls.io/repos/github/Qiskit/qiskit-terra/badge.svg?branch=main)](https://coveralls.io/github/Qiskit/qiskit-terra?branch=main)[![Minimum rustc 1.64.0](https://img.shields.io/badge/rustc-1.64.0+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html) -**Qiskit** is an open-source framework for working with noisy quantum computers at the level of pulses, circuits, and algorithms. +**Qiskit** is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and functions. This library is the core component of Qiskit, **Terra**, which contains the building blocks for creating -and working with quantum circuits, programs, and algorithms. It also contains a compiler that supports -different quantum computers and a common interface for running programs on different quantum computer architectures. +and working with quantum circuits, quantum operators, and primitive functions (sampler and estimator). +It also contains a transpiler that supports optimizing quantum circutis and a quantum information toolbox for creating advance quantum operators. For more details on how to use Qiskit you can refer to the documentation located here: @@ -26,59 +26,91 @@ To install from source, follow the instructions in the [documentation](https://q ## Creating Your First Quantum Program in Qiskit Terra -Now that Qiskit is installed, it's time to begin working with Qiskit. To do this -we create a `QuantumCircuit` object to define a basic quantum program. +Now that Qiskit is installed, it's time to begin working with Qiskit. The essential parts of a quantum program are +1. Define and build a quantum circuit that represents the quantum state +2. Define the classical output by a measurements circuit or a set of observable operators +3. Depending on the output use the primitive function `sampler` to sample outcomes or the `estimaor` to estimate values. + +Usign the `QuantumCircuit` object a example quantum circuit can be created using: ```python +import numpy as np from qiskit import QuantumCircuit -qc = QuantumCircuit(2, 2) -qc.h(0) -qc.cx(0, 1) -qc.measure([0,1], [0,1]) + +# A quantum circuit for preparing the quantum state |000> + i |111> +qc_example = QuantumCircuit(3) +qc_example.h(0) # generate superpostion +qc_example.p(np.pi/2,0) # add quantum phase +qc_example.cx(0,1) # condition 1st qubit on 0th qubit +qc_example.cx(0,2) # condition 2st qubit on 0th qubit ``` -This simple example makes an entangled state, also called a [Bell state](https://qiskit.org/textbook/ch-gates/multiple-qubits-entangled-states.html#3.2-Entangled-States-). +This simple example makes an entangled state known as a GHZ state `(|000> + i |111>)/rt(2)`. It uses the standard quantum +gates: Hadamard gate, Phase gate and CNOT. -Once you've made your first quantum circuit, you can then simulate it. -To do this, first we need to compile your circuit for the target backend we're going to run -on. In this case we are leveraging the built-in `BasicAer` simulator. However, this -simulator is primarily for testing and is limited in performance and functionality (as the name -implies). You should consider more sophisticated simulators, such as [`qiskit-aer`](https://github.com/Qiskit/qiskit-aer/), -for any real simulation work. +Once you've made your first quantum circuit, you need to decide on which primtive function you will use. Starting with the sampler +we use the `compose` funtion to add a measurement circuit to the example circuit. In this example we simply map the qubits to +the classical registers in asending order. ```python -from qiskit import transpile -from qiskit.providers.basicaer import QasmSimulatorPy -backend_sim = QasmSimulatorPy() -transpiled_qc = transpile(qc, backend_sim) +qc_measure = QuantumCircuit(3,3) +qc_measure.measure([0,1,2], [0,1,2]) +qc_compose = qc_example.compose(qc_measure) + +from qiskit.primitives.sampler import Sampler +sampler = Sampler() +job = sampler.run(qc_compose, shots=1000) +result = job.result() +print(f" > Quasi probability distribution: {result.quasi_dists}") ``` - -After compiling the circuit we can then run this on the ``backend`` object with: +Running this will give the outcome `{0: 0.497, 7: 0.503}` which is `000` 50% of the time and `111` 50% of the time upto statistical errors. +To illustrate the power of estimator we now use the quantum information toolbox to create the set of operators `[XXY, XYX, YXX, YYY]` which represents four different multi-qubit +observables. ```python -result = backend_sim.run(transpiled_qc).result() -print(result.get_counts(qc)) +from qiskit.quantum_info import SparsePauliOp +XXY = SparsePauliOp('XXY') +XYX = SparsePauliOp('XYX') +YXX = SparsePauliOp('YXX') +YYY = SparsePauliOp('YYY') +operators = [XXY,XYX,YXX,YYY] + +from qiskit.primitives.estimator import Estimator +estimator = Estimator() +job = estimator.run([qc_example]*4, operators, shots=1000) +result = job.result() +print(f" > Expectation values: {result.values}") ``` -The output from this execution will look similar to this: +Running this will give the outcome `[1,1,1,-1]`. For fun try to assign a value of +/- 1 to each single qubit operator X and Y +and see if you can acheive this outcome. This is not possible!. + +Using the Qiskit provided sampler and estimator will not take you very far. The power of quantum computing can not be simulated +on classical computers and you need to use real quantum hardware to scale to larger quantum circuits. However, running a quantum +circuit on hardware requires rewriting them to the basis gates and connectivity of the quantum hardware. +We call this the [transpiler](https://qiskit.org/documentation/tutorials/circuits_advanced/04_transpiler_passes_and_passmanager.html) +and Qiskit includes transpiler passes for synthesis, optimization, mapping, and scheduling. However, it also includes a +default compiler which works very well in most examples and as a example the following code will map the example circuit to the `basis_gates = ['cz', 'sx', 'rz']` and a linear chain of qubits with the `coupling_map =[[0, 1], [1, 2]]`. ```python -{'00': 513, '11': 511} +from qiskit import transpile +qc_ibm = transpile(qc_example, basis_gates = ['cz', 'sx', 'rz'], coupling_map =[[0, 1], [1, 2]] , optimization_level=3) ``` -For further examples of using Qiskit you can look at the example scripts in **examples/python**. You can start with -[using_qiskit_terra_level_0.py](examples/python/using_qiskit_terra_level_0.py) and working up in the levels. Also -you can refer to the tutorials in the documentation here: +For further examples of using Qiskit you can look at the example scripts in **examples/python** and the tutorials +in the documentation here: https://qiskit.org/documentation/tutorials.html -### Executing your code on a real quantum chip +### Executing your code on a real quantum hardware + +Qiskit provides an abstraction layer that lets users run quantum circuits on hardware from any vendor that provides an interface. +The default way for using Qiskit is to have a runtime environment that provides optimal implementations of `sampler` and `estimator` for a given hardware. This runtime may invole using pre and post processing such as optimized transpiler passes with error supression, error mitigation and eventually error correction built in. The runtime must provide a promise to the user that these primitives functions exist + +* https://github.com/Qiskit/qiskit-ibm-runtime -You can also use Qiskit to execute your code on a **real quantum processor**. -Qiskit provides an abstraction layer that lets users run quantum circuits on hardware from any -vendor that provides an interface to their systems through Qiskit. Using these ``providers`` you can run any Qiskit code against -real quantum computers. Some examples of published provider packages for running on real hardware are: +However, as Qiskit transitions to the runtime enviroment some hardware is only supported with the ``providers`` interface, however each provider may perform different types of pre and post processing and the return outcomes that are vendor defined: * https://github.com/Qiskit/qiskit-ibmq-provider * https://github.com/Qiskit-Partners/qiskit-ionq From 4a185e1c7882adfc7a63553b516c0db58ad62793 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Mon, 7 Aug 2023 21:57:00 -0400 Subject: [PATCH 02/54] Update README.md --- README.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b4f12e9f5726..352584f8604c 100644 --- a/README.md +++ b/README.md @@ -64,25 +64,20 @@ result = job.result() print(f" > Quasi probability distribution: {result.quasi_dists}") ``` Running this will give the outcome `{0: 0.497, 7: 0.503}` which is `000` 50% of the time and `111` 50% of the time upto statistical errors. -To illustrate the power of estimator we now use the quantum information toolbox to create the set of operators `[XXY, XYX, YXX, YYY]` which represents four different multi-qubit -observables. +To illustrate the power of estimator we now use the quantum information toolbox to create the operator `XXY+XYX+YXX-YYY`. ```python from qiskit.quantum_info import SparsePauliOp -XXY = SparsePauliOp('XXY') -XYX = SparsePauliOp('XYX') -YXX = SparsePauliOp('YXX') -YYY = SparsePauliOp('YYY') -operators = [XXY,XYX,YXX,YYY] +operator = SparsePauliOp('XXY')+SparsePauliOp('XYX')+SparsePauliOp('YXX')-SparsePauliOp('YYY') from qiskit.primitives.estimator import Estimator estimator = Estimator() -job = estimator.run([qc_example]*4, operators, shots=1000) +job = estimator.run(qc_example, operator, shots=1000) result = job.result() print(f" > Expectation values: {result.values}") ``` -Running this will give the outcome `[1,1,1,-1]`. For fun try to assign a value of +/- 1 to each single qubit operator X and Y +Running this will give the outcome `4`. For fun try to assign a value of +/- 1 to each single qubit operator X and Y and see if you can acheive this outcome. This is not possible!. Using the Qiskit provided sampler and estimator will not take you very far. The power of quantum computing can not be simulated From 8a355070bc2e29627c15045f5326425685f14eae Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Mon, 7 Aug 2023 22:01:41 -0400 Subject: [PATCH 03/54] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 352584f8604c..f2584455208c 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ To illustrate the power of estimator we now use the quantum information toolbox ```python from qiskit.quantum_info import SparsePauliOp -operator = SparsePauliOp('XXY')+SparsePauliOp('XYX')+SparsePauliOp('YXX')-SparsePauliOp('YYY') +operator = SparsePauliOp.from_list([("XXY", 1), ("XYX", 1), ("YXX", 1), ("YYY", -1)]) from qiskit.primitives.estimator import Estimator estimator = Estimator() From b0b9b546216ccef39c49ab41e35907bc0e42cd45 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:14:33 -0400 Subject: [PATCH 04/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2584455208c..2821c922e2d5 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This library is the core component of Qiskit, **Terra**, which contains the building blocks for creating and working with quantum circuits, quantum operators, and primitive functions (sampler and estimator). -It also contains a transpiler that supports optimizing quantum circutis and a quantum information toolbox for creating advance quantum operators. +It also contains a transpiler that supports optimizing quantum circutis and a quantum information toolbox for creating advanced quantum operators. For more details on how to use Qiskit you can refer to the documentation located here: From f6a1e511d253455f0ef2b65daffc2e1621d4342a Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:14:47 -0400 Subject: [PATCH 05/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2821c922e2d5..3d84fd55a9f8 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ To install from source, follow the instructions in the [documentation](https://q Now that Qiskit is installed, it's time to begin working with Qiskit. The essential parts of a quantum program are 1. Define and build a quantum circuit that represents the quantum state -2. Define the classical output by a measurements circuit or a set of observable operators +2. Define the classical output by measurements or a set of observable operators 3. Depending on the output use the primitive function `sampler` to sample outcomes or the `estimaor` to estimate values. Usign the `QuantumCircuit` object a example quantum circuit can be created using: From fb6e69ba80b5310239b517282c49cb171c0a8014 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:15:00 -0400 Subject: [PATCH 06/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3d84fd55a9f8..cd60ae4870c9 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ qc_example = QuantumCircuit(3) qc_example.h(0) # generate superpostion qc_example.p(np.pi/2,0) # add quantum phase qc_example.cx(0,1) # condition 1st qubit on 0th qubit -qc_example.cx(0,2) # condition 2st qubit on 0th qubit +qc_example.cx(0,2) # condition 2nd qubit on 0th qubit ``` This simple example makes an entangled state known as a GHZ state `(|000> + i |111>)/rt(2)`. It uses the standard quantum From e9f2e6eff4ce0e0def8b8619311fe2601327485b Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:15:10 -0400 Subject: [PATCH 07/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cd60ae4870c9..154f4dde8576 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ gates: Hadamard gate, Phase gate and CNOT. Once you've made your first quantum circuit, you need to decide on which primtive function you will use. Starting with the sampler we use the `compose` funtion to add a measurement circuit to the example circuit. In this example we simply map the qubits to -the classical registers in asending order. +the classical registers in ascending order. ```python qc_measure = QuantumCircuit(3,3) From bd39ef326e8313851f8c5ba40a056aba4d334ec1 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:15:28 -0400 Subject: [PATCH 08/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 154f4dde8576..4f96bdfe9672 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ To install from source, follow the instructions in the [documentation](https://q Now that Qiskit is installed, it's time to begin working with Qiskit. The essential parts of a quantum program are 1. Define and build a quantum circuit that represents the quantum state 2. Define the classical output by measurements or a set of observable operators -3. Depending on the output use the primitive function `sampler` to sample outcomes or the `estimaor` to estimate values. +3. Depending on the output, use the primitive function `sampler` to sample outcomes or the `estimaor` to estimate values. Usign the `QuantumCircuit` object a example quantum circuit can be created using: From 6b4ad11ce3bd274b5c8ba4c59474c744a560022e Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:18:44 -0400 Subject: [PATCH 09/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f96bdfe9672..63f9f318d485 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ job = sampler.run(qc_compose, shots=1000) result = job.result() print(f" > Quasi probability distribution: {result.quasi_dists}") ``` -Running this will give the outcome `{0: 0.497, 7: 0.503}` which is `000` 50% of the time and `111` 50% of the time upto statistical errors. +Running this will give an outcome similar to `{0: 0.497, 7: 0.503}` which is `000` 50% of the time and `111` 50% of the time up to statistical fluctuations. To illustrate the power of estimator we now use the quantum information toolbox to create the operator `XXY+XYX+YXX-YYY`. ```python From 37c45b186e6935602cbfbabc20996d4f1d014d07 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:18:57 -0400 Subject: [PATCH 10/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 63f9f318d485..1adc5fc555de 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ print(f" > Expectation values: {result.values}") ``` Running this will give the outcome `4`. For fun try to assign a value of +/- 1 to each single qubit operator X and Y -and see if you can acheive this outcome. This is not possible!. +and see if you can acheive this outcome. This is not possible! Using the Qiskit provided sampler and estimator will not take you very far. The power of quantum computing can not be simulated on classical computers and you need to use real quantum hardware to scale to larger quantum circuits. However, running a quantum From 40148a4df42f38d59800ee081ee4ea9f6b706490 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:19:06 -0400 Subject: [PATCH 11/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1adc5fc555de..d8931ddbf8a4 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ print(f" > Expectation values: {result.values}") Running this will give the outcome `4`. For fun try to assign a value of +/- 1 to each single qubit operator X and Y and see if you can acheive this outcome. This is not possible! -Using the Qiskit provided sampler and estimator will not take you very far. The power of quantum computing can not be simulated +Using the Qiskit provided sampler and estimator will not take you very far. The power of quantum computing cannot be simulated on classical computers and you need to use real quantum hardware to scale to larger quantum circuits. However, running a quantum circuit on hardware requires rewriting them to the basis gates and connectivity of the quantum hardware. We call this the [transpiler](https://qiskit.org/documentation/tutorials/circuits_advanced/04_transpiler_passes_and_passmanager.html) From 970cc63adb774858b3c98b31a01b451833b13df2 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:20:11 -0400 Subject: [PATCH 12/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d8931ddbf8a4..02889377d860 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ and see if you can acheive this outcome. This is not possible! Using the Qiskit provided sampler and estimator will not take you very far. The power of quantum computing cannot be simulated on classical computers and you need to use real quantum hardware to scale to larger quantum circuits. However, running a quantum circuit on hardware requires rewriting them to the basis gates and connectivity of the quantum hardware. -We call this the [transpiler](https://qiskit.org/documentation/tutorials/circuits_advanced/04_transpiler_passes_and_passmanager.html) +The tool that does this is the [transpiler](https://qiskit.org/documentation/tutorials/circuits_advanced/04_transpiler_passes_and_passmanager.html) and Qiskit includes transpiler passes for synthesis, optimization, mapping, and scheduling. However, it also includes a default compiler which works very well in most examples and as a example the following code will map the example circuit to the `basis_gates = ['cz', 'sx', 'rz']` and a linear chain of qubits with the `coupling_map =[[0, 1], [1, 2]]`. From 2da714f5c0c10f894a9234b67a98bfcbf4e14be1 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:20:23 -0400 Subject: [PATCH 13/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 02889377d860..14eeb7511b62 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ in the documentation here: https://qiskit.org/documentation/tutorials.html -### Executing your code on a real quantum hardware +### Executing your code on real quantum hardware Qiskit provides an abstraction layer that lets users run quantum circuits on hardware from any vendor that provides an interface. The default way for using Qiskit is to have a runtime environment that provides optimal implementations of `sampler` and `estimator` for a given hardware. This runtime may invole using pre and post processing such as optimized transpiler passes with error supression, error mitigation and eventually error correction built in. The runtime must provide a promise to the user that these primitives functions exist From b04c47848508ec155e44cfb55f15e6f0ed412d82 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:22:40 -0400 Subject: [PATCH 14/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 14eeb7511b62..aaa33612e91b 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ https://qiskit.org/documentation/tutorials.html ### Executing your code on real quantum hardware -Qiskit provides an abstraction layer that lets users run quantum circuits on hardware from any vendor that provides an interface. +Qiskit provides an abstraction layer that lets users run quantum circuits on hardware from any vendor that provides a compatible interface. The default way for using Qiskit is to have a runtime environment that provides optimal implementations of `sampler` and `estimator` for a given hardware. This runtime may invole using pre and post processing such as optimized transpiler passes with error supression, error mitigation and eventually error correction built in. The runtime must provide a promise to the user that these primitives functions exist * https://github.com/Qiskit/qiskit-ibm-runtime From f697354725d5618899b4c29f0ef815faabdfe985 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:23:01 -0400 Subject: [PATCH 15/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aaa33612e91b..b304dd1a9ea4 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ The default way for using Qiskit is to have a runtime environment that provides * https://github.com/Qiskit/qiskit-ibm-runtime -However, as Qiskit transitions to the runtime enviroment some hardware is only supported with the ``providers`` interface, however each provider may perform different types of pre and post processing and the return outcomes that are vendor defined: +However, as Qiskit transitions to the runtime enviroment some hardware is only supported with the ``providers`` interface, however each provider may perform different types of pre and post processing and return outcomes that are vendor defined: * https://github.com/Qiskit/qiskit-ibmq-provider * https://github.com/Qiskit-Partners/qiskit-ionq From 206ad1deee0ec37dfd0f8fc51950885e9cb78f9d Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:25:39 -0400 Subject: [PATCH 16/54] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b304dd1a9ea4..fb1fd152d440 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Qiskit Terra [![License](https://img.shields.io/github/license/Qiskit/qiskit-terra.svg?style=popout-square)](https://opensource.org/licenses/Apache-2.0)[![Release](https://img.shields.io/github/release/Qiskit/qiskit-terra.svg?style=popout-square)](https://github.com/Qiskit/qiskit-terra/releases)[![Downloads](https://img.shields.io/pypi/dm/qiskit-terra.svg?style=popout-square)](https://pypi.org/project/qiskit-terra/)[![Coverage Status](https://coveralls.io/repos/github/Qiskit/qiskit-terra/badge.svg?branch=main)](https://coveralls.io/github/Qiskit/qiskit-terra?branch=main)[![Minimum rustc 1.64.0](https://img.shields.io/badge/rustc-1.64.0+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html) -**Qiskit** is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and functions. +**Qiskit** is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives. This library is the core component of Qiskit, **Terra**, which contains the building blocks for creating and working with quantum circuits, quantum operators, and primitive functions (sampler and estimator). From 7ce7ed5c2d5e3b6f9aaeaa8d80f7376b5383e3a3 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:34:40 -0400 Subject: [PATCH 17/54] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb1fd152d440..c7909f97882e 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ the classical registers in ascending order. ```python qc_measure = QuantumCircuit(3,3) -qc_measure.measure([0,1,2], [0,1,2]) +qc_measure.measure_all(add_bits=False) qc_compose = qc_example.compose(qc_measure) from qiskit.primitives.sampler import Sampler From f0e95f100f13f4dc147f473d36d4f99769fc5ca3 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:49:49 -0400 Subject: [PATCH 18/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c7909f97882e..37874ed21389 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This library is the core component of Qiskit, **Terra**, which contains the building blocks for creating and working with quantum circuits, quantum operators, and primitive functions (sampler and estimator). -It also contains a transpiler that supports optimizing quantum circutis and a quantum information toolbox for creating advanced quantum operators. +It also contains a transpiler that supports optimizing quantum circuits and a quantum information toolbox for creating advanced quantum operators. For more details on how to use Qiskit you can refer to the documentation located here: From 45294cb863ad2a86eb33de734512ce7982add13d Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 09:54:16 -0400 Subject: [PATCH 19/54] Update README.md Co-authored-by: Abby Mitchell <23662430+javabster@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37874ed21389..bab002aec46b 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Now that Qiskit is installed, it's time to begin working with Qiskit. The essent 2. Define the classical output by measurements or a set of observable operators 3. Depending on the output, use the primitive function `sampler` to sample outcomes or the `estimaor` to estimate values. -Usign the `QuantumCircuit` object a example quantum circuit can be created using: +Using the `QuantumCircuit` class, an example quantum circuit can be created: ```python import numpy as np From f22fdb049649b5811c649844a0d94502b839f261 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:49:24 -0400 Subject: [PATCH 20/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bab002aec46b..e37d26981eaf 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ The default way for using Qiskit is to have a runtime environment that provides * https://github.com/Qiskit/qiskit-ibm-runtime -However, as Qiskit transitions to the runtime enviroment some hardware is only supported with the ``providers`` interface, however each provider may perform different types of pre and post processing and return outcomes that are vendor defined: +As Qiskit transitions to the runtime environment, some hardware is only supported with the ``providers`` interface; however, each provider may perform different types of pre- and post-processing and return outcomes that are vendor-defined: * https://github.com/Qiskit/qiskit-ibmq-provider * https://github.com/Qiskit-Partners/qiskit-ionq From 2201e8b7b41af53763ae1f322caa14f1d2fcc6fa Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:49:47 -0400 Subject: [PATCH 21/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e37d26981eaf..88697a8d42aa 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This library is the core component of Qiskit, **Terra**, which contains the buil and working with quantum circuits, quantum operators, and primitive functions (sampler and estimator). It also contains a transpiler that supports optimizing quantum circuits and a quantum information toolbox for creating advanced quantum operators. -For more details on how to use Qiskit you can refer to the documentation located here: +For more details on how to use Qiskit, refer to the documentation located here: https://qiskit.org/documentation/ From 834a03bab418454c94c3e3be96720e70c8a6f9be Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:50:29 -0400 Subject: [PATCH 22/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 88697a8d42aa..c35350a0d15a 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Pip will handle all dependencies automatically and you will always install the l To install from source, follow the instructions in the [documentation](https://qiskit.org/documentation/contributing_to_qiskit.html#install-install-from-source-label). -## Creating Your First Quantum Program in Qiskit Terra +## Create your first quantum program in Qiskit Terra Now that Qiskit is installed, it's time to begin working with Qiskit. The essential parts of a quantum program are 1. Define and build a quantum circuit that represents the quantum state From 5ea063e6e172945e2fc1b5d791e129d86076f3bb Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:50:37 -0400 Subject: [PATCH 23/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c35350a0d15a..cb65da7bfa74 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ To install from source, follow the instructions in the [documentation](https://q ## Create your first quantum program in Qiskit Terra -Now that Qiskit is installed, it's time to begin working with Qiskit. The essential parts of a quantum program are +Now that Qiskit is installed, it's time to begin working with Qiskit. The essential parts of a quantum program are: 1. Define and build a quantum circuit that represents the quantum state 2. Define the classical output by measurements or a set of observable operators 3. Depending on the output, use the primitive function `sampler` to sample outcomes or the `estimaor` to estimate values. From cd0ba9fe51783f4bcda0ee6b339824b89a9e8c99 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:51:10 -0400 Subject: [PATCH 24/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb65da7bfa74..eaf9fa96e9be 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ To install from source, follow the instructions in the [documentation](https://q Now that Qiskit is installed, it's time to begin working with Qiskit. The essential parts of a quantum program are: 1. Define and build a quantum circuit that represents the quantum state 2. Define the classical output by measurements or a set of observable operators -3. Depending on the output, use the primitive function `sampler` to sample outcomes or the `estimaor` to estimate values. +3. Depending on the output, use the primitive function `sampler` to sample outcomes or the `estimator` to estimate values. Using the `QuantumCircuit` class, an example quantum circuit can be created: From 34f2dea176cb398ebd514a4d50c1466d4c6e6ea9 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:51:22 -0400 Subject: [PATCH 25/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eaf9fa96e9be..7eec9d7d2f6b 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Now that Qiskit is installed, it's time to begin working with Qiskit. The essent 2. Define the classical output by measurements or a set of observable operators 3. Depending on the output, use the primitive function `sampler` to sample outcomes or the `estimator` to estimate values. -Using the `QuantumCircuit` class, an example quantum circuit can be created: +Create an example quantum circuit using the `QuantumCircuit` class: ```python import numpy as np From a42a5aa3ac4aef1659ca709c68577aad99a90d3d Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:51:33 -0400 Subject: [PATCH 26/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7eec9d7d2f6b..acecdcee4c26 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ qc_example.cx(0,2) # condition 2nd qubit on 0th qubit This simple example makes an entangled state known as a GHZ state `(|000> + i |111>)/rt(2)`. It uses the standard quantum gates: Hadamard gate, Phase gate and CNOT. -Once you've made your first quantum circuit, you need to decide on which primtive function you will use. Starting with the sampler +Once you've made your first quantum circuit, choose which primitive function you will use. Starting with Sampler, we use the `compose` funtion to add a measurement circuit to the example circuit. In this example we simply map the qubits to the classical registers in ascending order. From 541170ca78f3b1d1172f99edcfaee5f6062a06a7 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:51:43 -0400 Subject: [PATCH 27/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index acecdcee4c26..4b200abe4d9c 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ This simple example makes an entangled state known as a GHZ state `(|000> + i |1 gates: Hadamard gate, Phase gate and CNOT. Once you've made your first quantum circuit, choose which primitive function you will use. Starting with Sampler, -we use the `compose` funtion to add a measurement circuit to the example circuit. In this example we simply map the qubits to +we use the `compose` function to add a measurement circuit to the example circuit. In this example we simply map the qubits to the classical registers in ascending order. ```python From c8bb7e9e6759f17f9f1c03dc91b317603ddbfb09 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:52:36 -0400 Subject: [PATCH 28/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b200abe4d9c..4e6e59d5c153 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ result = job.result() print(f" > Quasi probability distribution: {result.quasi_dists}") ``` Running this will give an outcome similar to `{0: 0.497, 7: 0.503}` which is `000` 50% of the time and `111` 50% of the time up to statistical fluctuations. -To illustrate the power of estimator we now use the quantum information toolbox to create the operator `XXY+XYX+YXX-YYY`. +To illustrate the power of Estimator, we now use the quantum information toolbox to create the operator `XXY+XYX+YXX-YYY`. ```python from qiskit.quantum_info import SparsePauliOp From 43d04787e22045de466b8cc31f6e757163689fbb Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:53:38 -0400 Subject: [PATCH 29/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e6e59d5c153..6d50a2c3600f 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ print(f" > Expectation values: {result.values}") Running this will give the outcome `4`. For fun try to assign a value of +/- 1 to each single qubit operator X and Y and see if you can acheive this outcome. This is not possible! -Using the Qiskit provided sampler and estimator will not take you very far. The power of quantum computing cannot be simulated +Using the Qiskit-provided Sampler and Estimator will not take you very far. The power of quantum computing cannot be simulated on classical computers and you need to use real quantum hardware to scale to larger quantum circuits. However, running a quantum circuit on hardware requires rewriting them to the basis gates and connectivity of the quantum hardware. The tool that does this is the [transpiler](https://qiskit.org/documentation/tutorials/circuits_advanced/04_transpiler_passes_and_passmanager.html) From e06c30e09bb93117e135f78a742210e3f6dc1486 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:54:42 -0400 Subject: [PATCH 30/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d50a2c3600f..5e3ccff852f6 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ https://qiskit.org/documentation/tutorials.html ### Executing your code on real quantum hardware Qiskit provides an abstraction layer that lets users run quantum circuits on hardware from any vendor that provides a compatible interface. -The default way for using Qiskit is to have a runtime environment that provides optimal implementations of `sampler` and `estimator` for a given hardware. This runtime may invole using pre and post processing such as optimized transpiler passes with error supression, error mitigation and eventually error correction built in. The runtime must provide a promise to the user that these primitives functions exist +The default way to use Qiskit is to have a runtime environment that provides optimal implementations of `sampler` and `estimator` for a given hardware. 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. The runtime must provide a promise to the user that these primitives functions exist. * https://github.com/Qiskit/qiskit-ibm-runtime From 9811d348952d3b8938c3f2c3ca4307f9a14d8662 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:54:53 -0400 Subject: [PATCH 31/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e3ccff852f6..960ddf5169b9 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ result = job.result() print(f" > Expectation values: {result.values}") ``` -Running this will give the outcome `4`. For fun try to assign a value of +/- 1 to each single qubit operator X and Y +Running this will give the outcome `4`. For fun, try to assign a value of +/- 1 to each single-qubit operator X and Y and see if you can acheive this outcome. This is not possible! Using the Qiskit-provided Sampler and Estimator will not take you very far. The power of quantum computing cannot be simulated From 4fcfc98bb857ec0e166914bde5b33e3fa22b9cda Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:56:00 -0400 Subject: [PATCH 32/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 960ddf5169b9..5c7e69754b00 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ print(f" > Expectation values: {result.values}") ``` Running this will give the outcome `4`. For fun, try to assign a value of +/- 1 to each single-qubit operator X and Y -and see if you can acheive this outcome. This is not possible! +and see if you can achieve this outcome. (Spoiler alert: this is not possible!) Using the Qiskit-provided Sampler and Estimator will not take you very far. The power of quantum computing cannot be simulated on classical computers and you need to use real quantum hardware to scale to larger quantum circuits. However, running a quantum From cf857b7ac707f025b812128bdaadd0099cc6a64c Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:57:18 -0400 Subject: [PATCH 33/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c7e69754b00..d89ba26b4b24 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ on classical computers and you need to use real quantum hardware to scale to lar circuit on hardware requires rewriting them to the basis gates and connectivity of the quantum hardware. The tool that does this is the [transpiler](https://qiskit.org/documentation/tutorials/circuits_advanced/04_transpiler_passes_and_passmanager.html) and Qiskit includes transpiler passes for synthesis, optimization, mapping, and scheduling. However, it also includes a -default compiler which works very well in most examples and as a example the following code will map the example circuit to the `basis_gates = ['cz', 'sx', 'rz']` and a linear chain of qubits with the `coupling_map =[[0, 1], [1, 2]]`. +default compiler which works very well in most examples. The following code will map the example circuit to the `basis_gates = ['cz', 'sx', 'rz']` and a linear chain of qubits with the `coupling_map =[[0, 1], [1, 2]]`. ```python from qiskit import transpile From 14f0f1176b87bc30889b75ed5c4c3defdb386c56 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 12:57:33 -0400 Subject: [PATCH 34/54] Update README.md Co-authored-by: abbycross --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d89ba26b4b24..1125889a5803 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ from qiskit import transpile qc_ibm = transpile(qc_example, basis_gates = ['cz', 'sx', 'rz'], coupling_map =[[0, 1], [1, 2]] , optimization_level=3) ``` -For further examples of using Qiskit you can look at the example scripts in **examples/python** and the tutorials +For further examples of using Qiskit, look at the example scripts in **examples/python** and the tutorials in the documentation here: https://qiskit.org/documentation/tutorials.html From 0d9b380fdd1e0fb6b82c2df1342041acdd8484c9 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 17:16:22 -0400 Subject: [PATCH 35/54] Update README.md Co-authored-by: Luciano Bello --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1125889a5803..d0bbd6d546cc 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ To illustrate the power of Estimator, we now use the quantum information toolbox from qiskit.quantum_info import SparsePauliOp operator = SparsePauliOp.from_list([("XXY", 1), ("XYX", 1), ("YXX", 1), ("YYY", -1)]) -from qiskit.primitives.estimator import Estimator +from qiskit.primitives import Estimator estimator = Estimator() job = estimator.run(qc_example, operator, shots=1000) result = job.result() From c7f10bd894c3148a806dfd366a1a26683fbef1cd Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 18:09:01 -0400 Subject: [PATCH 36/54] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d0bbd6d546cc..090d7a8cf9e8 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Create an example quantum circuit using the `QuantumCircuit` class: import numpy as np from qiskit import QuantumCircuit -# A quantum circuit for preparing the quantum state |000> + i |111> +# 1. A quantum circuit for preparing the quantum state |000> + i |111> qc_example = QuantumCircuit(3) qc_example.h(0) # generate superpostion qc_example.p(np.pi/2,0) # add quantum phase @@ -53,10 +53,12 @@ we use the `compose` function to add a measurement circuit to the example circui the classical registers in ascending order. ```python +# 2. define the classical output to be measurement qc_measure = QuantumCircuit(3,3) qc_measure.measure_all(add_bits=False) qc_compose = qc_example.compose(qc_measure) +# 3. Execute using the Sampler primitive from qiskit.primitives.sampler import Sampler sampler = Sampler() job = sampler.run(qc_compose, shots=1000) @@ -67,9 +69,11 @@ Running this will give an outcome similar to `{0: 0.497, 7: 0.503}` which is `00 To illustrate the power of Estimator, we now use the quantum information toolbox to create the operator `XXY+XYX+YXX-YYY`. ```python +# 2. define the observable to be measured from qiskit.quantum_info import SparsePauliOp operator = SparsePauliOp.from_list([("XXY", 1), ("XYX", 1), ("YXX", 1), ("YYY", -1)]) +# 3. Execute using the Sampler primitive from qiskit.primitives import Estimator estimator = Estimator() job = estimator.run(qc_example, operator, shots=1000) From ddeab4b2f43bb76066121f6ba2288405bd0bfc87 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Tue, 8 Aug 2023 18:10:14 -0400 Subject: [PATCH 37/54] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 090d7a8cf9e8..cfdf05005195 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ To illustrate the power of Estimator, we now use the quantum information toolbox from qiskit.quantum_info import SparsePauliOp operator = SparsePauliOp.from_list([("XXY", 1), ("XYX", 1), ("YXX", 1), ("YYY", -1)]) -# 3. Execute using the Sampler primitive +# 3. Execute using the Estimator primitive from qiskit.primitives import Estimator estimator = Estimator() job = estimator.run(qc_example, operator, shots=1000) From 8730b935b55c86b5c0a4d231d0f84aef0fc67d64 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Wed, 9 Aug 2023 09:32:46 -0400 Subject: [PATCH 38/54] Update README.md Co-authored-by: Luciano Bello --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cfdf05005195..44911cdb127d 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,8 @@ from qiskit import QuantumCircuit qc_example = QuantumCircuit(3) qc_example.h(0) # generate superpostion qc_example.p(np.pi/2,0) # add quantum phase -qc_example.cx(0,1) # condition 1st qubit on 0th qubit -qc_example.cx(0,2) # condition 2nd qubit on 0th qubit +qc_example.cx(0,1) # 0th-qubit-Controlled-NOT gate on 1st qubit +qc_example.cx(0,2) # 0th-qubit-Controlled-NOT gate on 2nd qubit ``` This simple example makes an entangled state known as a GHZ state `(|000> + i |111>)/rt(2)`. It uses the standard quantum From cd0b0bb48ad8aec35ea609977c7a6613aa08eb10 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Wed, 9 Aug 2023 09:33:22 -0400 Subject: [PATCH 39/54] Update README.md Co-authored-by: Luciano Bello --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44911cdb127d..0b1b95ed0545 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ qc_example.cx(0,2) # 0th-qubit-Controlled-NOT gate on 2nd qubit ``` This simple example makes an entangled state known as a GHZ state `(|000> + i |111>)/rt(2)`. It uses the standard quantum -gates: Hadamard gate, Phase gate and CNOT. +gates: Hadamard gate (`h`), Phase gate (`p`), and CNOT gate (`cx`). Once you've made your first quantum circuit, choose which primitive function you will use. Starting with Sampler, we use the `compose` function to add a measurement circuit to the example circuit. In this example we simply map the qubits to From 924d6b265e0665e512fdb1522649695155963ada Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Wed, 9 Aug 2023 09:34:16 -0400 Subject: [PATCH 40/54] Update README.md Co-authored-by: Luciano Bello --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 0b1b95ed0545..a9c7fe2039d8 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,7 @@ This simple example makes an entangled state known as a GHZ state `(|000> + i |1 gates: Hadamard gate (`h`), Phase gate (`p`), and CNOT gate (`cx`). Once you've made your first quantum circuit, choose which primitive function you will use. Starting with Sampler, -we use the `compose` function to add a measurement circuit to the example circuit. In this example we simply map the qubits to -the classical registers in ascending order. +we use `measure_all(inplace=False)` to get a copy of the circuit in which all the qubits are measured: ```python # 2. define the classical output to be measurement From e1d9ba6223aba6e383108bfca6de6c299dc33059 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Wed, 9 Aug 2023 09:35:27 -0400 Subject: [PATCH 41/54] Update README.md Co-authored-by: Luciano Bello --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a9c7fe2039d8..cee1906b23bd 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ qc_example.cx(0,1) # 0th-qubit-Controlled-NOT gate on 1st qubit qc_example.cx(0,2) # 0th-qubit-Controlled-NOT gate on 2nd qubit ``` -This simple example makes an entangled state known as a GHZ state `(|000> + i |111>)/rt(2)`. It uses the standard quantum +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 + |111\rangle)/\sqrt{2}$. It uses the standard quantum gates: Hadamard gate (`h`), Phase gate (`p`), and CNOT gate (`cx`). Once you've made your first quantum circuit, choose which primitive function you will use. Starting with Sampler, From dd4b564b62003a7dd9f7c582bad71c57ed470285 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Wed, 9 Aug 2023 09:36:26 -0400 Subject: [PATCH 42/54] Update README.md Co-authored-by: Luciano Bello --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cee1906b23bd..e609ae5b168c 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ qc_example.cx(0,2) # 0th-qubit-Controlled-NOT gate on 2nd qubit 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 + |111\rangle)/\sqrt{2}$. It uses the standard quantum gates: Hadamard gate (`h`), Phase gate (`p`), and CNOT gate (`cx`). -Once you've made your first quantum circuit, choose which primitive function you will use. Starting with Sampler, +Once you've made your first quantum circuit, choose which primitive function you will use. Starting with `sampler`, we use `measure_all(inplace=False)` to get a copy of the circuit in which all the qubits are measured: ```python From 68675381baa7675a2b226c52849e30579e20cdad Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Wed, 9 Aug 2023 11:27:03 -0400 Subject: [PATCH 43/54] Update README.md Co-authored-by: Luciano Bello --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e609ae5b168c..4540c8a3610c 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ default compiler which works very well in most examples. The following code will ```python from qiskit import transpile -qc_ibm = transpile(qc_example, basis_gates = ['cz', 'sx', 'rz'], coupling_map =[[0, 1], [1, 2]] , optimization_level=3) +qc_transpiled = transpile(qc_example, basis_gates = ['cz', 'sx', 'rz'], coupling_map =[[0, 1], [1, 2]] , optimization_level=3) ``` For further examples of using Qiskit, look at the example scripts in **examples/python** and the tutorials From 75ccf696f18829b3daa03cb0dd77b9aa88538ed4 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Wed, 9 Aug 2023 11:27:31 -0400 Subject: [PATCH 44/54] Update README.md Co-authored-by: Luciano Bello --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4540c8a3610c..cfc2e2ee0ce7 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ on classical computers and you need to use real quantum hardware to scale to lar circuit on hardware requires rewriting them to the basis gates and connectivity of the quantum hardware. The tool that does this is the [transpiler](https://qiskit.org/documentation/tutorials/circuits_advanced/04_transpiler_passes_and_passmanager.html) and Qiskit includes transpiler passes for synthesis, optimization, mapping, and scheduling. However, it also includes a -default compiler which works very well in most examples. The following code will map the example circuit to the `basis_gates = ['cz', 'sx', 'rz']` and a linear chain of qubits with the `coupling_map =[[0, 1], [1, 2]]`. +default compiler which works very well in most examples. 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]]`. ```python from qiskit import transpile From 21fbaa730793933e6104e5a0d3323432508d0231 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Wed, 9 Aug 2023 11:27:58 -0400 Subject: [PATCH 45/54] Update README.md Co-authored-by: Luciano Bello --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cfc2e2ee0ce7..5afbae00b44e 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ https://qiskit.org/documentation/tutorials.html ### Executing your code on real quantum hardware Qiskit provides an abstraction layer that lets users run quantum circuits on hardware from any vendor that provides a compatible interface. -The default way to use Qiskit is to have a runtime environment that provides optimal implementations of `sampler` and `estimator` for a given hardware. 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. The runtime must provide a promise to the user that these primitives functions exist. +The default way to use Qiskit is to have a runtime environment that provides optimal implementations of `sampler` and `estimator` for a given hardware. 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.BaseSampler` and `qiskit.primitives.BaseEstimator` interfaces. * https://github.com/Qiskit/qiskit-ibm-runtime From 8afefbc0e7402779e5e20fc9af64c9983a5c0590 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Wed, 9 Aug 2023 11:28:39 -0400 Subject: [PATCH 46/54] Update README.md Co-authored-by: Luciano Bello --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5afbae00b44e..debb12113e2b 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ print(f" > Expectation values: {result.values}") Running this will give the outcome `4`. For fun, try to assign a value of +/- 1 to each single-qubit operator X and Y and see if you can achieve this outcome. (Spoiler alert: this is not possible!) -Using the Qiskit-provided Sampler and Estimator will not take you very far. The power of quantum computing cannot be simulated +Using the Qiskit-provided `qiskit.primitives.Sampler` and `qiskit.primitives.Estimator` will not take you very far. The power of quantum computing cannot be simulated on classical computers and you need to use real quantum hardware to scale to larger quantum circuits. However, running a quantum circuit on hardware requires rewriting them to the basis gates and connectivity of the quantum hardware. The tool that does this is the [transpiler](https://qiskit.org/documentation/tutorials/circuits_advanced/04_transpiler_passes_and_passmanager.html) From 79f386cb551c6ced17cf1632b57d14f007becfe1 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Wed, 9 Aug 2023 18:27:09 -0400 Subject: [PATCH 47/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index debb12113e2b..38f9423737cf 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ **Qiskit** is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives. -This library is the core component of Qiskit, **Terra**, which contains the building blocks for creating +This library is the core component of Qiskit, which contains the building blocks for creating and working with quantum circuits, quantum operators, and primitive functions (sampler and estimator). It also contains a transpiler that supports optimizing quantum circuits and a quantum information toolbox for creating advanced quantum operators. From 6ac3ad048f1196cda88a37908710061e761b287f Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Thu, 10 Aug 2023 15:36:38 -0400 Subject: [PATCH 48/54] Update README.md Co-authored-by: Abby Mitchell <23662430+javabster@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 38f9423737cf..22de4b950e66 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ result = job.result() print(f" > Quasi probability distribution: {result.quasi_dists}") ``` Running this will give an outcome similar to `{0: 0.497, 7: 0.503}` which is `000` 50% of the time and `111` 50% of the time up to statistical fluctuations. -To illustrate the power of Estimator, we now use the quantum information toolbox to create the operator `XXY+XYX+YXX-YYY`. +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. ```python # 2. define the observable to be measured From e679cdb3fc6301a5fb0833ddf03cd04e1c3f9e4c Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Thu, 10 Aug 2023 15:37:07 -0400 Subject: [PATCH 49/54] Update README.md Co-authored-by: Luciano Bello --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 22de4b950e66..09cfe1fe611c 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ and see if you can achieve this outcome. (Spoiler alert: this is not possible!) Using the Qiskit-provided `qiskit.primitives.Sampler` and `qiskit.primitives.Estimator` will not take you very far. The power of quantum computing cannot be simulated on classical computers and you need to use real quantum hardware to scale to larger quantum circuits. However, running a quantum circuit on hardware requires rewriting them to the basis gates and connectivity of the quantum hardware. -The tool that does this is the [transpiler](https://qiskit.org/documentation/tutorials/circuits_advanced/04_transpiler_passes_and_passmanager.html) +The tool that does this is the [transpiler](https://qiskit.org/documentation/apidoc/transpiler.html) and Qiskit includes transpiler passes for synthesis, optimization, mapping, and scheduling. However, it also includes a default compiler which works very well in most examples. 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]]`. From a3c20e3236587fdc2c6f5c89956e5bf86dfcdf2a Mon Sep 17 00:00:00 2001 From: Blake Johnson Date: Fri, 11 Aug 2023 14:33:19 -0400 Subject: [PATCH 50/54] Apply suggestions from code review Co-authored-by: Matthew Treinish --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 09cfe1fe611c..fb8bbd0e3555 100644 --- a/README.md +++ b/README.md @@ -104,14 +104,17 @@ https://qiskit.org/documentation/tutorials.html ### Executing your code on real quantum hardware Qiskit provides an abstraction layer that lets users run quantum circuits on hardware from any vendor that provides a compatible interface. -The default way to use Qiskit is to have a runtime environment that provides optimal implementations of `sampler` and `estimator` for a given hardware. 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.BaseSampler` and `qiskit.primitives.BaseEstimator` interfaces. +The default way to use Qiskit is to have a runtime environment that provides optimal implementations of `sampler` and `estimator` for a given hardware. 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.BaseSampler` and `qiskit.primitives.BaseEstimator` interfaces. For example, +some packages that provide implementations of a runtime primitive implementation are: * https://github.com/Qiskit/qiskit-ibm-runtime -As Qiskit transitions to the runtime environment, some hardware is only supported with the ``providers`` interface; however, each provider may perform different types of pre- and post-processing and return outcomes that are vendor-defined: +Qiskit also provides a lower-level abstract interface for describing quantum backends. This interface, located in +``qiskit.providers``, defines an abstract `BackendV2` class that providers can implement to represent their +hardware or simulators to Qiskit. The backend class includes a common interface for executing circuits on the backends; however, in this interface each provider may perform different types of pre- and post-processing and return outcomes that are vendor-defined. Some examples of published provider packages that interface for will real hardware are: -* https://github.com/Qiskit/qiskit-ibmq-provider -* https://github.com/Qiskit-Partners/qiskit-ionq +* https://github.com/Qiskit/qiskit-ibm-provider +* https://github.com/qiskit-community/qiskit-ionq * https://github.com/Qiskit-Partners/qiskit-aqt-provider * https://github.com/qiskit-community/qiskit-braket-provider * https://github.com/qiskit-community/qiskit-quantinuum-provider From 443ced029489aa808cb87df7deb0efc29f01f71f Mon Sep 17 00:00:00 2001 From: Blake Johnson Date: Fri, 11 Aug 2023 14:37:04 -0400 Subject: [PATCH 51/54] Apply suggestions from code review --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fb8bbd0e3555..b330f0ca547d 100644 --- a/README.md +++ b/README.md @@ -104,14 +104,14 @@ https://qiskit.org/documentation/tutorials.html ### Executing your code on real quantum hardware Qiskit provides an abstraction layer that lets users run quantum circuits on hardware from any vendor that provides a compatible interface. -The default way to use Qiskit is to have a runtime environment that provides optimal implementations of `sampler` and `estimator` for a given hardware. 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.BaseSampler` and `qiskit.primitives.BaseEstimator` interfaces. For example, +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.BaseSampler` and `qiskit.primitives.BaseEstimator` interfaces. For example, some packages that provide implementations of a runtime primitive implementation are: * https://github.com/Qiskit/qiskit-ibm-runtime Qiskit also provides a lower-level abstract interface for describing quantum backends. This interface, located in ``qiskit.providers``, defines an abstract `BackendV2` class that providers can implement to represent their -hardware or simulators to Qiskit. The backend class includes a common interface for executing circuits on the backends; however, in this interface each provider may perform different types of pre- and post-processing and return outcomes that are vendor-defined. Some examples of published provider packages that interface for will real hardware are: +hardware or simulators to Qiskit. The backend class includes a common interface for executing circuits on the backends; however, in this interface each provider may perform different types of pre- and post-processing and return outcomes that are vendor-defined. Some examples of published provider packages that interface with real hardware are: * https://github.com/Qiskit/qiskit-ibm-provider * https://github.com/qiskit-community/qiskit-ionq From bae815488883cc7908bd4ef5ef9e224761374cb9 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Wed, 16 Aug 2023 12:51:42 +0200 Subject: [PATCH 52/54] new example --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a6de91c52669..b03673f4cbd8 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,10 @@ from qiskit import QuantumCircuit # 1. A quantum circuit for preparing the quantum state |000> + i |111> qc_example = QuantumCircuit(3) -qc_example.h(0) # generate superpostion -qc_example.p(np.pi/2,0) # add quantum phase -qc_example.cx(0,1) # 0th-qubit-Controlled-NOT gate on 1st qubit -qc_example.cx(0,2) # 0th-qubit-Controlled-NOT gate on 2nd qubit +qc_example.h(0) # generate superpostion +qc_example.p(np.pi/2,0) # add quantum phase +qc_example.cx(0,1) # 0th-qubit-Controlled-NOT gate on 1st qubit +qc_example.cx(0,2) # 0th-qubit-Controlled-NOT gate on 2nd qubit ``` 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 + |111\rangle)/\sqrt{2}$. It uses the standard quantum gates: Hadamard gate (`h`), Phase gate (`p`), and CNOT gate (`cx`). @@ -57,15 +57,13 @@ Once you've made your first quantum circuit, choose which primitive function you we use `measure_all(inplace=False)` to get a copy of the circuit in which all the qubits are measured: ```python -# 2. define the classical output to be measurement -qc_measure = QuantumCircuit(3,3) -qc_measure.measure_all(add_bits=False) -qc_compose = qc_example.compose(qc_measure) +# 2. Add the classical output to be measurement in a different circuit +qc_measured = qc_example.measure_all(inplace=False) # 3. Execute using the Sampler primitive from qiskit.primitives.sampler import Sampler sampler = Sampler() -job = sampler.run(qc_compose, shots=1000) +job = sampler.run(qc_measured, shots=1000) result = job.result() print(f" > Quasi probability distribution: {result.quasi_dists}") ``` From 0d6bc53244c417c039cf06a1424810393002e717 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Wed, 16 Aug 2023 15:54:18 +0200 Subject: [PATCH 53/54] Update README.md Co-authored-by: Blake Johnson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b03673f4cbd8..4b077d43649b 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Once you've made your first quantum circuit, choose which primitive function you we use `measure_all(inplace=False)` to get a copy of the circuit in which all the qubits are measured: ```python -# 2. Add the classical output to be measurement in a different circuit +# 2. Add the classical output in the form of measurement of all qubits qc_measured = qc_example.measure_all(inplace=False) # 3. Execute using the Sampler primitive From e42821f395034771858f93d17e392dbf6f36db34 Mon Sep 17 00:00:00 2001 From: Blake Johnson Date: Wed, 16 Aug 2023 11:43:35 -0400 Subject: [PATCH 54/54] Update README.md Co-authored-by: Matthew Treinish --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b077d43649b..29bbd93410b9 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ hardware or simulators to Qiskit. The backend class includes a common interface * https://github.com/Qiskit/qiskit-ibm-provider * https://github.com/qiskit-community/qiskit-ionq -* https://github.com/Qiskit-Partners/qiskit-aqt-provider +* https://github.com/qiskit-community/qiskit-aqt-provider * https://github.com/qiskit-community/qiskit-braket-provider * https://github.com/qiskit-community/qiskit-quantinuum-provider * https://github.com/rigetti/qiskit-rigetti