{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n", "import pygsti\n", "from pygsti import algorithms" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "n_1 = 4\n", "glist = ['Gx','Gy','Gcnot']\n", "pspec_1 = pygsti.obj.ProcessorSpec(n_1,glist,verbosity=0)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "12\n" ] } ], "source": [ "s_1, p_1 = pygsti.symplectic.random_clifford(n_1)\n", "\n", "circuit = algorithms.compile_clifford(s_1,p_1,pspec_1)\n", "print(circuit.twoqubit_gatecount())" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "4\n" ] } ], "source": [ "circuit = algorithms.compile_stabilizer_state(s_1,p_1,pspec_1)\n", "print(circuit.twoqubit_gatecount())" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "4\n" ] } ], "source": [ "circuit = algorithms.compile_stabilizer_measurement(s_1,p_1,pspec_1)\n", "print(circuit.twoqubit_gatecount())" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Qubit 0 ---|Gy |-|Gx |-|Gx |-| |-| |-| |-| |-|Gx |-Gcnot:0:3|-|Gcnot:3:0|-||Gx |-Gcnot:2:0|-||Gy |-Gcnot:0:2|-||Gy |-|Gy |-|Gx |-|Gy |-|Gy |-|Gx |-|Gy |-Gcnot:3:0|-|Gcnot:0:3|-|Gcnot:3:0|-||Gy |-|Gx |---\n", "Qubit 1 ---|Gy |-|Gx |-|Gx |-| |-| |-| |-| |-|Gy |-Gcnot:1:2|-||Gx |-Gcnot:3:1|-||Gy |-|Gy |-|Gy |-|Gx |-Gcnot:1:3|-||Gy |-|Gx |-|Gx |-|Gy |-|Gy |-| |-| |-| |-| |-| |---\n", "Qubit 2 ---|Gx |-|Gy |-Gcnot:3:2|-||Gx |-|Gx |-|Gy |-|Gy |-|Gy |-Gcnot:1:2|-||Gx |-|Gy |-Gcnot:2:0|-|Gcnot:3:2|-|Gcnot:0:2|-||Gx |-|Gx |-Gcnot:3:2|-||Gy |-|Gy |-|Gy |-| |-| |-| |-| |-| |-| |---\n", "Qubit 3 ---|Gx |-|Gy |-Gcnot:3:2|-||Gy |-|Gy |-| |-| |-|Gy |-Gcnot:0:3|-|Gcnot:3:0|-|Gcnot:3:1|-||Gy |-Gcnot:3:2|-||Gx |-|Gy |-Gcnot:1:3|-|Gcnot:3:2|-||Gy |-|Gy |-|Gx |-|Gy |-Gcnot:3:0|-|Gcnot:0:3|-|Gcnot:3:0|-||Gy |-|Gx |---\n", "\n", "[1, 0, 0, 1]\n" ] } ], "source": [ "from pygsti.extras import rb\n", "circuit, out = rb.sample.direct_rb_circuit(pspec_1,10,randomizeout=True)\n", "print(circuit)\n", "print(out)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Qubit 0 ---|Gy |-Gcnot:0:3|-||Gx |-|Gy |-|Gx |-Gcnot:3:0|-||Gx |-|Gy |-Gcnot:1:0|-|| |-| |-Gcnot:0:1|-|| |-Gcnot:1:0|-||Gx |-|Gx |-|Gy |-|Gy |-| |-| |-| |-Gcnot:1:0|-||Gx |-|Gy |-|Gx |-Gcnot:0:3|-|Gcnot:2:0|-|| |-| |-| |-| |-| |-Gcnot:0:2|-|| |-| |-| |-| |-| |-|Gy |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:0:3|-||Gy |-Gcnot:3:0|-||Gy |-Gcnot:3:0|-||Gx |-|Gx |-|Gy |-|Gy |-|Gx |-Gcnot:0:2|-|| |-Gcnot:1:0|-|| |-| |-| |-Gcnot:0:2|-|| |-| |-| |-Gcnot:2:0|-|| |-| |-|Gx |-Gcnot:1:0|-|| |-| |-| |-Gcnot:0:1|-|Gcnot:0:2|-|| |-| |-| |-| |-Gcnot:2:0|-|| |-Gcnot:0:3|-|| |-| |-| |-|Gy |-|Gy |-| |-| |-|Gx |-| |-Gcnot:1:0|-|Gcnot:0:1|-|Gcnot:0:2|-|Gcnot:2:0|-|Gcnot:0:2|-|| |-Gcnot:0:3|-|| |-| |-| |-| |-| |-| |-| |-|Gx |-|Gx |-|Gy |-Gcnot:0:3|-|| |-Gcnot:0:3|-|Gcnot:2:0|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:0:1|-|| |-| |-| |-Gcnot:3:0|-||Gx |-|Gx |-| |-| |-| |-| |-Gcnot:2:0|-||Gy |-Gcnot:2:0|-|| |-Gcnot:3:0|-|| |-| |-| |-| |-| |-Gcnot:3:0|-|Gcnot:1:0|-|| |-| |-Gcnot:0:1|-|| |-| |-| |-| |-| |-Gcnot:1:0|-||Gx |-|Gx |-|Gy |-|Gy |-|Gy |-| |-| |-Gcnot:0:3|-||Gy |-Gcnot:1:0|-||Gx |-|Gy |-|Gx |-Gcnot:0:3|-|Gcnot:0:2|-|| |-| |-Gcnot:2:0|-||Gy |-|Gy |-| |-| |-| |-Gcnot:1:0|-||Gx |-|Gy |-|Gx |-Gcnot:0:1|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:0:3|-|Gcnot:1:0|-|| |-| |-| |-| |-| |-| |-|Gx |-|Gx |-|Gy |-|Gy |-| |-| |-| |-| |-Gcnot:3:0|-|Gcnot:0:3|-|Gcnot:0:2|-||Gy |-Gcnot:1:0|-|| |-| |-| |-Gcnot:1:0|-||Gy |-|Gy |-| |-| |-|Gy |-| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:0:2|-||Gy |-|Gx |-Gcnot:2:0|-||Gy |-Gcnot:1:0|-|Gcnot:2:0|-||Gx |-|Gy |-Gcnot:0:1|-|Gcnot:0:3|-||Gx |-|Gx |-|Gy |-|Gy |---\n", "Qubit 1 ---|Gy |-| |-| |-| |-| |-| |-| |-| |-Gcnot:1:0|-||Gy |-|Gx |-Gcnot:0:1|-|Gcnot:1:3|-|Gcnot:1:0|-|| |-| |-| |-| |-|Gx |-|Gy |-|Gx |-Gcnot:1:0|-|| |-| |-| |-| |-| |-| |-| |-Gcnot:1:2|-|| |-| |-| |-| |-| |-| |-| |-| |-|Gy |-| |-| |-| |-| |-| |-| |-| |-Gcnot:1:3|-||Gy |-|Gx |-Gcnot:1:2|-||Gy |-| |-|Gx |-|Gx |-| |-| |-|Gx |-|Gy |-Gcnot:3:1|-|Gcnot:1:0|-|| |-| |-| |-| |-| |-| |-Gcnot:2:1|-|| |-| |-| |-|Gy |-Gcnot:1:0|-||Gx |-|Gy |-|Gx |-Gcnot:0:1|-|| |-| |-Gcnot:1:2|-|Gcnot:3:1|-|| |-Gcnot:1:3|-|| |-| |-| |-| |-| |-|Gx |-|Gx |-|Gy |-|Gy |-|Gy |-Gcnot:2:1|-|Gcnot:1:0|-|Gcnot:0:1|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:3:1|-|| |-| |-|Gy |-|Gy |-|Gy |-| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:1:2|-||Gy |-Gcnot:3:1|-||Gy |-Gcnot:0:1|-|Gcnot:3:1|-||Gy |-Gcnot:1:3|-|Gcnot:1:2|-||Gx |-|Gx |-|Gy |-|Gy |-|Gy |-| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:1:0|-||Gy |-Gcnot:2:1|-|Gcnot:0:1|-||Gy |-Gcnot:2:1|-||Gx |-|Gy |-Gcnot:1:2|-|Gcnot:1:0|-||Gx |-|Gx |-| |-| |-|Gx |-| |-Gcnot:1:3|-|| |-| |-Gcnot:1:0|-|Gcnot:1:2|-|| |-| |-| |-Gcnot:3:1|-|| |-| |-| |-|Gy |-|Gy |-| |-| |-|Gx |-Gcnot:1:0|-|| |-| |-| |-Gcnot:0:1|-|Gcnot:2:1|-|| |-Gcnot:1:2|-|Gcnot:2:1|-|Gcnot:1:2|-|Gcnot:2:1|-|| |-| |-| |-| |-Gcnot:1:0|-|| |-Gcnot:1:3|-|| |-| |-Gcnot:3:1|-|| |-|Gx |-|Gx |-| |-| |-|Gy |-| |-| |-| |-| |-| |-Gcnot:1:3|-|| |-Gcnot:1:0|-|Gcnot:3:1|-||Gy |-Gcnot:1:3|-|Gcnot:1:0|-|| |-| |-| |-| |-| |-Gcnot:1:2|-|| |-Gcnot:1:2|-|Gcnot:3:1|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:1:0|-|| |-| |-| |-Gcnot:0:1|-|| |-| |-| |-| |-| |---\n", "Qubit 2 ---| |-| |-| |-| |-| |-| |-Gcnot:3:2|-|Gcnot:2:3|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-|Gy |-| |-| |-| |-| |-| |-| |-| |-Gcnot:2:0|-||Gy |-|Gx |-Gcnot:1:2|-|Gcnot:3:2|-||Gy |-Gcnot:0:2|-||Gy |-| |-| |-| |-| |-|Gy |-Gcnot:3:2|-|| |-Gcnot:2:3|-|| |-Gcnot:2:3|-|| |-| |-| |-| |-| |-Gcnot:1:2|-|| |-| |-|Gy |-|Gy |-| |-| |-|Gx |-Gcnot:0:2|-|| |-| |-| |-Gcnot:3:2|-||Gy |-Gcnot:0:2|-||Gx |-|Gy |-Gcnot:2:1|-|Gcnot:2:0|-||Gy |-|Gy |-|Gx |-| |-| |-| |-| |-| |-Gcnot:0:2|-||Gy |-Gcnot:1:2|-||Gx |-|Gy |-Gcnot:2:0|-|| |-| |-Gcnot:2:3|-|| |-| |-|Gy |-|Gy |-| |-| |-|Gy |-Gcnot:2:1|-||Gx |-|Gy |-Gcnot:0:2|-|Gcnot:2:0|-|Gcnot:0:2|-|Gcnot:2:3|-|| |-| |-Gcnot:2:3|-|| |-| |-| |-Gcnot:3:2|-|| |-| |-| |-|Gy |-| |-| |-| |-Gcnot:2:0|-||Gy |-Gcnot:3:2|-||Gx |-|Gy |-|Gx |-Gcnot:1:2|-|| |-| |-| |-| |-| |-| |-| |-Gcnot:1:2|-|| |-| |-| |-| |-|Gx |-|Gy |-Gcnot:2:0|-|| |-Gcnot:2:0|-|Gcnot:3:2|-|| |-| |-Gcnot:2:3|-|| |-| |-| |-| |-| |-| |-Gcnot:2:1|-|| |-| |-Gcnot:2:1|-|| |-| |-Gcnot:1:2|-|| |-|Gx |-|Gx |-| |-| |-|Gx |-|Gy |-| |-| |-| |-| |-Gcnot:1:2|-|| |-| |-| |-Gcnot:0:2|-||Gy |-Gcnot:2:3|-|Gcnot:2:0|-||Gx |-|Gx |-|Gy |-|Gy |-|Gy |-| |-| |-| |-| |-| |-Gcnot:2:1|-||Gy |-Gcnot:1:2|-|Gcnot:2:1|-|Gcnot:1:2|-|Gcnot:2:1|-|Gcnot:3:2|-|| |-| |-| |-Gcnot:2:3|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-|Gx |-| |-Gcnot:3:2|-|Gcnot:2:3|-|| |-| |-Gcnot:0:2|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-|Gx |-Gcnot:1:2|-||Gy |-Gcnot:1:2|-||Gy |-Gcnot:3:2|-|| |-| |-| |-Gcnot:2:3|-|Gcnot:0:2|-|| |-| |-Gcnot:2:0|-|| |-| |-Gcnot:2:0|-|| |-| |-| |-| |-|Gx |-|Gx |-|Gy |-|Gy |---\n", "Qubit 3 ---|Gx |-Gcnot:0:3|-|| |-| |-| |-Gcnot:3:0|-|Gcnot:3:2|-|Gcnot:2:3|-|| |-| |-| |-| |-Gcnot:1:3|-|| |-| |-| |-| |-| |-|Gy |-| |-| |-| |-| |-| |-| |-Gcnot:0:3|-|| |-| |-| |-| |-Gcnot:3:2|-|| |-| |-| |-|Gx |-|Gx |-|Gy |-|Gy |-|Gy |-Gcnot:3:2|-||Gy |-Gcnot:2:3|-||Gy |-Gcnot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|-|| |-Gcnot:1:3|-|| |-|Gx |-|Gx |-|Gy |-|Gy |-|Gy |-| |-| |-| |-Gcnot:3:1|-|Gcnot:3:2|-||Gx |-|Gy |-|Gx |-Gcnot:2:3|-||Gx |-|Gy |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:0:3|-||Gx |-|Gx |-| |-| |---\n", "\n", "[0, 0, 0, 0]\n" ] } ], "source": [ "from pygsti.extras import rb\n", "circuit, out = rb.sample.clifford_rb_circuit(pspec_1,10,randomizeout=False)\n", "print(circuit)\n", "print(out)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "n_2 = 3\n", "glist = ['Gxpi','Gypi','Gzpi','Gh','Gp','Gcphase']\n", "availability = {'Gcphase':[(0,1),(1,2)]}\n", "pspec_2 = pygsti.obj.ProcessorSpec(n_2,glist,availability=availability,verbosity=0)\n", "\n", "\n", "n_3 = 6\n", "glist = ['Gxpi','Gypi','Gzpi','Gh','Gp','Gcphase']\n", "availability = {'Gcphase':[(0,1),(1,2),(2,3),(3,4),(4,5)]}\n", "pspec_3 = pygsti.obj.ProcessorSpec(n_3,glist,availability=availability,verbosity=0)\n", "np.sum(pspec_3.qubitgraph.shortest_path_distance_matrix(),axis=0)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "s_3, p_3 = pygsti.symplectic.random_clifford(n_3)\n", "\n", "circuit = algorithms.compile_clifford(s_3,p_3,pspec_3)\n", "print(circuit.twoqubit_gatecount())\n", "\n", "circuit = algorithms.compile_stabilizer_state(s_3,p_3,pspec_3)\n", "print(circuit.twoqubit_gatecount())" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "pygsti.symplectic.composite_clifford_from_clifford_circuit(circuit,)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "g= pspec_1.models['clifford']" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ " l = []" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "if l == None:\n", " print(1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.6.3" } }, "nbformat": 4, "nbformat_minor": 2 }