{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "bbddc54d", "metadata": { "execution": { "iopub.execute_input": "2024-03-26T18:57:26.596225Z", "iopub.status.busy": "2024-03-26T18:57:26.595950Z", "iopub.status.idle": "2024-03-26T18:57:26.598496Z", "shell.execute_reply": "2024-03-26T18:57:26.598088Z" }, "nbsphinx": "hidden" }, "outputs": [], "source": [ "# Copyright 2024 Keysight Technologies Inc." ] }, { "cell_type": "raw", "id": "45e46534", "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": "5f8cbcb4", "metadata": { "execution": { "iopub.execute_input": "2024-03-26T18:57:26.600307Z", "iopub.status.busy": "2024-03-26T18:57:26.600043Z", "iopub.status.idle": "2024-03-26T18:57:28.875567Z", "shell.execute_reply": "2024-03-26T18:57:28.875103Z" } }, "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': 100.341
  • \n", "
  • 'X': -129.067
  • \n", "
  • 'Z': -24.005
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 0.08\n", " \n", " \n", " 0.18j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.81\n", " \n", " \n", " 0.55j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.33\n", " \n", " \n", " 0.92j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.17\n", " \n", " \n", " -0.10j\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": "d9c73968", "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": "aa9e8b3a", "metadata": { "execution": { "iopub.execute_input": "2024-03-26T18:57:28.877749Z", "iopub.status.busy": "2024-03-26T18:57:28.877512Z", "iopub.status.idle": "2024-03-26T18:57:28.880805Z", "shell.execute_reply": "2024-03-26T18:57:28.880391Z" } }, "outputs": [ { "data": { "text/plain": [ "[('Z', 79.58855658027758),\n", " ('X', 90),\n", " ('Z', 22.26079950862166),\n", " ('X', 90),\n", " ('Z', 3.863045721614313)]" ] }, "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": "428a1c87", "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": "6cfb54c9", "metadata": { "execution": { "iopub.execute_input": "2024-03-26T18:57:28.882699Z", "iopub.status.busy": "2024-03-26T18:57:28.882523Z", "iopub.status.idle": "2024-03-26T18:57:28.920615Z", "shell.execute_reply": "2024-03-26T18:57:28.920187Z" }, "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': -121.294
  • \n", "
  • 'X': -116.259
  • \n", "
  • 'Z': 51.663
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " -0.26\n", " \n", " \n", " -0.15j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.88\n", " \n", " \n", " -0.37j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.33\n", " \n", " \n", " 0.89j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.28\n", " \n", " \n", " 0.08j\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': -160.54
  • \n", "
  • 'X': 37.359
  • \n", "
  • 'Z': -104.788
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 0.12\n", " \n", " \n", " 0.53j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.64\n", " \n", " \n", " -0.54j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.81\n", " \n", " \n", " 0.20j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.36\n", " \n", " \n", " -0.41j\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': 37.385
  • \n", "
  • 'X': 74.107
  • \n", "
  • 'Z': 92.372
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 0.54\n", " \n", " \n", " 0.60j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.57\n", " \n", " \n", " -0.15j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.46\n", " \n", " \n", " 0.37j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.74\n", " \n", " \n", " 0.32j\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': 27.658
  • \n", "
  • 'X': -22.209
  • \n", "
  • 'Z': -44.033
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " -0.40\n", " \n", " \n", " -0.87j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.30\n", " \n", " \n", " 0.02j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.04\n", " \n", " \n", " -0.29j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.90\n", " \n", " \n", " -0.33j\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': 6.604
  • \n", "
  • 'X': 28.894
  • \n", "
  • 'Z': -134.88
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 0.86\n", " \n", " \n", " -0.47j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.19\n", " \n", " \n", " 0.07j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.20\n", " \n", " \n", " -0.02j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.95\n", " \n", " \n", " -0.24j\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': 127.755
  • \n", "
  • 'X': -2.436
  • \n", "
  • 'Z': 123.108
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " -0.68\n", " \n", " \n", " -0.12j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.08\n", " \n", " \n", " 0.72j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.11\n", " \n", " \n", " -0.71j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.69\n", " \n", " \n", " 0.07j\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': -61.493
  • \n", "
  • 'X': -18.753
  • \n", "
  • 'Z': 210.802
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 0.54\n", " \n", " \n", " -0.80j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.08\n", " \n", " \n", " 0.26j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.22\n", " \n", " \n", " -0.17j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.93\n", " \n", " \n", " 0.23j\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': 27.753
  • \n", "
  • 'X': 73.269
  • \n", "
  • 'Z': 177.858
  • \n", "
\n", "
\n", "
\n", "
\n", "
Matrix:
\n", "
\n", "
    \n", "
  • \n", " \n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 0.73\n", " \n", " \n", " -0.56j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.25\n", " \n", " \n", " -0.31j\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.40\n", " \n", " \n", " -0.06j\n", " \n", " \n", " \n", " \n", " \n", " \n", " -0.85\n", " \n", " \n", " 0.34j\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": "8174857c", "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": "381642ad", "metadata": { "execution": { "iopub.execute_input": "2024-03-26T18:57:28.922438Z", "iopub.status.busy": "2024-03-26T18:57:28.922272Z", "iopub.status.idle": "2024-03-26T18:57:29.025483Z", "shell.execute_reply": "2024-03-26T18:57:29.025052Z" } }, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQcAAAECCAYAAADzZhIUAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuNSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/xnp5ZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAUoUlEQVR4nO3df0xT9/7H8VfxCuigdVDTjtCq2SVDv98FAg5shihbJz8SM2XLZuI2LFwXM7MEu2zqMmATr4hGYtxYiLuKI3c/DIkj2d3UZGRD7qy4wYgbYWRkbEW7At1GW4rAIuf7h187qx+BusIp5fVI+kfPOcX3J1ufK+e4HoUkSRKIiG4RJvcARBScGAciEmIciEiIcSAiIcaBiIQYByISYhyISIhxICKhv8k9wK3Gx8dhs9kQHR0NhUIh9zhEIUWSJLjdbsTFxSEsbOLPBkEXB5vNBp1OJ/cYRCGtt7cX8fHxEx4TdHGIjo4GAFz44gKioqJkniawdAmMHsnL5XJBp9N532cTCbo43PhVIioqCtFRky9gNlEqlXKPQAQAU/qVnSckiUiIcSAiIcaBiIQYByISYhyISIhxICIhxoGIhBgHIhJiHIhIiHEgIiHGgYiEGAciEmIciEiIcSAiIcaBiIQYByISYhyISIhxICKhkI5Dy1ctKNxWiIdWP4QliUtw9rOzk77G0mJBXn4eEh5MQOa6TNSfqp+BSYmCz13Fobq6GkuXLkVkZCTS09Nx8eJF776RkRFs374dsbGxiIqKwhNPPIG+vr6ADeyP4avDWJ64HOWl5VM63nrZCtM2EwxpBnza8CkKnyvEzpKdaGpumuZJiYKP33E4efIkzGYzysrK0NbWhqSkJGRnZ6O/vx8AsGPHDnz88ceor69HU1MTbDYb8vPzAz74VGRlZuHl4peR81jOlI5/78P3oIvXoWRXCRLuT8CWZ7YgLzsPx949Ns2TEgUfv+NQVVWFrVu3wmQyYcWKFaipqcHChQtx/PhxOJ1OHDt2DFVVVXjkkUeQmpqK2tpanD9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LAxGoxEWiwWtra34448/fPYnJiZCr9fDYrHIMfKkJltTqOrp6YHdbvdZt0qlQnp6ekivWw5zIg4OhwPXrl2DRqPx2a7RaGC322G32xEeHo5FixYJ9wejydYUqm6sba6tWw5zIg5E5L85EQe1Wo158+bddvWhr68PWq0WWq0WY2Njt53Nv7E/GE22plB1Y21zbd1ymBNxCA8PR2pqKhobG73bxsfH0djYCIPBgNTUVMyfP99nf1dXF6xWKwwGgxwjT2qyNYWqZcuWQavV+qzb5XKhpaUlpNcth6D7spfpYjabUVBQgJUrVyItLQ2HDx+Gx+OByWSCSqVCUVERzGYzYmJioFQq8eKLL8JgMGDVqlVyj35HE60JgPd8Snd3NwDg22+/RXR0NPR6PWJiYuQcfUJDQ0PemYHrJyHb29sRExMDvV6P4uJi7N27FwkJCVi2bBlKSkoQFxeHDRs2yDf0FEy2rt9++w1WqxU2mw3A9f9AAfB+up1xsl4rmWFvvvmmpNfrpfDwcCktLU26cOGCd9/Vq1elF154Qbr33nulhQsXShs3bpR++eUXGaedmonWVFZWJgG47VFbWyvfwFNw49LrrY+CggJJkq5fziwpKZE0Go0UEREhPfroo1JXV5e8Q0/BZOuqra0V7i8rK5NlXv4v20QkNCfOORCR/xgHIhJiHIhIiHEgIiHGgYiEGAciEmIciEiIcSAiIcaBiIQYByISYhyISIhxICKh/wMbe9MMyGvOoQAAAABJRU5ErkJggg==", "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": "raw_mimetype,nbsphinx,-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 }