Skip to content

Commit

Permalink
feat!: Move to classical input, classical output (#65)
Browse files Browse the repository at this point in the history
* update cnot and comp basis tests

* Update GHZ test

* Update t gate tests

* Remove inputs and outputs

* Complete test coverage

* Remove commented functino

* Reintrocude exceptions

* Update measure exceptions

* Add entangled output test

* Update example

* Correct exception
  • Loading branch information
daniel-mills-cqc authored Jun 26, 2024
1 parent 765de7d commit dc312a4
Show file tree
Hide file tree
Showing 5 changed files with 432 additions and 884 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"id": "6ea7b4f5",
"metadata": {},
"source": [
"# Blind X Gate\n",
"# Blind Z Gate\n",
"\n",
"In the following we exemplify how to implement an X gate with `pytket-mbqc`.\n",
"\n",
"We first initialis a graph state with 2 physical qubits and 3 logical qubits. This is to say that 2 qubits will be added to the circuit. These will be reused to build a 3 qubit graph state."
"We first initialise a graph state with 2 physical qubits and 3 logical qubits. The number of logical qubits can be higher than the number of phisical qubits if qubits are reused, as is the case here."
]
},
{
Expand All @@ -24,7 +24,7 @@
"\n",
"graph_circuit = GraphCircuit(\n",
" n_physical_qubits=2,\n",
" n_logical_qubits=3\n",
" n_logical_qubits=3,\n",
")\n",
"render_circuit_jupyter(graph_circuit)"
]
Expand All @@ -38,7 +38,7 @@
"\n",
"Next we create a linear cluster state consisting of 3 qubits. Note that vertices are measured once all of the edges they connect to are added. This allows for some qubit reuse.\n",
"\n",
"Themeasurement angles differ between vertices, being ewuivelent to an X gate. The input is initalised in the 1 computation basis state."
"The measurement angles differ between vertices, being equivelent to an Z gate. The input is |+>, and the measurements are in the hadamard bases."
]
},
{
Expand All @@ -50,17 +50,18 @@
"source": [
"import networkx as nx\n",
"\n",
"input_qubit, input_vertex = graph_circuit.add_input_vertex(measurement_order=0)\n",
"graph_circuit.X(input_qubit)\n",
"input_vertex = graph_circuit.add_graph_vertex(measurement_order=0)\n",
"\n",
"graph_vertex = graph_circuit.add_graph_vertex(measurement_order=1)\n",
"graph_vertex = graph_circuit.add_graph_vertex(measurement_order=None)\n",
"graph_circuit.add_edge(input_vertex, graph_vertex)\n",
"graph_circuit.corrected_measure(vertex=input_vertex, t_multiple=0)\n",
"graph_circuit.corrected_measure(vertex=input_vertex, t_multiple=4)\n",
"\n",
"output_vertex = graph_circuit.add_graph_vertex(measurement_order=None)\n",
"graph_circuit.add_edge(graph_vertex, output_vertex)\n",
"graph_circuit.corrected_measure(vertex=graph_vertex, t_multiple=4)\n",
"\n",
"graph_circuit.corrected_measure(vertex=output_vertex, t_multiple=0)\n",
"\n",
"nx.draw(graph_circuit.entanglement_graph, with_labels=True)"
]
},
Expand All @@ -79,7 +80,7 @@
"id": "2493b013",
"metadata": {},
"source": [
"We can now run the resulting circuit, giving the 0 state 100% of the time, as we expect."
"We can now run the resulting circuit, giving the 1 state 100% of the time, as we expect."
]
},
{
Expand All @@ -94,12 +95,11 @@
"api_offline = QuantinuumAPIOffline()\n",
"backend = QuantinuumBackend(device_name=\"H1-1LE\", api_handler = api_offline)\n",
"\n",
"output_dict = graph_circuit.get_outputs()\n",
"output_reg = graph_circuit.add_c_register(name='output_meas', size=1)\n",
"graph_circuit.Measure(output_dict[output_vertex], output_reg[0])\n",
"output_reg = [graph_circuit.vertex_reg[output_vertex][0]]\n",
"\n",
"compiled_circuit = backend.get_compiled_circuit(circuit=graph_circuit)\n",
"result = backend.run_circuit(circuit=compiled_circuit, n_shots=100)\n",
"compiled_circuit = backend.get_compiled_circuit(graph_circuit)\n",
"n_shots = 100\n",
"result = backend.run_circuit(circuit=compiled_circuit, n_shots=n_shots)\n",
"result.get_counts(cbits=output_reg)"
]
}
Expand Down
1 change: 0 additions & 1 deletion pytket-mbqc-py/pytket_mbqc_py/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
Tools for managing MBQC computations.
"""

from .cnot_block import CNOTBlocksGraphCircuit
from .graph_circuit import GraphCircuit
from .qubit_manager import QubitManager
251 changes: 0 additions & 251 deletions pytket-mbqc-py/pytket_mbqc_py/cnot_block.py

This file was deleted.

Loading

0 comments on commit dc312a4

Please sign in to comment.