From 2f493a90b5d2b3b71c4a541f733a1f37790d6fcc Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Fri, 22 Mar 2024 14:40:00 +0000 Subject: [PATCH] Updating z with init for graph qubit --- .../pytket_mbqc_py-0.1.1.dist-info/RECORD | 2 +- .../__pycache__/__init__.cpython-311.pyc | Bin 426 -> 426 bytes .../__pycache__/graph_circuit.cpython-311.pyc | Bin 14804 -> 14828 bytes .../__pycache__/qubit_manager.cpython-311.pyc | Bin 7061 -> 7061 bytes .../wasm_file_handler.cpython-311.pyc | Bin 685 -> 685 bytes .../pytket_mbqc_py/graph_circuit.py | 13 ++-- .../pytket_mbqc_py/graph_circuit.py | 6 +- pytket-mbqc-py/pytket_mbqc_py/test_run.ipynb | 63 +++++++++++++++--- 8 files changed, 66 insertions(+), 18 deletions(-) diff --git a/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py-0.1.1.dist-info/RECORD b/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py-0.1.1.dist-info/RECORD index d7a68dc2..d864a4b5 100644 --- a/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py-0.1.1.dist-info/RECORD +++ b/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py-0.1.1.dist-info/RECORD @@ -9,7 +9,7 @@ pytket_mbqc_py/__pycache__/__init__.cpython-311.pyc,, pytket_mbqc_py/__pycache__/graph_circuit.cpython-311.pyc,, pytket_mbqc_py/__pycache__/qubit_manager.cpython-311.pyc,, pytket_mbqc_py/__pycache__/wasm_file_handler.cpython-311.pyc,, -pytket_mbqc_py/graph_circuit.py,sha256=kIdfW4BQGOaItp6CHl3g-wxyhp-z65rUpH-hflgfYRo,9587 +pytket_mbqc_py/graph_circuit.py,sha256=x-KrLUkqIY14Rd-HMuOyqwVSx1zUfdmgTZCfOqP7aD8,9600 pytket_mbqc_py/pytket_mbqc_rus.wasm,sha256=aQbYffUOB2eGERfpEuwsjebQjCzQ4wMgGb7qybvZLPQ,1677906 pytket_mbqc_py/qubit_manager.py,sha256=BqhsaeKn3CfO2iOTVOwYuO0e9CCPD_6vOURj67FAWBQ,3234 pytket_mbqc_py/test_run.ipynb,sha256=kC7Jl0A6hLkojdlImB2W31oQRyV7z9K_eaQRLD8bOWw,21204 diff --git a/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py/__pycache__/__init__.cpython-311.pyc b/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py/__pycache__/__init__.cpython-311.pyc index 21e08b7c835cc92a4ccad674dfb9d088fa35340f..8b49cba38763147d008167e27d85b58f65ab306e 100644 GIT binary patch delta 20 acmZ3*yo#B7IWI340}xD`{&yqyd`18^#Razj delta 20 acmZ3*yo#B7IWI340}#xc^JgRXd`18_76roq diff --git a/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py/__pycache__/graph_circuit.cpython-311.pyc b/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py/__pycache__/graph_circuit.cpython-311.pyc index 206735bbb1fe9dab4594162213f22eb4f9c025cc..b901e5fb05239515267ff38009159297fd4e2352 100644 GIT binary patch delta 451 zcmcao{HB<9IWI340}xD`{x`K@Bd;kVqxfWJ#&~gw6uwmE6sA=6G?osAG{zME7Tzd< z6p6_@8BOISQrLlVq9FMc<}|hxu@=@Skq(9m#wgKX22IJ$yi9EZT2=A6r8y;;1v#n7 zOdt!OfE`FP1M%lAj0_A@8QU4!nI{J@8Et+q6v4>S$&kf9`MsXZh&048`g3yYgEGNx_zlBi~5Y}|ZIE{u_J>SS4k zXN)r@vnYOLoVWRxVizN0(dJfVMK;!=V4&TTS8AFu?%Mo7Q=gIN7FP+}p_}=&<=7Z+ zPu4R$%MVglBn>2PF$Uja44KSh6v$XJInF4B@$%-wMpev=J)7;!{1^=dSVccD0ErdM tU}}Ran8Hn{Y~E|0#0Yeof@QIzBMT$n2L|lq1e=dwnJ+lxixh#50{}B)c<}%L delta 447 zcmaD;e5IIoIWI340}#xc^Cz`l7EZx03_#)onBdwhFK))jn7TPkqMD7dVe=)q zFh<5HlQk8dF;1T>p!k(>?q)WnE=I<}%@dUs*_dxJMor$XX~wv7^E*v_#?6}Aa%_yZ zCVLp36|4bTStJc4ZZQTI1q12HDn@~f0h7y&QW!67zHL;+%-Fp-%*>C`ke^lb0|Ss) u!3?H0xPmF%gwp1#=1Gh|=U7-4J36p1@_k^yPEN4-2$uPRL%v86=qvzspLWIo diff --git a/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py/__pycache__/qubit_manager.cpython-311.pyc b/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py/__pycache__/qubit_manager.cpython-311.pyc index df43056c209437343d873824d303a747246c8bfc..4518ad070cc1cfc40672157fc6381325ee7a4504 100644 GIT binary patch delta 20 acmbPgKGmFiIWI340}xD`{&ypHmoxx6=LPxz delta 20 acmbPgKGmFiIWI340}#xc^JgP>moxx7I0gm) diff --git a/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py/__pycache__/wasm_file_handler.cpython-311.pyc b/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py/__pycache__/wasm_file_handler.cpython-311.pyc index 3bd5a78db38904d776afd4fd96f840ad51bd179b..d53c352c0a1cf239551cdea7ae0a54ea73470871 100644 GIT binary patch delta 20 acmZ3>x|WrDIWI340}xD`{&yqyA|?Pgh6Tj{ delta 20 acmZ3>x|WrDIWI340}#xc^JgRXA|?Pg*9Fl4 diff --git a/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py/graph_circuit.py b/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py/graph_circuit.py index c9f4e0d7..a01fedf7 100644 --- a/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py/graph_circuit.py +++ b/pytket-mbqc-env/lib/python3.11/site-packages/pytket_mbqc_py/graph_circuit.py @@ -81,28 +81,29 @@ def add_output_vertex(self) -> int: self.output_vertices.append(index) return index - def get_plus_state(self,t_multiple: int = 0) -> Qubit: + def get_plus_state(self,z_multiple: int = 0) -> Qubit: qubit = super().get_qubit() index = self._add_vertex(qubit=qubit) self.Reset(qubit=qubit) self.H(qubit=qubit) - [self.T(qubit=qubit) for _ in range(t_multiple)] + [self.Z(qubit=qubit) for _ in range(z_multiple)] self.add_c_setreg(value=index, arg=self.index_reg) self.add_wasm_to_reg( "update_z_correction", self.wfh, - [self.qubit_init_t_mult_reg[self.vertex_qubit[index]], t_multiple], - [],) + [self.qubit_init_t_mult_reg[self.vertex_qubit[index]], self.index_reg], + [], + ) return qubit - def add_graph_vertex(self,t_multiple: int = 0) -> int: + def add_graph_vertex(self,z_multiple: int = 0) -> int: if len(self.vertex_qubit) == 100: raise Exception("The current maximum number of vertices is 100.") - qubit = self.get_plus_state(t_multiple) + qubit = self.get_plus_state(z_multiple) index = self._add_vertex(qubit=qubit) diff --git a/pytket-mbqc-py/pytket_mbqc_py/graph_circuit.py b/pytket-mbqc-py/pytket_mbqc_py/graph_circuit.py index b2bce742..a01fedf7 100644 --- a/pytket-mbqc-py/pytket_mbqc_py/graph_circuit.py +++ b/pytket-mbqc-py/pytket_mbqc_py/graph_circuit.py @@ -94,16 +94,16 @@ def get_plus_state(self,z_multiple: int = 0) -> Qubit: self.add_wasm_to_reg( "update_z_correction", self.wfh, - [self.qubit_init_t_mult_reg[self.vertex_qubit[index]], z_multiple], + [self.qubit_init_t_mult_reg[self.vertex_qubit[index]], self.index_reg], [], ) return qubit - def add_graph_vertex(self,t_multiple: int = 0) -> int: + def add_graph_vertex(self,z_multiple: int = 0) -> int: if len(self.vertex_qubit) == 100: raise Exception("The current maximum number of vertices is 100.") - qubit = self.get_plus_state(t_multiple) + qubit = self.get_plus_state(z_multiple) index = self._add_vertex(qubit=qubit) diff --git a/pytket-mbqc-py/pytket_mbqc_py/test_run.ipynb b/pytket-mbqc-py/pytket_mbqc_py/test_run.ipynb index e4ec3351..c8e8027e 100644 --- a/pytket-mbqc-py/pytket_mbqc_py/test_run.ipynb +++ b/pytket-mbqc-py/pytket_mbqc_py/test_run.ipynb @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -42,9 +42,9 @@ "\n", "\n", "\n", - " <div id="circuit-display-vue-container-e19f83a7-5a52-4fbc-a152-d3f4aa9882c2" class="pytket-circuit-display-container">\n", + " <div id="circuit-display-vue-container-7186230d-04ec-491c-ad3d-1b7f57fdad96" class="pytket-circuit-display-container">\n", " <div style="display: none">\n", - " <div id="circuit-json-to-display">{"bits": [["index", [0]], ["meas_0", [0]], ["meas_1", [0]], ["x_corr_0", [0]], ["x_corr_1", [0]], ["z_corr_0", [0]], ["z_corr_1", [0]]], "commands": [{"args": [["meas_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["meas_1", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["q", [0]]], "op": {"type": "Reset"}}, {"args": [["q", [1]]], "op": {"type": "Reset"}}, {"args": [["x_corr_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["x_corr_1", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["z_corr_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["z_corr_1", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["q", [0]]], "op": {"type": "H"}}, {"args": [["q", [1]]], "op": {"type": "H"}}, {"args": [["x_corr_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["z_corr_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["q", [0]]], "op": {"params": ["0.4"], "type": "Rz"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CZ"}}, {"args": [["q", [0]], ["meas_0", [0]]], "op": {"type": "Measure"}}, {"args": [["meas_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["q", [0]]], "op": {"type": "Reset"}}, {"args": [["q", [0]]], "op": {"type": "H"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]]]}</div>\n", + " <div id="circuit-json-to-display">{"bits": [["index", [0]], ["init_t_mult_0", [0]], ["init_t_mult_1", [0]], ["meas_0", [0]], ["meas_1", [0]], ["x_corr_0", [0]], ["x_corr_1", [0]], ["z_corr_0", [0]], ["z_corr_1", [0]]], "commands": [{"args": [["init_t_mult_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["init_t_mult_1", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["meas_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["meas_1", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["q", [0]]], "op": {"type": "Reset"}}, {"args": [["q", [1]]], "op": {"type": "Reset"}}, {"args": [["x_corr_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["x_corr_1", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["z_corr_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["z_corr_1", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["init_t_mult_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["q", [0]]], "op": {"type": "H"}}, {"args": [["q", [1]]], "op": {"type": "H"}}, {"args": [["x_corr_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["z_corr_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["q", [0]]], "op": {"params": ["0.4"], "type": "Rz"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CZ"}}, {"args": [["q", [0]], ["meas_0", [0]]], "op": {"type": "Measure"}}, {"args": [["meas_0", [0]]], "op": {"classical": {"values": [false]}, "type": "SetBits"}}, {"args": [["q", [0]]], "op": {"type": "Reset"}}, {"args": [["q", [0]]], "op": {"type": "H"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]]]}</div>\n", " </div>\n", " <circuit-display-container\n", " :circuit-element-str="'#circuit-json-to-display'"\n", @@ -52,7 +52,7 @@ " ></circuit-display-container>\n", " </div>\n", " <script type="application/javascript">\n", - " const circuitRendererUid = "e19f83a7-5a52-4fbc-a152-d3f4aa9882c2";\n", + " const circuitRendererUid = "7186230d-04ec-491c-ad3d-1b7f57fdad96";\n", " const displayOptions = JSON.parse('{}');\n", "\n", " // Script to initialise the circuit renderer app\n", @@ -108,13 +108,60 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "circuit = GraphCircuit(n_qubits_total=3)\n", - "qubit_one, index_one = circuit.add_input_vertex()\n", - "index_two = circuit.add_graph_vertex(t_multiple = 14)" + "circuit.add_input_vertex()\n", + "circuit.add_graph_vertex(2)\n", + "#qubit_one, index_one = circuit.add_input_vertex()\n", + "#index_two = circuit.add_graph_vertex(t_multiple = 14)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{}\n" + ] + } + ], + "source": [ + "print(circuit.vertex_flow)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n" + ] + } + ], + "source": [ + "print(index_two)" ] }, {