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 measure functions for MCMs in X, Y and arbitrary measurement basis #6953

Merged
merged 74 commits into from
Feb 28, 2025

Conversation

lillian542
Copy link
Contributor

@lillian542 lillian542 commented Feb 11, 2025

Note: I also added docs rendering in this PR (I meant to in the previous one), so we should include the docs rendering for the ftqc module in the review process


Context:
In the existing architecture of PennyLane, if a MCM returns a value that we would like to manipulate/use following the measurement, the MCM needs to be stored in a MeasurementValue. For the computational basis, qml.measure is the function that creates an MCM, links it to a MeasurementValue, and returns the MeasurementValue for use.

We've added a base class for creating MCMs in bases other than the computational basis to the ftqc module, but it doesn't have this functionality yet.

Description of the Change:
We add ftqc.measure_arbitrary_basis, ftqc.measure_x, and ftqc.measure_y, analogous to qml.measure.
Additionally, we add classes XMidMeasureMP and YMidMeasureMP (used in the x and y measurement functions), as subclasses of ParametrizedMidMeasureMP.

Benefits:

  • the measure functions allow us to easily return a measurement value and use or manipulate is, as in:
    m = measure_y(0)
    qml.cond(m, qml.RX)(2.345, 1)
  • designated classes for X and Y basis measurements will simplify logic in creating MBQC circuits, which rely mostly on X and Y basis MPs
  • designated classes for X and Y basis measurements allows them to be labelled clearly as X or Y (instead of XY-plane) measurements will improve circuit visualization

[sc-83347]

Copy link
Member

@multiphaseCFD multiphaseCFD left a comment

Choose a reason for hiding this comment

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

Thank you @lillian542 . LGTM!

Copy link
Contributor

@joeycarter joeycarter left a comment

Choose a reason for hiding this comment

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

Looks good to me, nice work! 🚀

Just had a few final editorial fixes and thoughts.

Copy link
Member

@mlxd mlxd left a comment

Choose a reason for hiding this comment

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

Thanks a bunch @lillian542
No concerns from my side

Copy link
Member

@multiphaseCFD multiphaseCFD left a comment

Choose a reason for hiding this comment

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

Thanks @lillian542 for the nice work!

@lillian542 lillian542 enabled auto-merge (squash) February 28, 2025 17:16
@lillian542 lillian542 merged commit 90a26a7 into master Feb 28, 2025
46 checks passed
@lillian542 lillian542 deleted the ftqc_measure branch February 28, 2025 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants