Skip to content

Update circuits in guides #2852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 27, 2025
2 changes: 1 addition & 1 deletion docs/guides/circuit-library.ipynb
Original file line number Diff line number Diff line change
@@ -336,7 +336,7 @@
"\n",
"For example, the \"quantum volume\" benchmark measures how accurately a quantum computer executes a type of random quantum circuit. The score of the quantum computer increases with the size of the circuit it can reliably run. This takes into account all aspects of the computer, including qubit count, instruction fidelity, qubit connectivity, and the software stack transpiling and post-processing results. Read more about quantum volume in the original [quantum volume paper](https://arxiv.org/abs/1811.12926).\n",
"\n",
"The following code shows an example of a quantum volume circuit built in Qiskit that runs on four qubits (the `su4_` blocks are randomized two-qubit gates)."
"The following code shows an example of a quantum volume circuit built in Qiskit that runs on four qubits (the `unitary` blocks are randomized two-qubit gates)."
]
},
{
6 changes: 3 additions & 3 deletions docs/guides/defaults-and-configuration-options.ipynb
Original file line number Diff line number Diff line change
@@ -68,14 +68,14 @@
],
"source": [
"from qiskit import QuantumCircuit\n",
"from qiskit.circuit.library import GroverOperator, Diagonal\n",
"from qiskit.circuit.library import grover_operator, DiagonalGate\n",
"from qiskit_ibm_runtime.fake_provider import FakeSherbrooke\n",
"\n",
"# Create circuit to test transpiler on\n",
"oracle = Diagonal([1] * 7 + [-1])\n",
"oracle = DiagonalGate([1] * 7 + [-1])\n",
"qc = QuantumCircuit(3)\n",
"qc.h([0, 1, 2])\n",
"qc = qc.compose(GroverOperator(oracle))\n",
"qc = qc.compose(grover_operator(oracle))\n",
"\n",
"# Add measurements to the circuit\n",
"qc.measure_all()\n",
62 changes: 31 additions & 31 deletions docs/guides/get-started-with-primitives.ipynb
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "8a3313d3-c8f5-494d-9fc1-4159796d4335",
"id": "ac2e4df5-d03e-442d-857b-a1ad8b2a5c85",
"metadata": {},
"source": [
"# Get started with primitives\n",
@@ -35,7 +35,7 @@
},
{
"cell_type": "markdown",
"id": "df6e2c9a-daa8-4d40-85cf-3afdffd597b1",
"id": "0009caf4-5088-4bd2-b3b4-bd280d32500b",
"metadata": {},
"source": [
"<span id=\"start-estimator\"></span>\n",
@@ -53,7 +53,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "dbd3ecf7-8d27-444c-a74c-e83da6cd2718",
"id": "566136c4-c605-43dc-b2cc-9586fcdafd8e",
"metadata": {},
"outputs": [
{
@@ -77,7 +77,7 @@
},
{
"cell_type": "markdown",
"id": "d645615e-bf76-48c6-a3f2-e1327330c4cb",
"id": "8c64278b-cba0-435d-a81e-01907dc94b82",
"metadata": {},
"source": [
"### 2. Create a circuit and an observable\n",
@@ -88,7 +88,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "4e36a987-6737-409e-bafa-c6ba4b10119a",
"id": "92bd800f-1d25-47bd-8f6c-19eb47bfc817",
"metadata": {},
"outputs": [
{
@@ -114,15 +114,15 @@
}
],
"source": [
"from qiskit.circuit.library import QAOAAnsatz\n",
"from qiskit.circuit.library import qaoa_ansatz\n",
"from qiskit.quantum_info import SparsePauliOp\n",
"\n",
"entanglement = [tuple(edge) for edge in backend.coupling_map.get_edges()]\n",
"observable = SparsePauliOp.from_sparse_list(\n",
" [(\"ZZ\", [i, j], 0.5) for i, j in entanglement],\n",
" num_qubits=backend.num_qubits,\n",
")\n",
"circuit = QAOAAnsatz(observable, reps=2)\n",
"circuit = qaoa_ansatz(observable, reps=2)\n",
"# the circuit is parametrized, so we will define the parameter values for execution\n",
"param_values = [0.1, 0.2, 0.3, 0.4]\n",
"\n",
@@ -131,7 +131,7 @@
},
{
"cell_type": "markdown",
"id": "52f932e6-9774-4847-a7c2-51d5eba5e8b9",
"id": "accac29a-88fc-41fc-9799-05a13ea851b8",
"metadata": {},
"source": [
"The circuit and observable need to be transformed to only use instructions supported by the QPU (referred to as *instruction set architecture (ISA)* circuits). We'll use the transpiler to do this."
@@ -140,7 +140,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "dc9e53b9-ee88-4e8e-a562-3d18ad1fdddc",
"id": "4ad40fd6-f46b-4aa5-be9f-8ece16af08ae",
"metadata": {},
"outputs": [
{
@@ -162,7 +162,7 @@
},
{
"cell_type": "markdown",
"id": "99090992-bc33-4f4c-9b7e-f24e430dda7c",
"id": "eaece075-3e4b-4967-a816-c61f120da91f",
"metadata": {},
"source": [
"### 3. Initialize Qiskit Runtime Estimator\n",
@@ -173,7 +173,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "fb2a2241-b2ce-4635-ae64-450f87aba66f",
"id": "d21ec1a4-44d9-45ab-9cce-eec9bcee46d0",
"metadata": {},
"outputs": [],
"source": [
@@ -184,7 +184,7 @@
},
{
"cell_type": "markdown",
"id": "84be9ea0-ff02-4c93-84e6-f135ab5d01d0",
"id": "c4fb0602-4d03-45b0-b1c9-86552765209b",
"metadata": {},
"source": [
"### 4. Invoke the Estimator and get results\n",
@@ -195,7 +195,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "cd4aec24-2b30-40cb-9e19-558c96204b9b",
"id": "97432adb-56f5-4b72-972f-77ac30f31b32",
"metadata": {},
"outputs": [
{
@@ -222,7 +222,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "87eb1b90-13d2-4a08-a825-b1650ef60572",
"id": "8ed2324f-4e94-42c2-8515-7778879d252e",
"metadata": {},
"outputs": [
{
@@ -244,7 +244,7 @@
},
{
"cell_type": "markdown",
"id": "145ed101-4a62-4d9c-8fdc-f81e60395ccb",
"id": "eb70f63d-e449-4f0c-9ba4-e0ddab820ed6",
"metadata": {},
"source": [
"<span id=\"start-sampler\"></span>\n",
@@ -260,7 +260,7 @@
{
"cell_type": "code",
"execution_count": 7,
"id": "b787ef29-3d08-46c6-8e10-4906202e8964",
"id": "c96c0905-4328-4383-83d3-b46debaddcfb",
"metadata": {},
"outputs": [],
"source": [
@@ -274,7 +274,7 @@
},
{
"cell_type": "markdown",
"id": "f12847fa-43eb-4a83-8711-0b4b737b76ae",
"id": "f4a189ff-798e-4655-a41f-31b75f643df4",
"metadata": {},
"source": [
"### 2. Create a circuit\n",
@@ -285,22 +285,22 @@
{
"cell_type": "code",
"execution_count": 8,
"id": "08561f08-9767-4611-9d29-fae2911dc6fa",
"id": "9a709493-bf96-45d8-9aa0-d04a9a61bf7b",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from qiskit.circuit.library import EfficientSU2\n",
"from qiskit.circuit.library import efficient_su2\n",
"\n",
"circuit = EfficientSU2(127, entanglement=\"linear\", flatten=True)\n",
"circuit = efficient_su2(127, entanglement=\"linear\")\n",
"circuit.measure_all()\n",
"# The circuit is parametrized, so we will define the parameter values for execution\n",
"param_values = np.random.rand(circuit.num_parameters)"
]
},
{
"cell_type": "markdown",
"id": "eaf9bb06-f53c-4482-8c52-523fe9f2ff88",
"id": "8cc0b51c-a9d4-4308-b4be-ffa78b5364b1",
"metadata": {},
"source": [
"Use the transpiler to get an ISA circuit."
@@ -309,7 +309,7 @@
{
"cell_type": "code",
"execution_count": 9,
"id": "88512fb3-bb55-46a0-b954-a5da67277d3f",
"id": "84d8fa59-fd9c-4a87-b859-1bc6dc6ecc12",
"metadata": {},
"outputs": [
{
@@ -330,7 +330,7 @@
},
{
"cell_type": "markdown",
"id": "de82cee0-ddb0-4b09-a407-fe76e7fb1534",
"id": "977eb6da-9ea0-4b0a-9da2-6879595c83ac",
"metadata": {},
"source": [
"### 3. Initialize the Qiskit Runtime Sampler\n",
@@ -341,7 +341,7 @@
{
"cell_type": "code",
"execution_count": 10,
"id": "5c25ef75-2436-40de-a1e8-54170199f91a",
"id": "2f4c0696-6da4-4a79-bfe5-141fa01bfb38",
"metadata": {},
"outputs": [],
"source": [
@@ -352,7 +352,7 @@
},
{
"cell_type": "markdown",
"id": "6c17e68f-9566-4770-9049-2f89bb7bac16",
"id": "7aafaf2a-cf1e-4a58-8178-cfc52ad54fc7",
"metadata": {},
"source": [
"### 4. Invoke the Sampler and get results\n",
@@ -363,7 +363,7 @@
{
"cell_type": "code",
"execution_count": 11,
"id": "a89b3bbb-2c53-490e-ad9e-ede2918c779f",
"id": "0d45665b-b6f4-46d4-a539-3628f145c0cb",
"metadata": {},
"outputs": [
{
@@ -390,7 +390,7 @@
{
"cell_type": "code",
"execution_count": 12,
"id": "a3516d62-2cb2-4763-8bde-7d05a01dc1a9",
"id": "a928521f-5dc8-4657-b6ea-6222f08a6f85",
"metadata": {},
"outputs": [
{
@@ -413,7 +413,7 @@
},
{
"cell_type": "markdown",
"id": "4b078dd6-4ffd-4fb0-8e8c-c69f48d0b673",
"id": "81b8764a-4ec5-4c8c-8690-bcdc540862d3",
"metadata": {},
"source": [
"<span id=\"backend\"></span>\n",
@@ -430,7 +430,7 @@
},
{
"cell_type": "markdown",
"id": "b5309fd1-1b72-4cff-af4c-63287e539611",
"id": "d207c7e0-2b47-4964-af86-cfce2f0b4ac8",
"metadata": {},
"source": [
"### Example: BackendEstimator\n",
@@ -458,7 +458,7 @@
},
{
"cell_type": "markdown",
"id": "1cd6f101-8c3d-4d6d-83f4-712ae1f148f6",
"id": "d85f35a1-1f27-4c8f-ab17-4b0f24d07a0b",
"metadata": {},
"source": [
"### Similarities and differences between backend and Runtime primitives\n",
@@ -477,7 +477,7 @@
},
{
"cell_type": "markdown",
"id": "478bf08c-0a2e-4bc4-8f25-121fd2280a94",
"id": "5dd510e3-d934-4a15-89ea-a0b3c276f03e",
"metadata": {},
"source": [
"## Next steps\n",
Loading