Skip to content

Conversation

@andrijapau
Copy link
Contributor

@andrijapau andrijapau commented Nov 25, 2025

This PR adds basic cluster visualization for these control flow operators.

⚠️ The cluster labels are not descriptive at the moment but a future PR should improve upon them (not required for MVP).

@qml.qjit(autograph=True, target="mlir")
@qml.qnode(dev)
def my_workflow(x):
    if x == 2:
        qml.X(0)
    elif x == 3:
        qml.Y(0)
    else:
        qml.Z(0)

    for i in range(3):
        qml.H(0)

    counter = 0 
    while counter < 5:
        qml.RX(0.5, 0)
Screenshot 2025-12-10 at 3 05 55 PM

[sc-103462]
[sc-103464]
[sc-103465]

@andrijapau andrijapau added wip PRs that are a Work-In-Progress unified compiler Pull requests for the integration with xDSL labels Nov 25, 2025
@andrijapau andrijapau changed the title Feature/control flow clusters feat: visualize control flow as clusters in the graph Nov 25, 2025
@andrijapau andrijapau changed the title feat: visualize control flow as clusters in the graph feat: visualize control flow operations as clusters in the graph Nov 25, 2025
Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 blocking comments:

  • if-elif-else blocks seems to be incorrectly handled
  • WhileOp should probably have a main cluster with 2 clusters inside it, similar to an IfOp, for the before/after_regions

@andrijapau andrijapau requested a review from mudit2812 December 9, 2025 02:20
Copy link
Contributor

@mehrdad2m mehrdad2m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andrijapau, looks good. I only have some concerns regarding the flattening logic.

@andrijapau andrijapau requested a review from mehrdad2m December 9, 2025 18:07
Copy link
Contributor

@mehrdad2m mehrdad2m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will approve to not block the PR, I think I looks good as long as the unresolved conversation is fixed.

@andrijapau
Copy link
Contributor Author

I will approve to not block the PR, I think I looks good as long as the unresolved conversation is fixed.

Thanks, I think the fix is already in place. I posted in slack here to see product's opinion.

@andrijapau andrijapau merged commit 8f6563e into feature/graph-visualization Dec 10, 2025
34 checks passed
@andrijapau andrijapau deleted the feature/control-flow-clusters branch December 10, 2025 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unified compiler Pull requests for the integration with xDSL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants