Paddle Quantum have a toolkit for simulating measurement-based QC patterns in Python, and I'm having a hard time understanding how this works.
For example, the following code snippet considers the pattern of two qubits joined by an edge. We initialise the two qubits in the state $|+\rangle |+\rangle$, before applying a measurement on the 1st qubit with respect to the $\{ |+\rangle, |-\rangle \}$ basis:
from paddle import to_tensor
from paddle_quantum.mbqc.simulator import MBQC
from paddle_quantum.mbqc.qobject import State
from paddle_quantum.mbqc.utils import basis
# Define MBQC graph as two vertices joined by an edge
G = [['1','2'], [('1','2')]]
# Initialise MBQC model
mbqc = MBQC()
# Set the graph state
mbqc.set_graph(G)
# Define input state as |+>|+>
input_state = to_tensor([[0.5],[0.5],[0.5],[0.5]], dtype='complex128')
input_state = State(input_state, ['1','2'])
# Set the input state
mbqc.set_input_state(input_state)
# Print initial state
print('Input state:')
print(mbqc.get_quantum_output().vector.numpy())
# Measure qubit 1
mbqc.measure('1', basis('XY', to_tensor(0, dtype='float64')))
# Print measurement outcome and resultant state of qubit 2
print('Measurement outcome of 1st qubit:')
print(mbqc.sum_outcomes(['1']))
print('Post-measurement state:')
print(mbqc.get_quantum_output().vector.numpy())
As I understand it, the measurement outcome of the first qubit should always be 0, since the first qubit has state $|+\rangle$ and we are measuring in the $\{ |+\rangle, |-\rangle \}$ basis. However, the code above sometimes gives a measurement outcome of 1 in the console:
Input state:
[[0.5+0.j]
[0.5+0.j]
[0.5+0.j]
[0.5+0.j]]
Measurement outcome of 1st qubit:
1
Post-measurement state:
[[0.+0.j]
[1.+0.j]]
Hence, my question is simply: which part of the above simulation am I misunderstanding?