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

Extend qcut.tape_to_graph to support sampling measurements #2313

Merged
merged 8 commits into from
Mar 14, 2022

Conversation

anthayes92
Copy link
Contributor

@anthayes92 anthayes92 commented Mar 12, 2022

Context:
Many practical applications of quantum circuits require sampling measurements. Here we begin extending the existing manual circuit cutting pipeline to support sampling measurements.

Description of the Change:
The existing qcut.tape_to_graph method has been extended to convert a sampling in the computational basis over all wires in a circuit. The single sampling measurement is converted into distinct nodes in the computational graph; one for each wire.

Benefits:
First step toward supporting cutting circuit with sampling measurements.

Possible Drawbacks:
Does not support sample measurements containing observables.

Related GitHub Issues:
#2297 sampling with and without observables in a single circuit causes an error. As such, the sample nodes added to the graph contain an explicit projection measurement equivalent to sampling in the computational basis. This is required for later steps in the cutting pipeline when converting subgraphs to fragment tapes.

@codecov
Copy link

codecov bot commented Mar 12, 2022

Codecov Report

Merging #2313 (2704c16) into master (6786127) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2313   +/-   ##
=======================================
  Coverage   99.32%   99.32%           
=======================================
  Files         242      242           
  Lines       19160    19166    +6     
=======================================
+ Hits        19031    19037    +6     
  Misses        129      129           
Impacted Files Coverage Δ
pennylane/transforms/qcut.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6786127...2704c16. Read the comment docs.

Copy link
Contributor

@trbromley trbromley left a comment

Choose a reason for hiding this comment

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

Thanks @anthayes92! Looks good, left a few suggestions.

pennylane/transforms/qcut.py Outdated Show resolved Hide resolved
pennylane/transforms/qcut.py Outdated Show resolved Hide resolved
pennylane/transforms/qcut.py Show resolved Hide resolved
doc/releases/changelog-dev.md Outdated Show resolved Hide resolved
tests/transforms/test_qcut.py Show resolved Hide resolved
@trbromley
Copy link
Contributor

[sc-15861]

anthayes92 and others added 3 commits March 14, 2022 09:52
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Copy link
Contributor

@trbromley trbromley left a comment

Choose a reason for hiding this comment

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

Thanks @anthayes92. Please resolve the suggestions, but otherwise approved!

tests/transforms/test_qcut.py Outdated Show resolved Hide resolved
tests/transforms/test_qcut.py Show resolved Hide resolved
tests/transforms/test_qcut.py Show resolved Hide resolved
tests/transforms/test_qcut.py Outdated Show resolved Hide resolved
tests/transforms/test_qcut.py Outdated Show resolved Hide resolved
tests/transforms/test_qcut.py Outdated Show resolved Hide resolved
anthayes92 and others added 2 commits March 14, 2022 14:31
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
@anthayes92 anthayes92 merged commit 0269f9a into master Mar 14, 2022
@anthayes92 anthayes92 deleted the qcut-split-sampling-nodes-in-tape-to-graph branch March 14, 2022 23:15
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.

2 participants