Gate inconsistencies between versions when using controlled interface
See original GitHub issueIt 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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Troubleshoot Switch Port and Interface Problems - Cisco
This document describes how to determine why a port or interface experiences problems.
Read more >Managed vs. unmanaged switches: What are the differences?
A managed switch enables better control of networks and the data frames moving through them. Unmanaged switches, on the other hand, enable connected...
Read more >BPDU Protection for Spanning-Tree Protocols | Junos OS
To prevent a switch from forwarding BPDUs generated by spanning-tree protocols to a device, you can enable bpdu-block on an interface. On Juniper...
Read more >Getting Started With Native Gates - IonQ
A comprehensive guide for using IonQ's hardware-native gate set.
Read more >TS 129 244 - V16.4.0 - LTE; 5G - ETSI
Interface between the Control Plane and the User Plane nodes ... existing or perceived difference in contents between such versions and/or in print, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
What is happening here is that the current code constructs a CXPowGate, but uses the global phase of the gate. Since Rx gates have global phase, that phase ends up in the “identity” part of the gate. That is not at all what users expect, they expect that the gate is a CRx gate. I think the solution here is if the global shift is not 0, use the old way to construct a controlled not.
Alternatively we could add CR* Gates. This is one of the “features” on the roadmap that needs to be decided, so I think for now the “don’t do it when the shift doesn’t work” is the right path
@smitsanghavi or @Strilanc any comments since you were involved in the bug leading up to this change.
The bug is that the code is not checking the global phase (self._global_phase_shift) before performing the substitution.