{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "d23d84b3", "metadata": { "execution": { "iopub.execute_input": "2024-04-26T18:16:51.148384Z", "iopub.status.busy": "2024-04-26T18:16:51.148104Z", "iopub.status.idle": "2024-04-26T18:16:51.151777Z", "shell.execute_reply": "2024-04-26T18:16:51.151353Z" }, "nbsphinx": "hidden" }, "outputs": [], "source": [ "# Copyright 2024 Keysight Technologies Inc." ] }, { "cell_type": "raw", "id": "34ccbe58", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Example: Gate synthesis\n", "=======================\n", "\n", "This example demonstrates how the built-in compiler can be used to perform gate\n", "synthesis.\n", "\n", "Synthesizing Single-Qubit Gates\n", "-------------------------------\n", "We begin by generating a random gate in :math:`SU(2)`\\; we will synthesize this gate\n", "later." ] }, { "cell_type": "code", "execution_count": 2, "id": "5b8168cf", "metadata": { "execution": { "iopub.execute_input": "2024-04-26T18:16:51.153672Z", "iopub.status.busy": "2024-04-26T18:16:51.153402Z", "iopub.status.idle": "2024-04-26T18:16:53.693041Z", "shell.execute_reply": "2024-04-26T18:16:53.692580Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "
True-Q formatting will not be loaded without trusting this\n", "notebook or rerunning the affected cells. Notebooks can be marked as trusted by clicking\n", "\"File -> Trust Notebook\".
\n", "\n", "\n", "\n", "
\n", "
\n", "
Name:
\n", "
\n", "
    \n", "
  • Gate(Y, X, ...)
  • \n", "
\n", "
\n", "\n", " \n", "\n", " \n", "\n", "\n", " \n", "
Generators:
\n", "
\n", "
    \n", "
  • 'Y': 86.208
  • \n", "
  • 'X': 21.93
  • \n", "
  • 'Z': -160.518
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 0.81\n", " \n", " \n", " 0.34j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.28\n", " \n", " \n", " 0.40j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.05\n", " \n", " \n", " -0.48j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.83\n", " \n", " \n", " -0.28j\n", " \n", " \n", " \n", "\n", "\n", "
  • \n", "
\n", "
\n", "
\n", "
\n" ], "text/plain": [ "Gate(Y, X, ...)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import trueq as tq\n", "\n", "# create a Haar random SU(2) gate and print its matrix representation\n", "U = tq.Gate.random(2)\n", "U" ] }, { "cell_type": "raw", "id": "4c00623c", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "We can perform single qubit gate decomposition into a number of possible \"modes\".\n", "Here we decompose the gate ``U`` into a ZXZXZ decomposition, which is short hand\n", "for :math:`Z(\\theta)X(90)Z(\\phi)X(90)Z(\\gamma)`\\. See\n", ":py:class:`~trueq.math.decomposition.QubitMode` for a complete list of all available\n", "single qubit decompositions." ] }, { "cell_type": "code", "execution_count": 3, "id": "911c6360", "metadata": { "execution": { "iopub.execute_input": "2024-04-26T18:16:53.695395Z", "iopub.status.busy": "2024-04-26T18:16:53.694901Z", "iopub.status.idle": "2024-04-26T18:16:53.698430Z", "shell.execute_reply": "2024-04-26T18:16:53.698011Z" } }, "outputs": [ { "data": { "text/plain": [ "[('Z', -257.7385690112652),\n", " ('X', 90),\n", " ('Z', 122.042638725902),\n", " ('X', 90),\n", " ('Z', -106.283141468562)]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "synthesized_gate = tq.math.QubitMode.ZXZXZ.decompose(U)\n", "\n", "# print the synthesized gate as a list of single-qubit rotations about Z and X\n", "synthesized_gate" ] }, { "cell_type": "raw", "id": "5864c252", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Synthesizing Two-Qubit Gates\n", "----------------------------\n", "In the event that we want to express a two-qubit gate in terms of a different\n", "two-qubit gate, we can use the compiler to synthesize the desired gate.\n", "Here we decompose a random :math:`SU(4)` operation so that it can be implemented\n", "using iSWAP gates." ] }, { "cell_type": "code", "execution_count": 4, "id": "9a791856", "metadata": { "execution": { "iopub.execute_input": "2024-04-26T18:16:53.700994Z", "iopub.status.busy": "2024-04-26T18:16:53.700691Z", "iopub.status.idle": "2024-04-26T18:16:53.742901Z", "shell.execute_reply": "2024-04-26T18:16:53.742470Z" }, "lines_to_next_cell": 2 }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "
True-Q formatting will not be loaded without trusting this\n", "notebook or rerunning the affected cells. Notebooks can be marked as trusted by clicking\n", "\"File -> Trust Notebook\".
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", "
\n", "
\n", "
Circuit
\n", "
\n", "
\n", "
Key:
\n", "
\n", " No key present in circuit.\n", "
\n", "
\n", "
\n", "
\n", "
\n", "
\n", "  \n", "
\n", "
Marker 0
\n", " Compilation tools may only recompile cycles with equal markers.\n", "
\n", "
\n", "
\n", "
\n", " \n", " (0):\n", " Gate(Y, X, ...)\n", " \n", " \n", "\n", "\n", "
\n", "
\n", "
Name:
\n", "
\n", "
    \n", "
  • Gate(Y, X, ...)
  • \n", "
\n", "
\n", "\n", " \n", "\n", " \n", "\n", "\n", " \n", "
Generators:
\n", "
\n", "
    \n", "
  • 'Y': -30.76
  • \n", "
  • 'X': 167.589
  • \n", "
  • 'Z': 74.986
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " -0.18\n", " \n", " \n", " -0.36j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.14\n", " \n", " \n", " -0.90j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.46\n", " \n", " \n", " -0.79j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.08\n", " \n", " \n", " 0.40j\n", " \n", " \n", " \n", "\n", "\n", "
  • \n", "
\n", "
\n", "
\n", "
\n", "\n", "
\n", "
\n", "
\n", " \n", " (1):\n", " Gate(Y, X, ...)\n", " \n", " \n", "\n", "\n", "
\n", "
\n", "
Name:
\n", "
\n", "
    \n", "
  • Gate(Y, X, ...)
  • \n", "
\n", "
\n", "\n", " \n", "\n", " \n", "\n", "\n", " \n", "
Generators:
\n", "
\n", "
    \n", "
  • 'Y': -81.07
  • \n", "
  • 'X': 50.75
  • \n", "
  • 'Z': -33.329
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 0.51\n", " \n", " \n", " -0.46j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.08\n", " \n", " \n", " -0.73j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.62\n", " \n", " \n", " 0.39j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.05\n", " \n", " \n", " -0.68j\n", " \n", " \n", " \n", "\n", "\n", "
  • \n", "
\n", "
\n", "
\n", "
\n", "\n", "
\n", "
\n", "
\n", "  \n", "
\n", "
Marker 0
\n", " Compilation tools may only recompile cycles with equal markers.\n", "
\n", "
\n", "
\n", "
\n", " \n", " (0, 1):\n", " Gate.iswap\n", " \n", " \n", "\n", "\n", "
\n", "
\n", "
Name:
\n", "
\n", "
    \n", "
  • Gate.iswap
  • \n", "
\n", "
\n", "\n", " \n", "
Aliases:
\n", "
\n", "
    \n", "
  • Gate.iswap
  • \n", "
\n", "
\n", "\n", " \n", "
Likeness:
\n", "
\n", "
    \n", "
  • iSWAP
  • \n", "
\n", "
\n", "\n", "\n", " \n", "
Generators:
\n", "
\n", "
    \n", "
  • 'YY': -90.0
  • \n", "
  • 'XX': -90.0
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 1.00\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1.00j\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1.00j\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1.00\n", " \n", " \n", " \n", "\n", "\n", "
  • \n", "
\n", "
\n", "
\n", "
\n", "\n", "
\n", "
 
\n", "
\n", "  \n", "
\n", "
Marker 0
\n", " Compilation tools may only recompile cycles with equal markers.\n", "
\n", "
\n", "
\n", "
\n", " \n", " (0):\n", " Gate(Y, X, ...)\n", " \n", " \n", "\n", "\n", "
\n", "
\n", "
Name:
\n", "
\n", "
    \n", "
  • Gate(Y, X, ...)
  • \n", "
\n", "
\n", "\n", " \n", "\n", " \n", "\n", "\n", " \n", "
Generators:
\n", "
\n", "
    \n", "
  • 'Y': 67.651
  • \n", "
  • 'X': 34.193
  • \n", "
  • 'Z': 33.037
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " -0.60\n", " \n", " \n", " -0.53j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.02\n", " \n", " \n", " 0.61j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.50\n", " \n", " \n", " -0.34j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.13\n", " \n", " \n", " -0.78j\n", " \n", " \n", " \n", "\n", "\n", "
  • \n", "
\n", "
\n", "
\n", "
\n", "\n", "
\n", "
\n", "
\n", " \n", " (1):\n", " Gate(Y, X, ...)\n", " \n", " \n", "\n", "\n", "
\n", "
\n", "
Name:
\n", "
\n", "
    \n", "
  • Gate(Y, X, ...)
  • \n", "
\n", "
\n", "\n", " \n", "\n", " \n", "\n", "\n", " \n", "
Generators:
\n", "
\n", "
    \n", "
  • 'Y': 0.889
  • \n", "
  • 'X': 43.484
  • \n", "
  • 'Z': -83.916
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 0.17\n", " \n", " \n", " -0.93j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.28\n", " \n", " \n", " 0.19j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.29\n", " \n", " \n", " 0.18j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.92\n", " \n", " \n", " -0.21j\n", " \n", " \n", " \n", "\n", "\n", "
  • \n", "
\n", "
\n", "
\n", "
\n", "\n", "
\n", "
\n", "
\n", "  \n", "
\n", "
Marker 0
\n", " Compilation tools may only recompile cycles with equal markers.\n", "
\n", "
\n", "
\n", "
\n", " \n", " (0, 1):\n", " Gate.iswap\n", " \n", " \n", "\n", "\n", "
\n", "
\n", "
Name:
\n", "
\n", "
    \n", "
  • Gate.iswap
  • \n", "
\n", "
\n", "\n", " \n", "
Aliases:
\n", "
\n", "
    \n", "
  • Gate.iswap
  • \n", "
\n", "
\n", "\n", " \n", "
Likeness:
\n", "
\n", "
    \n", "
  • iSWAP
  • \n", "
\n", "
\n", "\n", "\n", " \n", "
Generators:
\n", "
\n", "
    \n", "
  • 'YY': -90.0
  • \n", "
  • 'XX': -90.0
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 1.00\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1.00j\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1.00j\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1.00\n", " \n", " \n", " \n", "\n", "\n", "
  • \n", "
\n", "
\n", "
\n", "
\n", "\n", "
\n", "
 
\n", "
\n", "  \n", "
\n", "
Marker 0
\n", " Compilation tools may only recompile cycles with equal markers.\n", "
\n", "
\n", "
\n", "
\n", " \n", " (0):\n", " Gate(Y, X, ...)\n", " \n", " \n", "\n", "\n", "
\n", "
\n", "
Name:
\n", "
\n", "
    \n", "
  • Gate(Y, X, ...)
  • \n", "
\n", "
\n", "\n", " \n", "\n", " \n", "\n", "\n", " \n", "
Generators:
\n", "
\n", "
    \n", "
  • 'Y': 18.218
  • \n", "
  • 'X': 96.185
  • \n", "
  • 'Z': -139.688
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " -0.81\n", " \n", " \n", " 0.10j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.56\n", " \n", " \n", " -0.12j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.56\n", " \n", " \n", " 0.10j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.82\n", " \n", " \n", " 0.07j\n", " \n", " \n", " \n", "\n", "\n", "
  • \n", "
\n", "
\n", "
\n", "
\n", "\n", "
\n", "
\n", "
\n", " \n", " (1):\n", " Gate(Y, X, ...)\n", " \n", " \n", "\n", "\n", "
\n", "
\n", "
Name:
\n", "
\n", "
    \n", "
  • Gate(Y, X, ...)
  • \n", "
\n", "
\n", "\n", " \n", "\n", " \n", "\n", "\n", " \n", "
Generators:
\n", "
\n", "
    \n", "
  • 'Y': -139.535
  • \n", "
  • 'X': -64.795
  • \n", "
  • 'Z': 30.824
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 0.04\n", " \n", " \n", " -0.27j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.94\n", " \n", " \n", " -0.21j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.44\n", " \n", " \n", " 0.85j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.28\n", " \n", " \n", " 0.03j\n", " \n", " \n", " \n", "\n", "\n", "
  • \n", "
\n", "
\n", "
\n", "
\n", "\n", "
\n", "
\n", "
\n", "  \n", "
\n", "
Marker 0
\n", " Compilation tools may only recompile cycles with equal markers.\n", "
\n", "
\n", "
\n", "
\n", " \n", " (0, 1):\n", " Gate.iswap\n", " \n", " \n", "\n", "\n", "
\n", "
\n", "
Name:
\n", "
\n", "
    \n", "
  • Gate.iswap
  • \n", "
\n", "
\n", "\n", " \n", "
Aliases:
\n", "
\n", "
    \n", "
  • Gate.iswap
  • \n", "
\n", "
\n", "\n", " \n", "
Likeness:
\n", "
\n", "
    \n", "
  • iSWAP
  • \n", "
\n", "
\n", "\n", "\n", " \n", "
Generators:
\n", "
\n", "
    \n", "
  • 'YY': -90.0
  • \n", "
  • 'XX': -90.0
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 1.00\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1.00j\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1.00j\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1.00\n", " \n", " \n", " \n", "\n", "\n", "
  • \n", "
\n", "
\n", "
\n", "
\n", "\n", "
\n", "
 
\n", "
\n", "  \n", "
\n", "
Marker 0
\n", " Compilation tools may only recompile cycles with equal markers.\n", "
\n", "
\n", "
\n", "
\n", " \n", " (0):\n", " Gate(Y, X, ...)\n", " \n", " \n", "\n", "\n", "
\n", "
\n", "
Name:
\n", "
\n", "
    \n", "
  • Gate(Y, X, ...)
  • \n", "
\n", "
\n", "\n", " \n", "\n", " \n", "\n", "\n", " \n", "
Generators:
\n", "
\n", "
    \n", "
  • 'Y': -135.41
  • \n", "
  • 'X': 56.091
  • \n", "
  • 'Z': -64.089
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 0.39\n", " \n", " \n", " 0.18j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.39\n", " \n", " \n", " -0.81j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.85\n", " \n", " \n", " 0.30j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.13\n", " \n", " \n", " -0.41j\n", " \n", " \n", " \n", "\n", "\n", "
  • \n", "
\n", "
\n", "
\n", "
\n", "\n", "
\n", "
\n", "
\n", " \n", " (1):\n", " Gate(Y, X, ...)\n", " \n", " \n", "\n", "\n", "
\n", "
\n", "
Name:
\n", "
\n", "
    \n", "
  • Gate(Y, X, ...)
  • \n", "
\n", "
\n", "\n", " \n", "\n", " \n", "\n", "\n", " \n", "
Generators:
\n", "
\n", "
    \n", "
  • 'Y': -39.749
  • \n", "
  • 'X': -23.555
  • \n", "
  • 'Z': 0.606
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " -0.28\n", " \n", " \n", " 0.87j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.30\n", " \n", " \n", " 0.26j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.08\n", " \n", " \n", " -0.38j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.29\n", " \n", " \n", " 0.87j\n", " \n", " \n", " \n", "\n", "\n", "
  • \n", "
\n", "
\n", "
\n", "
\n", "\n", "
\n", "
\n", "\n", "\n", "\n", "\n" ], "text/plain": [ "Circuit(Cycle((0,): Gate(Y, X, ...), (1,): Gate(Y, X, ...)),Cycle((0, 1): Gate.iswap),Cycle((0,): Gate(Y, X, ...), (1,): Gate(Y, X, ...)),Cycle((0, 1): Gate.iswap),Cycle((0,): Gate(Y, X, ...), (1,): Gate(Y, X, ...)),Cycle((0, 1): Gate.iswap),Cycle((0,): Gate(Y, X, ...), (1,): Gate(Y, X, ...)))" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# define the gate to be synthesized\n", "gate_to_be_synthesized = tq.Gate.random(4)\n", "\n", "# re-express the gate using an iswap gate as the two-qubit gate\n", "two_qubit_synthesized_gate = tq.math.decompose_unitary(\n", " target_gate=gate_to_be_synthesized, given_gate=tq.Gate.iswap\n", ")\n", "\n", "# print the synthesized gate\n", "two_qubit_synthesized_gate" ] }, { "cell_type": "raw", "id": "833c4bed", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "This circuit can be verified to reproduce the original random unitary using an ideal\n", "simulator:" ] }, { "cell_type": "code", "execution_count": 5, "id": "60a64a91", "metadata": { "execution": { "iopub.execute_input": "2024-04-26T18:16:53.744836Z", "iopub.status.busy": "2024-04-26T18:16:53.744545Z", "iopub.status.idle": "2024-04-26T18:16:53.841406Z", "shell.execute_reply": "2024-04-26T18:16:53.840942Z" } }, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQcAAAECCAYAAADzZhIUAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuNSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/xnp5ZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAUnklEQVR4nO3df0xT9/7H8VfxCuig3aCmldCq2SVj5i4QcGAzRNk6+ZGYKS6byX5g4bqYmSXYZfNHBmziFdFIjBsL8V7Fkbs5Q+JIdrdpMrIhd1bcYERHGBkZu0W7At1GW4rAIuf7h187qx+BusIp5fVI+kfPOcX3J1ufK+e4HoUkSRKIiG4TJvcARBScGAciEmIciEiIcSAiIcaBiIQYByISYhyISIhxICKhv8g9wO3Gx8dhs9kQHR0NhUIh9zhEIUWSJLjdbsTFxSEsbOLPBkEXB5vNBp1OJ/cYRCGtt7cX8fHxEx4TdHGIjo4GAFz48gKioqJkniawdAmMHsnL5XJBp9N532cTCbo43PxVIioqCtFRky9gNlEqlXKPQAQAU/qVnSckiUiIcSAiIcaBiIQYByISYhyISIhxICIhxoGIhBgHIhJiHIhIiHEgIiHGgYiEGAciEmIciEiIcSAiIcaBiIQYByISYhyISIhxICKhkI5Dy9ctKNxaiEdXPYoliUtw9vOzk77G0mJBXn4eEh5JQObaTNSfrp+BSYmCzz3Fobq6GkuXLkVkZCTS09Nx8eJF776RkRFs27YNsbGxiIqKwsaNG9HX1xewgf0xfG0YDyc+jPLS8ikdb71ihWmrCYY0Az5t+BSFLxZiR8kONDU3TfOkRMHH7zicOnUKZrMZZWVlaGtrQ1JSErKzs9Hf3w8A2L59Oz7++GPU19ejqakJNpsN+fn5AR98KrIys/Ba8WvIeTJnSse//+H70MXrULKzBAkPJmDz85uRl52HY+8dm+ZJiYKP33GoqqrCli1bYDKZsHz5ctTU1GDhwoU4fvw4nE4njh07hqqqKjz++ONITU1FbW0tzp8/jwsXLkz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FjpEnNdmaQlVPTw/sdrvPulUqFdLT00N63XKYE3FwOBy4fv06NBqNz3aNRgO73Q673Y7w8HDcf//9wv3BaLI1haqba5tr65bDnIgDEflvTsRBrVZj3rx5d1x96Ovrg1arhVarxdjY2B1n82/uD0aTrSlU3VzbXFu3HOZEHMLDw5GamorGxkbvtvHxcTQ2NsJgMCA1NRXz58/32d/V1QWr1QqDwSDHyJOabE2hatmyZdBqtT7rdrlcaGlpCel1yyHovuxlupjNZhQUFGDFihVIS0vD4cOH4fF4YDKZoFKpUFRUBLPZjJiYGCiVSrzyyiswGAxYuXKl3KPf1URrAuA9n9Ld3Q0AuHz5MqKjo6HX6xETEyPn6BMaGhryzgzcOAnZ3t6OmJgY6PV6FBcXY+/evUhISMCyZctQUlKCuLg4rF+/Xr6hp2Cydf3666+wWq2w2WwAbvwHCoD30+2Mk/VayQx7++23Jb1eL4WHh0tpaWnShQsXvPuuXbsmvfzyy9IDDzwgLVy4UNqwYYP0888/yzjt1Ey0prKyMgnAHY/a2lr5Bp6Cm5deb38UFBRIknTjcmZJSYmk0WikiIgI6YknnpC6urrkHXoKJltXbW2tcH9ZWZks8/J/2SYioTlxzoGI/Mc4EJEQ40BEQowDEQkxDkQkxDgQkRDjQERCjAMRCTEORCTEOBCREONAREKMAxEJ/R/Dk9MJ4TLD6wAAAABJRU5ErkJggg==", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "matrix = tq.Simulator().operator(two_qubit_synthesized_gate).mat()\n", "\n", "# This will result in an identity gate up to a global complex phase.\n", "tq.plot_mat(matrix @ gate_to_be_synthesized.adj.mat)" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "nbsphinx,raw_mimetype,-all", "main_language": "python", "notebook_metadata_filter": "-all", "text_representation": { "extension": ".py", "format_name": "percent" } }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 5 }