0
$\begingroup$

I implemented the following circuit on cirq:

enter image description here

For clarity: the circuit consists of X gates, (controlled) Hadamard gates (H), N-toffoli gates, and reset operations (R).

The (1,4) qubit is the one I have a question about. Simulating this circuit, I get -1$|0\rangle$ as output vector for the (1,4) qubit, but I don't understand why I get a phase factor of -1. Given that all qubits are initialised in the $|0\rangle$ state, the N-Toffoli gates acting on qubit (1,4) are not even activated (since not all control qubits are $|1\rangle$), so I don't see why the (1,4) qubit is not simply left unchanged? And even if the N-Toffoli gates were activated, my (1,4) qubit would just be flipped, so even then I don't see where the -1 comes from.

The other strange thing is that if I remove the first reset operation, I no longer get the -1 factor in my output vector.

Maybe my understanding of the reset operation is lacking, but I thought it simply 'resets' the qubit back to the $|0\rangle$ state, so I don't see how that could introduce a phase either.

I am very confused about what is going on here, any help would be appreciated!

Here is my code for the circuit:

import cirq

number_qubits_y = 3
qubits_y = cirq.GridQubit.rect(1, number_qubits_y, top=1)
coin_qubit_y = cirq.GridQubit(1, number_qubits_y)
anc = cirq.GridQubit(1, number_qubits_y+1)

def initial_state():
    yield cirq.X.on(cirq.GridQubit(1, 1))
    yield cirq.X.on(coin_qubit_y)

def steps():
    yield cirq.H(coin_qubit_y)

    control_1 = [*qubits_y, coin_qubit_y]
    control_2 = [*qubits_y, anc]
    for i in range(0, number_qubits_y-1, 1):
        yield cirq.X.on(cirq.GridQubit(1, i))
    yield cirq.H.on(coin_qubit_y).controlled_by(*qubits_y)
    yield cirq.X.on(anc).controlled_by(*control_1)
    yield cirq.X.on(coin_qubit_y).controlled_by(*control_2)
    for i in range(0, number_qubits_y-1, 1):
        yield cirq.X.on(cirq.GridQubit(1, i))
    yield cirq.reset(anc)

    l = [cirq.GridQubit(1,1), cirq.GridQubit(1,2)] 
    for i in l:
        yield cirq.X.on(i)
    yield cirq.H.on(coin_qubit_y).controlled_by(*qubits_y)
    yield cirq.X.on(coin_qubit_y)
    yield cirq.X.on(anc).controlled_by(*control_1)
    yield cirq.X.on(coin_qubit_y).controlled_by(*control_2)
    yield cirq.X.on(coin_qubit_y)
    for i in l:
        yield cirq.X.on(i)
    yield cirq.reset(anc)

def circuit(number_qubits_y):
    circuit = cirq.Circuit()
    circuit.append(initial_state())
    for j in range(0, 1):
        circuit.append(steps())
    simulator = cirq.Simulator()
    print(circuit)
    result = simulator.simulate(circuit)
    return result
result = circuit(number_qubits_y)
print(result)
$\endgroup$
7
  • 1
    $\begingroup$ There's no experiment you can do in reality that distinguishes |0> from -|0>. What are you specifically asking the simulator in order to see the phase of that single qubit? Because it's generally allowed to make up any phase for that qubit that it wants, since the global phase of an unentangled qubit is unobservable. $\endgroup$ Aug 15, 2022 at 14:51
  • $\begingroup$ I am simulating the circuit with simulator = cirq.Simulator(), followed by result = simulator.simulate(circuit) and then I print the result and find the output vector of the qubit like that. $\endgroup$
    – Q.Ask
    Aug 15, 2022 at 15:00
  • $\begingroup$ Is there a way to get rid of the phase factor? In reality I repeat this circuit a few times before I make a measurement, and having the phase factor there leads to unwanted cancellations of terms. $\endgroup$
    – Q.Ask
    Aug 15, 2022 at 15:03
  • $\begingroup$ What do you mean it leads to unwanted cancellation of terms? Any math you are doing which is vulnerable to that phase factor is very likely (though not guaranteed!) to be wrong, and to break in many other ways. Consider converting to a bloch vector or a density matrix before combining values. $\endgroup$ Aug 15, 2022 at 15:09
  • 1
    $\begingroup$ This was fixed in github.com/quantumlib/Cirq/pull/5847 $\endgroup$
    – Dax Fohl
    Oct 25, 2022 at 1:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.