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

Add option to QuantumCircuit.draw to omit final measurements #13581

Open
kevinsung opened this issue Dec 18, 2024 · 3 comments
Open

Add option to QuantumCircuit.draw to omit final measurements #13581

kevinsung opened this issue Dec 18, 2024 · 3 comments
Labels
type: feature request New feature or request

Comments

@kevinsung
Copy link
Contributor

What should we add?

Often the last operation in a circuit is a measurement of all the qubits, and this takes up a lot of space in the drawing. I would like to add an option to omit final measurements from the drawing.

@kevinsung kevinsung added the type: feature request New feature or request label Dec 18, 2024
@Cryoris
Copy link
Contributor

Cryoris commented Dec 19, 2024

The solution proposed in #4149 which would just align all final measurements would also be nice, that way it is compact but we can still see the measurements.

@kevinsung
Copy link
Contributor Author

The solution proposed in #4149 which would just align all final measurements would also be nice, that way it is compact but we can still see the measurements.

Ah that's also a nice idea!

@enavarro51
Copy link
Contributor

enavarro51 commented Dec 30, 2024

@Cryoris, @kevinsung, @jakelishman I can take a look at this, at least for the mpl drawer. It does bring up a number of design questions.

  • In the following circuit,
qr = QuantumRegister(2)
cr = ClassicalRegister(3)
qc = QuantumCircuit(qr, cr)
qc.x(0)
qc.h(0)
qc.measure(0, 0)
qc.x(1)
qc.h(1)
qc.measure(1, 1)
qc.x(1)
qc.measure(1, 2)
qc.h(1)
qc.draw()

Image

since the first 2 measures are at the same depth, it seems reasonable to make these without the double vertical line as pictured in #4149. Having said that, why not make the third measure the same and remove all the double lines to the classical bits since the bit will be indicated either in the measure box or under it?

  • Taking this a step further,
qr = QuantumRegister(2)
cr = ClassicalRegister(3)
qc = QuantumCircuit(qr, cr)
with qc.if_test((cr, 2)):
    qc.x(0)
with qc.if_test(expr.equal(cr, 2)):
    qc.y(0)
qc.draw()

Image

if we were to put c6 == 2 under the If in the first red box, there would be no need for the double vertical lines here either. Which brings up the ultimate point, since the old c_if is going away and the measures can be done as above, why not do away with the entire classical bit section of the drawers?

This would free up a lot of space both vertically and horizontially as we move to 100+ qubit drawings, and it should be workable for both the mpl and text drawers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants