Classical conditions misalign in both ASCII and MPL output
See original GitHub issueEnvironment
- Qiskit Terra version: 0.19.1
- Python version: 3.7.12
- Operating system: Ubuntu 18.04.5 LTS (Google Colab)
What is happening?
I was testing my automatic code generation for Qiskit, and apparently the ~cphase~ controlled U1 gate with a classical condition will make the circuit misaligns in both of ASCII output and MPL output.
Screenshots:
q2_0: ββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββΒ»
βU1(0) βU1(0) βU1(0) βU1(0) βU1(0) βU1(0) βU1(0) βU1(0) βU1(0) Β»
q2_1: ββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββΒ»
β β β β β β β β β Β»
q2_2: ββ«ββββββββ«ββββββββ«ββββββββ«ββββββββ«ββββββββ«ββββββββ«ββββββββ«ββββββββ«ββββββΒ»
ββ«ββ¨βββ ββ«ββ¨βββ ββ«ββ¨βββ ββ«ββ¨βββ ββ«ββ¨βββ ββ«ββ¨βββ ββ«ββ¨βββ ββ«ββ¨βββ ββ«ββ¨ββββΒ»
c2: 5/β‘β0x1 βββ‘β0x3 βββ‘β0x5 βββ‘β0x7 βββ‘β0x9 βββ‘β0xb βββ‘β0xd βββ‘β0xf βββ‘β0x11 βΒ»
ββ«βββββ ββ«βββββ ββ«βββββ ββ«βββββ ββ«βββββ ββ«βββββ ββ«βββββ ββ«βββββ ββ«ββββββΒ»
Β« Β»
Β«q2_0: ββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββββββ βββββΒ»
Β« βU1(0) βU1(0) βU1(0) βU1(0) βU1(0) βU1(0) βU1(0) ββββββ΄βββββΒ»
Β«q2_1: ββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ βββββββ€ U2(0,0) βΒ»
Β« β β β β β β β ββββββ₯βββββΒ»
Β«q2_2: ββ«ββββββββ«ββββββββ«ββββββββ«ββββββββ«ββββββββ«ββββββββ«ββββββββββββ«βββββΒ»
Β« ββ«ββ¨ββββββ«ββ¨ββββββ«ββ¨ββββββ«ββ¨ββββββ«ββ¨ββββββ«ββ¨ββββββ«ββ¨ββββ ββββ¨βββ Β»
Β«c2: 5/β‘β0x13 ββ‘β0x15 ββ‘β0x17 ββ‘β0x19 ββ‘β0x1b ββ‘β0x1d ββ‘β0x1f ββββ‘ 0x2 βββΒ»
Β« ββ«ββββββββ«ββββββββ«ββββββββ«ββββββββ«ββββββββ«ββββββββ«ββββββ βββββββ Β»
Β« Β»
Β«q2_0: ββββββ βββββββββββ βββββββββββ βββββββββββ βββββββββββ βββββββββββ βββββΒ»
Β« ββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββΒ»
Β«q2_1: β€ U2(0,0) ββ€ U2(0,0) ββ€ U2(0,0) ββ€ U2(0,0) ββ€ U2(0,0) ββ€ U2(0,0) βΒ»
Β« ββββββ₯βββββββββββ₯βββββββββββ₯βββββββββββ₯βββββββββββ₯βββββββββββ₯βββββΒ»
Β«q2_2: ββββββ«βββββββββββ«βββββββββββ«βββββββββββ«βββββββββββ«βββββββββββ«βββββΒ»
Β« ββββ¨βββ ββββ¨βββ ββββ¨βββ ββββ¨βββ ββββ¨βββ ββββ¨βββ Β»
Β«c2: 5/βββ‘ 0x3 ββββββ‘ 0x6 ββββββ‘ 0x7 ββββββ‘ 0xa ββββββ‘ 0xb ββββββ‘ 0xe βββΒ»
Β« βββββββ βββββββ βββββββ βββββββ βββββββ βββββββ Β»
Β« Β»
Β«q2_0: ββββββ βββββββββββ βββββββββββ βββββββββββ βββββββββββ βββββββββββ βββββΒ»
Β« ββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββΒ»
Β«q2_1: β€ U2(0,0) ββ€ U2(0,0) ββ€ U2(0,0) ββ€ U2(0,0) ββ€ U2(0,0) ββ€ U2(0,0) βΒ»
Β« ββββββ₯βββββββββββ₯βββββββββββ₯βββββββββββ₯βββββββββββ₯βββββββββββ₯βββββΒ»
Β«q2_2: ββββββ«βββββββββββ«βββββββββββ«βββββββββββ«βββββββββββ«βββββββββββ«βββββΒ»
Β« ββββ¨βββ ββββ¨ββββ ββββ¨ββββ ββββ¨ββββ ββββ¨ββββ ββββ¨ββββ Β»
Β«c2: 5/βββ‘ 0xf ββββββ‘ 0x12 βββββ‘ 0x13 βββββ‘ 0x16 βββββ‘ 0x17 βββββ‘ 0x1a ββΒ»
Β« βββββββ ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ Β»
Β« ββββββββββββββββββββββββββ Β»
Β«q2_0: ββββββ βββββββββββ βββββββββββ ββββββ€ U3(0,0,0) ββ€ U3(0,0,0) ββββXβββΒ»
Β« ββββββ΄βββββββββββ΄βββββββββββ΄ββββββββββββ¬βββββββββββββ¬ββββββ β Β»
Β«q2_1: β€ U2(0,0) ββ€ U2(0,0) ββ€ U2(0,0) ββββββββ βββββββββββββ ββββββββββ βββΒ»
Β« ββββββ₯βββββββββββ₯βββββββββββ₯βββββ β β β Β»
Β«q2_2: ββββββ«βββββββββββ«βββββββββββ«ββββββββββββ«βββββββββββββ«βββββββββXβββΒ»
Β« ββββ¨ββββ ββββ¨ββββ ββββ¨ββββ ββββ¨ββββ ββββ¨ββββ ββββ¨βββΒ»
Β«c2: 5/βββ‘ 0x1b βββββ‘ 0x1e βββββ‘ 0x1f ββββββ‘ 0x15 βββββββ‘ 0x17 ββββ‘ 0x2 βΒ»
Β« ββββββββ ββββββββ ββββββββ ββββββββ ββββββββ βββββββΒ»
Β«
Β«q2_0: βββXββββββXββββββXββββββXβββββββXβββββββXβββββββXββββ
Β« β β β β β β β
Β«q2_1: ββββ βββββββ βββββββ βββββββ ββββββββ ββββββββ ββββββββ ββββ
Β« β β β β β β β
Β«q2_2: βββXββββββXββββββXββββββXβββββββXβββββββXβββββββXββββ
Β« ββββ¨βββββββ¨βββββββ¨βββββββ¨ββββββββ¨ββββββββ¨ββββββββ¨ββββ
Β«c2: 5/β‘ 0x3 ββ‘ 0xa ββ‘ 0xb ββ‘ 0x12 ββ‘ 0x13 ββ‘ 0x1a ββ‘ 0x1b β
Β« βββββββββββββββββββββββββββββββββββββββββββββββββββββ
How can we reproduce the issue?
Using the source code below:
from numpy import pi, e as euler
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.circuit.library.standard_gates import SdgGate, TdgGate, SXGate, RXGate, RYGate, RZGate, U1Gate, U2Gate, U3Gate, SwapGate, XGate, YGate, ZGate, HGate, PhaseGate, SGate, TGate
qr = QuantumRegister(3)
cr = ClassicalRegister(5)
qc = QuantumCircuit(qr, cr)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 1)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 3)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 5)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 7)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 9)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 11)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 13)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 15)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 17)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 19)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 21)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 23)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 25)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 27)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 29)
qc.append(U1Gate(0).control(1), [1, 0]).c_if(cr, 31)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 2)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 3)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 6)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 7)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 10)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 11)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 14)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 15)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 18)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 19)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 22)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 23)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 26)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 27)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 30)
qc.append(U2Gate(0, 0).control(1), [0, 1]).c_if(cr, 31)
qc.append(U3Gate(0, 0, 0).control(1), [1, 0]).c_if(cr, 21)
qc.append(U3Gate(0, 0, 0).control(1), [1, 0]).c_if(cr, 23)
qc.append(SwapGate().control(1), [1, 0, 2]).c_if(cr, 2)
qc.append(SwapGate().control(1), [1, 0, 2]).c_if(cr, 3)
qc.append(SwapGate().control(1), [1, 0, 2]).c_if(cr, 10)
qc.append(SwapGate().control(1), [1, 0, 2]).c_if(cr, 11)
qc.append(SwapGate().control(1), [1, 0, 2]).c_if(cr, 18)
qc.append(SwapGate().control(1), [1, 0, 2]).c_if(cr, 19)
qc.append(SwapGate().control(1), [1, 0, 2]).c_if(cr, 26)
qc.append(SwapGate().control(1), [1, 0, 2]).c_if(cr, 27)
qc.draw() # For ASCII output
# qc.draw('mpl') # For MPL output
What should happen?
They should align in a vertical manner.
Any suggestions?
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Visualization and Juypter Tools - GitHub
Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and algorithms.
Read more >flight-path plotting lidar: Topics by Science.gov
Both navigation technologies were essential to obtaining useful results ... Lidar binary data tapes were successfully converted to ASCII Code on the VAXΒ ......
Read more >U5L1-Spell-Checker.xml - The Beauty and Joy of Computing
... ,could,after,even,because,us,said,good,way,two,should,work,use,through,see ... ,appropriate,possibly,join,seemed,powerful,speak,condition,spirit,findingΒ ...
Read more >Oceans '88 - GovInfo
IEEE Catalog Number 88-CH2585-8 OCEANS '88 Proceedings Volume Two Table of Contents PLASTICS IN OUR OCEANS: WHAT ARE WE DOING MESOCOSMS AS TOOLS...
Read more >Abstracts from the 50th European Society of Human Genetics ...
Results: We detected 21 (4.3%) cytogenetic aberrations, both ... This condition can be a result of a genomic instability and defects inΒ ...
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 FreeTop 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
Top GitHub Comments
iβd be hesitant to remove the side text gates completely just because a bug might be difficult to fix. The userβs experience should come first, and the side text gates have been in use for a while so removing them would probably have a negative impact on all users as opposed to just the handful that experience this bug.
That was my most likely conclusion as well, so thatβs what I did in #7673.