-
Notifications
You must be signed in to change notification settings - Fork 575
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
New text circuit drawer #1885
New text circuit drawer #1885
Conversation
Hello. You may have forgotten to update the changelog!
|
@albi3ro does the new circuit drawer preserve the ability to print scalar parameters, e.g., >>> print(draw_text(tape))
0: ─╭QFT──RX(0.1)─╭C─┤ State
1: ─├QFT──RY(0.2)─├C─┤ State
2: ─╰QFT──RZ(0.3)─│──┤ State
aux: ───────────────╰X─┤ <Z> State I would say that this is a very important feature, since we use this to visualize circuit diagrams with rotation parameters across the docs + blog + demos! |
@josh146 Yes it can print scaler parameters via something like |
Hey all, just curious on the timeframe for this PR? |
@josh146 I'm going to make it my first priority next quarter. Mostly just test writing at this point, but those are going to be extensive. It could probably use a round of pre-review if anyone has the time. |
…ylane into new_text_drawer
…ylane into new_text_drawer
Something I noticed while comparing the old drawer to the new, is the change in the
Another thing I'm curious about is the capability of drawing multiple measurement layers. Was this added with complex measurement processes in mind or for practical reasons? |
[sc-12939] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few small things but other than that it looks really good! 8x speed up is insane!
pennylane/drawer/tape_text.py
Outdated
|
||
for op in layer: | ||
# Currently can't use `isinstance(op, QuantumTape)` due to circular imports | ||
if isinstance(op, qml.tape.QuantumTape): # isa tape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if isinstance(op, qml.tape.QuantumTape): # isa tape | |
if isinstance(op, qml.tape.QuantumTape): # is a tape |
2: ─╰QFT──RZ─│──┤ Probs | ||
aux: ──────────╰X─┤ <Z> Probs | ||
|
||
.. UsageDetails:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth it to add a usage case example for the tape_offset
kwarg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding.
Just another thing I came across when playing around with it. There are two features of the old text drawer that don't pass over: the numbering of I think the first feature is nice to have since we now omit showing the unitary matrices; if they are labeled the user can at least keep track of them and see if / where they repeat in the circuit. The second feature would also be a nice to have as it just provides more info in general, but maybe not fully required. |
Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>
…ylane into new_text_drawer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
This method can hopefully replace
CircuitGraph.draw()
and associated objects likeCircuitDrawer
,RepresentationResolver
andCharset
.This function already:
max_length
Issue Preventing printing overflow for long circuits in terminal withqml.draw_circuit()
#1841decimals
for printing scalar parameters to arbitrary precision-naturally supports templates
-broadcasts
qml.state
across all wiresDownsides: This function does not display matrix-valued parameters below the circuit diagram. Circuit drawings are for inspecting whether or not everything is generally in the correct place. Users can inspect specific parameters via other means.