Simulating MBQC Circuits¶
In the previous tutorial, you have learned how to create an MBQC circuit using the
MBQCircuit class. Now, we will use this circuit to run an actual experiment.
We will use the
PatternSimulator class to create a simulator. Let’s try it out
In : grid_cluster = mp.templates.grid_cluster(3, 5) In : simulator = mp.PatternSimulator(grid_cluster, backend='numpy-dm') In : print(simulator) PatternSimulator (NumpySimulatorDM for MBQCircuit with 15 qubits.)
You can specify the backend you want to use with the keyword argument
This can be useful if you want to run a circuit on real hardware.
mentpydoes not support running circuits on real hardware. This feature
will be added in the future.
Running the circuit¶
To run the circuit, we can simply call
simulator with the circuit as an argument.
If the measurement angle of a node is fixed (i.e. the measurement object
not trainable), you will not need to specify the measurement angle in the call to the
In : num_angles = len(grid_cluster.trainable_nodes) In : output_state = simulator(np.random.rand(num_angles)) In : print(output_state.shape) (8, 8)
If you want to run the circuit with a particular input state, you can specify it with the
In : random_state = mp.utils.generate_haar_random_states(3) In : simulator.reset(input_state = random_state) In : output_state = simulator(np.zeros(num_angles)) In : print(output_state.shape) (8, 8)