Skip to content

Gate inconsistencies between versions when using controlled interface #3111

@stasja

Description

@stasja

It seems there is a (unintentional?) change to what the controlled interface does before and after the 8179aa2d678bcce480c0ce14bd2852068657abf6 commit in certain cases, possibly related to how the global phase is handled.

Running the following circuit (and inspecting the states at each moment):

q0 = cirq.GridQubit(0, 0)
q1 = cirq.GridQubit(0, 1)
q2 = cirq.GridQubit(0, 2)
circuit = cirq.Circuit()
circuit.append(cirq.X(q0))
circuit.append(cirq.rx(1).controlled()(q0,q1))
circuit.append(cirq.rx(1).controlled()(q1,q2))
simulator = cirq.Simulator()
for i, step in enumerate(simulator.simulate_moment_steps(circuit))
    temp = np.around(step.state_vector(), 3)
    print('state at step %d: %s %s' % (i, temp[temp != 0], temp.nonzero()))

gives the following output before the 8179aa2d678bcce480c0ce14bd2852068657abf6 commit

state at step 0: [1.+0.j] (array([4]),)
state at step 1: [0.878+0.j    0.   -0.479j] (array([4, 6]),)
state at step 2: [ 0.878+0.j     0.   -0.421j -0.23 +0.j   ] (array([4, 6, 7]),)

and this output after:

state at step 0: [1.+0.j] (array([4]),)
state at step 1: [0.878+0.j    0.   -0.479j] (array([4, 6]),)
state at step 2: [ 0.77-0.421j  0.  -0.421j -0.23+0.j   ] (array([4, 6, 7]),)

The output I would expect to see is the former one, as it matches other implementations of the same circuit.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions