Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix global phase tracking for Unroller, OneQubitEulerDecomposer, and ControlledGate #5248

Merged
merged 4 commits into from
Nov 4, 2020

Conversation

georgios-ts
Copy link
Contributor

Summary

Related and (partially) resolves #5235. Fixes some bugs found in handling global phases.

Details and comments

The PR introduces the following changes:

  • Decomposer and Unroller may add twice a global phase if a gate has more than one instructions. See below. This has been fixed.
qc = QuantumCircuit(1, name='V', 
                    global_phase=pi / 2)
qc.x(0)
qc.h(0)
V = qc.to_gate()

circ = QuantumCircuit(1)
circ.append(V, [0])

print(circ.decompose().global_phase)

pass_ = Unroller(basis=['x', 'h', 'cx'])
pm = PassManager(pass_)
print(pm.run(circ).global_phase)
---
Outputs:
3.14
3.14
pauli = Operator(Pauli(label='XZ'))
gate = UnitaryGate(pauli)

np.allclose(pauli.data, 
            Operator(gate.definition).data)
---
False

@georgios-ts georgios-ts requested a review from a team as a code owner October 16, 2020 14:30
@mtreinish mtreinish added the stable backport potential The bug might be minimal and/or import enough to be port to stable label Oct 16, 2020
@kdk kdk changed the title fix bugs on global phases Fix global phase tracking for Unroller, OneQubitEulerDecomposer, and ControlledGate Nov 4, 2020
@kdk kdk added the automerge label Nov 4, 2020
@kdk kdk added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Nov 4, 2020
@mergify mergify bot merged commit 2d11db2 into Qiskit:master Nov 4, 2020
mergify bot pushed a commit that referenced this pull request Nov 4, 2020
…ControlledGate (#5248)

* fix bugs on global phases

* lint

* lint

Co-authored-by: Kevin Krsulich <[email protected]>
(cherry picked from commit 2d11db2)
mergify bot added a commit that referenced this pull request Nov 8, 2020
…ControlledGate (#5248) (#5342)

* fix bugs on global phases

* lint

* lint

Co-authored-by: Kevin Krsulich <[email protected]>
(cherry picked from commit 2d11db2)

Co-authored-by: georgios-ts <[email protected]>
Co-authored-by: Luciano Bello <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect relative phase added for controlled Pauli-X from quantum_info.operators
3 participants