Skip to content

Commit

Permalink
Updating z with init for graph qubit
Browse files Browse the repository at this point in the history
  • Loading branch information
fieldofnodes committed Mar 22, 2024
1 parent 25a2cb7 commit 2f493a9
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions pytket-mbqc-py/pytket_mbqc_py/graph_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
63 changes: 55 additions & 8 deletions pytket-mbqc-py/pytket_mbqc_py/test_run.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -42,17 +42,17 @@
"\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",
" :init-render-options="initRenderOptions"\n",
" ></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",
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down

0 comments on commit 2f493a9

Please sign in to comment.