Skip to content

Commit

Permalink
Fix phase of cu3 gate to be compatible with u3 gate definition (#2755)
Browse files Browse the repository at this point in the history
* fix phase of cu3 definition

* update changelog

* update unroller test for new cu3 def
  • Loading branch information
chriseclectic authored and nonhermitian committed Jul 20, 2019
1 parent db85708 commit 02e4309
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ The format is based on [Keep a Changelog].
- Replaces LegacySwap by faster, more stable StochasticSwap pass (\#2672)
- Uses level 1 by default as transpiler optimization level (\#2672)
- Change Snapshot signature to match simulator.snapshot (\#2592)
- Changed definition of `Cu3Gate` to to equivalent to the canonical
definition of a controlled `U3Gate` (\#2755)

### Removed

Expand Down
3 changes: 2 additions & 1 deletion qiskit/extensions/standard/cu3.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ def __init__(self, theta, phi, lam):
def _define(self):
"""
gate cu3(theta,phi,lambda) c, t
{ u1((lambda-phi)/2) t; cx c,t;
{ u1((lambda+phi)/2) c; u1((lambda-phi)/2) t; cx c,t;
u3(-theta/2,0,-(phi+lambda)/2) t; cx c,t;
u3(theta/2,phi,0) t;
}
"""
definition = []
q = QuantumRegister(2, "q")
rule = [
(U1Gate((self.params[2] + self.params[1]) / 2), [q[0]], []),
(U1Gate((self.params[2] - self.params[1]) / 2), [q[1]], []),
(CnotGate(), [q[0], q[1]], []),
(U3Gate(-self.params[0] / 2, 0, -(self.params[1] + self.params[2]) / 2), [q[1]], []),
Expand Down
1 change: 1 addition & 0 deletions test/python/transpiler/test_unroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def test_unroll_all_instructions(self):
ref_circuit.u3(0, 0, -pi/4, qr[0])
ref_circuit.u3(0, 0, pi/4, qr[1])
ref_circuit.cx(qr[1], qr[0])
ref_circuit.u3(0, 0, 0.05, qr[1])
ref_circuit.u3(0, 0, pi/4, qr[2])
ref_circuit.u3(pi/2, 0, pi, qr[2])
ref_circuit.cx(qr[2], qr[0])
Expand Down

0 comments on commit 02e4309

Please sign in to comment.