-
Notifications
You must be signed in to change notification settings - Fork 58
feat: add cluster visualization for FuncOp and DeviceInitOp operations
#2231
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
base: feature/graph-visualization
Are you sure you want to change the base?
Conversation
frontend/catalyst/python_interface/visualization/construct_circuit_dag.py
Outdated
Show resolved
Hide resolved
frontend/test/pytest/python_interface/visualization/test_construct_circuit_dag.py
Show resolved
Hide resolved
frontend/catalyst/python_interface/visualization/construct_circuit_dag.py
Outdated
Show resolved
Hide resolved
frontend/catalyst/python_interface/visualization/construct_circuit_dag.py
Outdated
Show resolved
Hide resolved
| if num_qnodes == 1: | ||
| visualize = False |
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.
What if there is only 1 qnode but there are also classical instructions outside the qnode call? I.e.
@qml.qjit
def workflow(x):
<classical operations>
@qml.qnode(dev)
def circuit(...):
...
res = circuit(...)
<classical stuff>
return ...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.
Good question. For now we are not visualizing classical operations so only quantum operations within the circuit will render. The way the visualization is currently written, it will only show a single circuit cluster but perhaps it should also have the outer workflow cluster too ... 🤔
CC @AntonNI8 - what do you think?
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.
It's fine if we have an outer workflow cluster, but it's kept blank (the only thing inside it is the QNode). That should allow a smoother transition to multi-QNode workflows later on.
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.
frontend/catalyst/python_interface/visualization/construct_circuit_dag.py
Outdated
Show resolved
Hide resolved
mudit2812
left a comment
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 good, just a few comments
…cuit_dag.py Co-authored-by: Mudit Pandey <18223836+mudit2812@users.noreply.github.com>
…cuit_dag.py Co-authored-by: Mudit Pandey <18223836+mudit2812@users.noreply.github.com>
…cuit_dag.py Co-authored-by: Mudit Pandey <18223836+mudit2812@users.noreply.github.com>
mehrdad2m
left a comment
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 good on my side as well. Happy to approve once the open conversations are resolved. The only thing that scares me a little is the that the implementation is heavily dependent on the current IR structure which sometimes make it look hacky. That would be fine for MVP but we should also be careful not add too much tech debt.
Any section in particular? I would assume this one: |
frontend/test/pytest/python_interface/visualization/test_construct_circuit_dag.py
Show resolved
Hide resolved
I removed the hacky work around. See context here. |
frontend/catalyst/python_interface/visualization/construct_circuit_dag.py
Outdated
Show resolved
Hide resolved
| # If it is a multi-qnode workflow, it will represent the "workflow" function | ||
| # If it is a single qnode, it will represent the quantum function. |
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 it is a multi-qnode workflow, it will represent the "workflow" function | |
| # If it is a single qnode, it will represent the quantum function. |
This PR adds the ability to view multiple QNodes in a workflow with clusters and their devices as nodes within said clusters.
Some examples,
[sc-104730]
[sc-104731]