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

Fix qml.draw/_mpl to work with deferred measurements circuits that use MCMs in measurements #5610

Merged
merged 5 commits into from May 1, 2024

Conversation

mudit2812
Copy link
Contributor

Context:
defer_measurements leaves MeasurementValues in the terminal measurement processes if they are present. This is not friendly with the drawer as the classical wires for those measurement values do not exist when using defer_measurements. This PR adds a "hack" fix so that the drawer/MPL drawer work with this scenario.

Description of the Change:
Add transform_deferred_measurements_tape util function, which replaces any MeasurementValues present in the tape after applying defer_measurements with wires. This transform is only applied in tape_text and tape_mpl.

Benefits:
Drawer works better with MCMs

Possible Drawbacks:
Hacky fix, technical debt to implement cleaner fix later

Related GitHub Issues:
#5588

@mudit2812 mudit2812 changed the base branch from master to v0.36.0-rc0 April 30, 2024 21:27
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.

Copy link

codecov bot commented Apr 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (v0.36.0-rc0@7621935). Click here to learn what that means.

Additional details and impacted files
@@              Coverage Diff               @@
##             v0.36.0-rc0    #5610   +/-   ##
==============================================
  Coverage               ?   99.69%           
==============================================
  Files                  ?      412           
  Lines                  ?    38302           
  Branches               ?        0           
==============================================
  Hits                   ?    38184           
  Misses                 ?      118           
  Partials               ?        0           

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

@mudit2812 mudit2812 added this to the v0.36 milestone May 1, 2024
@mudit2812
Copy link
Contributor Author

[sc-62204]

Copy link
Contributor

@dwierichs dwierichs left a comment

Choose a reason for hiding this comment

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

Nice, thanks for the quick fix @mudit2812 :)
Just one suggestion to cover the uncovered line within a test you added.

tests/transforms/test_defer_measurements.py Outdated Show resolved Hide resolved
@mudit2812 mudit2812 requested a review from dwierichs May 1, 2024 15:11
Copy link
Contributor

@dwierichs dwierichs left a comment

Choose a reason for hiding this comment

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

Thanks!

@mudit2812 mudit2812 enabled auto-merge (squash) May 1, 2024 20:49
@mudit2812 mudit2812 merged commit 091cd68 into v0.36.0-rc0 May 1, 2024
37 checks passed
@mudit2812 mudit2812 deleted the draw-deferred-mcm branch May 1, 2024 21:16
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.

[BUG] qml.draw, qml.draw_mpl do no work with qml.defer_measurements when collecting MCM statistics
3 participants