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

Handling MCM in captured transforms #7020

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

PietropaoloFrisoni
Copy link
Contributor

@PietropaoloFrisoni PietropaoloFrisoni commented Feb 27, 2025

Context: Plxpr transforms such as cancel_inverses, which use dictionaries to hold ops that have been traced, but not yet applied, are giving incorrect results with MCMs in the circuit.

Description of the Change: We apply the previously stored operators before applying the MCM, so that the result is correct.

Benefits: Correct result.

Possible Drawbacks: As for other higher-order primitives, we risk that some optimizations are not applied. For example, in the case of cancel inverses, if we have an operation O on wire 0. a MCM on wire 1, and then the inverse of O on wire 0, we are not canceling O with its inverse (although we could, because the measurement is on a different wire).

This is a further enhancement that can be implemented in the future for all the higher-order primitives and all the quantum transforms with program capture enabled.

Related GitHub Issues: None.

Related Shortcut Stories: [sc-85404]

Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@PietropaoloFrisoni PietropaoloFrisoni marked this pull request as ready for review February 27, 2025 21:43
@PietropaoloFrisoni PietropaoloFrisoni changed the title Initial commit Adding an interpreting mcm method to PlxprInterpret Feb 27, 2025
@PietropaoloFrisoni PietropaoloFrisoni changed the title Adding an interpreting mcm method to PlxprInterpret Adding an interpret_mcm_eqn method to the PlxprInterpreter class/ Feb 27, 2025
@PietropaoloFrisoni PietropaoloFrisoni changed the title Adding an interpret_mcm_eqn method to the PlxprInterpreter class/ Adding an interpret_mcm_eqn method to the PlxprInterpreter class Feb 27, 2025
Copy link

codecov bot commented Feb 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.60%. Comparing base (9b45754) to head (996ef54).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7020   +/-   ##
=======================================
  Coverage   99.60%   99.60%           
=======================================
  Files         484      484           
  Lines       46305    46315   +10     
=======================================
+ Hits        46122    46132   +10     
  Misses        183      183           

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

@PietropaoloFrisoni PietropaoloFrisoni changed the title Adding an interpret_mcm_eqn method to the PlxprInterpreter class Handling MCM in captured transforms Feb 27, 2025
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.

1 participant