Skip to content

Don't defer mid-circuit measurements when mcm_method is "device" #7243

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

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

Conversation

lillian542
Copy link
Contributor

Context:
Some mid-circuit measurement handling is device-specific, like tree-traversal. When a method is device-specific, we want to skip transforming the tape in the standard preprocess pipeline, and instead rely on handling that is implemented in the device class.

This is currently the case for tree-traversal, but the more generic specification "device" defaults to deferred measurements.

Description of the Change:

We handle mcm_method="device" in the mid_circuit_measurements transform the same way we handle mcm_method="tree-traversal" - with a null transform and null_postprocessing.

Benefits:
Generally, we can use "device" the way it seems to have been intended as a method for handling mid-circuit measurements.

More specifically, we can use "device" as an MCM method on null.qubit if we don't want to include transforming and post-processing MCMs in our mock execution, but just want to treat MCMs like any other operation on the tape with null.qubit and skip it. This will be helpful for benchmarking the device processing and post-processing for large-scale FTQC workloads on null.qubit.

Copy link
Contributor

github-actions bot commented Apr 9, 2025

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.

@lillian542 lillian542 marked this pull request as ready for review April 9, 2025 18:15
Copy link

codecov bot commented Apr 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.64%. Comparing base (b2f1f65) to head (c33331c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7243   +/-   ##
=======================================
  Coverage   99.64%   99.64%           
=======================================
  Files         513      513           
  Lines       50172    50172           
=======================================
  Hits        49996    49996           
  Misses        176      176           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@andrijapau andrijapau left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

I'm just confused about the doc string,

"""Provide the transform to handle mid-circuit measurements.
    If the tape or device uses finite-shot, use the native implementation (i.e. no transform),
    and use the ``qml.defer_measurements`` transform otherwise.
"""

Isn't it true that if the tape is using finite shots then we are using the dynamic_one_shot transform?

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.

3 participants