hongyehu / PyClifford

An intuitive programming package for simulating and analyzing Clifford circuits, quantum measurement, and stabilizer states with applications to many-body localization, classical shadows, quantum chemistry and error correction code.
https://hongyehu.github.io/PyCliffordPages/intro.html
BSD 3-Clause "New" or "Revised" License
72 stars 15 forks source link

Strange behavior in the measure method #6

Closed taylorpatti closed 1 year ago

taylorpatti commented 1 year ago

Here is something that I'm seeing with the get_prob method of stabilizer states. My understanding of the method is that it takes bitstring as input where bitstring is an array of the Pauli z operators (0 is +1 and 1 is -1) that you would measure and it returns to probability of that stabilizer state returning that measurement. Assuming this is correct, here's some weird behavior:

nqubits = 3 pauli_vals = [2, 0, 1] a = clifford_rotation_map(pauli_vals)

pauli_op = np.kron(y, np.kron(iden, x)) U_a = scipy.linalg.expm((1jnp.pi/4)pauli_op) state = np.zeros((2**nqubits, 1)) state[0, 0] = 1

print('Probability to sample the bitstring [0, 0, 0]') print(a.to_state().get_prob(np.array([0, 0, 0]))) print() print('Actual state prepared') print(np.matmul(U_a, state))

So U_a is unitary defined by the Clifford Map a. We see that it prepares a state with amplitude 1/sqrt(2) in the state |000> . But, if I understand the method correctly, the get_prob method gives us a zero percent change of measuring +++ for a string of 3 Pauli z operators.

hongyehu commented 1 year ago

Hi Taylor, the get_prob() method will take a NumPy array of size N, where 0 means (+1=i^0) and 2 means (-1=i^2). Sorry for the confusion. We should choose a convention soon.