Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 28 additions & 48 deletions docs/tutorials/fractional-gates.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"\n",
"Before starting this tutorial, be sure you have the following installed:\n",
"- Qiskit SDK v2.0 or later, with [visualization](/docs/api/qiskit/visualization) support\n",
"- Qiskit Runtime v0.37 or later (`pip install qiskit-ibm-runtime`)\n",
"- Qiskit Runtime v0.41 or later (`pip install qiskit-ibm-runtime`)\n",
"- Qiskit Basis Constructor (`pip install qiskit_basis_constructor`)"
]
},
Expand Down Expand Up @@ -188,15 +188,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "fd577102",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Backend: ibm_fez\n",
"Backend: ibm_boston\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"No fractional gates: ['cz', 'id', 'rz', 'sx', 'x']\n",
"With fractional gates: ['cz', 'id', 'rx', 'rz', 'rzz', 'sx', 'x']\n"
]
Expand Down Expand Up @@ -244,7 +250,7 @@
"where $|\\Phi(x)\\rangle$ represents the feature-mapped quantum state.\n",
"\n",
"We manually construct a ZZ feature map circuit using RZZ gates.\n",
"Although Qiskit provides a built-in `zz_feature_map`, it does not currently support RZZ gates as of Qiskit v2.0.2 ([see issue](https://github.com/Qiskit/qiskit/issues/14469)).\n",
"Although Qiskit provides a built-in `zz_feature_map`, it does not currently support RZZ gates as of Qiskit v2.4.1 ([see issue](https://github.com/Qiskit/qiskit/issues/14469)).\n",
"\n",
"Next, we compute the kernel function for identical inputs - for example, $K(x, x) = 1$.\n",
"On noisy quantum computers, this value may be less than 1 due to noise.\n",
Expand Down Expand Up @@ -428,7 +434,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"OrderedDict([('rz', 35), ('rzz', 18), ('x', 13), ('rx', 9), ('measure', 4), ('barrier', 2)])\n"
"OrderedDict({'rz': 35, 'rzz': 18, 'x': 13, 'rx': 9, 'measure': 4, 'barrier': 2})\n"
]
},
{
Expand Down Expand Up @@ -505,15 +511,7 @@
"execution_count": 12,
"id": "a703b939",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"d4bninsi51bc738j97eg\n"
]
}
],
"outputs": [],
"source": [
"job = sampler_f.run(t_qc_f, shots=shots)\n",
"print(job.job_id())"
Expand Down Expand Up @@ -545,12 +543,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[0.9005, 0.647, 0.3345, 0.355, 0.3315, 0.174, 0.1875, 0.149, 0.1175, 0.085]\n"
"[0.8995, 0.7985, 0.57, 0.717, 0.5795, 0.5785, 0.456, 0.3155, 0.1785, 0.211]\n"
]
}
],
"source": [
"# job = service.job(\"d1obougt0npc73flhiag\")\n",
"# job = service.job(\"d8585pg0bvlc73d5aai0\")\n",
"result = job.result()\n",
"fidelity_f = [fidelity(result=res) for res in result]\n",
"print(fidelity_f)\n",
Expand Down Expand Up @@ -589,7 +587,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"OrderedDict([('rz', 130), ('sx', 80), ('cz', 36), ('measure', 4), ('barrier', 2)])\n"
"OrderedDict({'rz': 130, 'sx': 80, 'cz': 36, 'measure': 4, 'barrier': 2})\n"
]
},
{
Expand Down Expand Up @@ -647,15 +645,7 @@
"execution_count": 18,
"id": "983dd26f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"d4bnirvnmdfs73ae3a2g\n"
]
}
],
"outputs": [],
"source": [
"job = sampler_c.run(pubs=zip(t_qc_c, params), shots=shots)\n",
"print(job.job_id())"
Expand All @@ -671,13 +661,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[0.6675, 0.5725, 0.098, 0.102, 0.065, 0.0235, 0.006, 0.0015, 0.0015, 0.002]\n"
"[0.8875, 0.623, 0.4395, 0.2425, 0.1985, 0.085, 0.029, 0.003, 0.0005, 0.0]\n"
]
}
],
"source": [
"# step 4: post-processing\n",
"# job = service.job(\"d1obp8j3rr0s73bg4810\")\n",
"# job = service.job(\"d8585uegbeec73aorp10\")\n",
"result = job.result()\n",
"fidelity_c = [fidelity(res) for res in result]\n",
"print(fidelity_c)\n",
Expand All @@ -704,7 +694,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x12bcaac50>"
"<matplotlib.legend.Legend at 0x110fac830>"
]
},
"execution_count": 20,
Expand Down Expand Up @@ -740,7 +730,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x12bdef310>"
"<matplotlib.legend.Legend at 0x111b46900>"
]
},
"execution_count": 21,
Expand Down Expand Up @@ -776,7 +766,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x12be8ac90>"
"<matplotlib.legend.Legend at 0x11057d6a0>"
]
},
"execution_count": 22,
Expand Down Expand Up @@ -812,7 +802,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x12bea8290>"
"<matplotlib.legend.Legend at 0x112175a90>"
]
},
"execution_count": 23,
Expand Down Expand Up @@ -973,7 +963,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"OrderedDict([('rz', 23), ('sx', 16), ('cz', 4)])\n"
"OrderedDict({'rz': 23, 'sx': 16, 'cz': 4})\n"
]
},
{
Expand Down Expand Up @@ -1015,7 +1005,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"OrderedDict([('rz', 22), ('sx', 14), ('cz', 4), ('rx', 1)])\n"
"OrderedDict({'rz': 22, 'sx': 14, 'cz': 4, 'rx': 1})\n"
]
},
{
Expand Down Expand Up @@ -1122,7 +1112,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"OrderedDict([('rz', 16), ('rx', 9), ('cz', 4)])\n"
"OrderedDict({'rz': 16, 'rx': 9, 'cz': 4})\n"
]
},
{
Expand Down Expand Up @@ -1162,8 +1152,8 @@
"source": [
"### Issue: Invalid RZZ angles might remain after transpilation\n",
"\n",
"As of Qiskit v2.0.3, there are known issues where RZZ gates with invalid angles may remain in the circuits even after transpilation.\n",
"The issue typically arises under the following conditions."
"As of Qiskit v2.4.1, there is a known issue where RZZ gates with invalid angles might remain in the circuits even after transpilation.\n",
"The issue typically arises under the following condition."
]
},
{
Expand All @@ -1175,17 +1165,7 @@
"\n",
"When the `target` option is used with `generate_preset_pass_manager` or `transpiler`, the specialized transpiler pass `FoldRzzAngle` is not invoked.\n",
"To ensure proper handling of RZZ angles for fractional gates, we recommend always using the `backend` option instead.\n",
"See [this issue](https://github.com/Qiskit/qiskit/issues/14318) for more details."
]
},
{
"cell_type": "markdown",
"id": "ac27c7cb",
"metadata": {},
"source": [
"#### Failure when circuits contain certain gates\n",
"\n",
"If your circuit includes certain gates such as `XXPlusYYGate`, the Qiskit transpiler may generate RZZ gates with invalid angles.\n",
"See [this issue](https://github.com/Qiskit/qiskit/issues/14318) for more details.\n",
"If you encounter this issue, see this [GitHub issue](https://github.com/Qiskit/qiskit-ibm-runtime/issues/2256#issuecomment-2889487152) for a workaround."
]
},
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading