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

Capture "for_loop" workflow #1509

Merged
merged 10 commits into from
Feb 14, 2025
Merged

Capture "for_loop" workflow #1509

merged 10 commits into from
Feb 14, 2025

Conversation

rauletorresc
Copy link
Contributor

@rauletorresc rauletorresc commented Feb 11, 2025

Context: Currently, Catalyst cannot compile and execute captured workflows with for_loop control flow. E.g.:

dev = qml.device("lightning.qubit", wires=1)

@qml.qjit(experimental_capture=True)
@qml.qnode(dev)
def circuit(n, x):

    @qml.for_loop(0, n, 1)
    def loop_rx(i, x):
            qml.RX(x, wires=0)
            return jnp.sin(x)

    # apply the for loop
    final_x = loop_rx(x)

    return qml.expval(qml.Z(0))

circuit(10, 0.3) # Array(-0.94854724, dtype=float64)

Description of the Change: Reuse the Branch interpreter created at #1468

Benefits: Extended support for plxpr capture.

  • Enable pre-existent skipped test
  • Update changelog
  • Add more test cases

[sc-81880]

@rauletorresc rauletorresc added the frontend Pull requests that update the frontend label Feb 11, 2025
@rauletorresc rauletorresc requested review from albi3ro and a team February 11, 2025 03:25
@rauletorresc rauletorresc self-assigned this Feb 11, 2025
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.74%. Comparing base (bf7ecba) to head (207ef61).
Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1509   +/-   ##
=======================================
  Coverage   96.73%   96.74%           
=======================================
  Files          76       76           
  Lines        8219     8236   +17     
  Branches      779      779           
=======================================
+ Hits         7951     7968   +17     
  Misses        213      213           
  Partials       55       55           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@PietropaoloFrisoni PietropaoloFrisoni left a comment

Choose a reason for hiding this comment

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

Thanks @rauletorresc!

I am not very familiar with the Catalyst pipeline, but this LGTM and I see that we are inheriting from the same PlxprInterpreter. I am very curious to test this with the features we are currently working on 🚀

@rauletorresc rauletorresc merged commit 6942e30 into main Feb 14, 2025
46 checks passed
@rauletorresc rauletorresc deleted the raultorres/loop_capture branch February 14, 2025 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Pull requests that update the frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants