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 quickstart page on mid-circuit measurements #5870

Merged
merged 19 commits into from
Jun 20, 2024
Merged

Conversation

dwierichs
Copy link
Contributor

@dwierichs dwierichs commented Jun 18, 2024

Context:
The PennyLane documentation has a quickstart page on measurements, which includes a large section about mid-circuit measurements.
With the focus on dynamic circuits and mid-circuit measurements more generally, we would like to make the content on MCMs more visible.

Description of the Change:
Extracts the MCM part of the measurements quickstart and adds it as its own quickstart page.
Adds some details on simulation techniques and polishes the content.

Benefits:
Visibility, documentation extent for MCMs

Possible Drawbacks:

Related GitHub Issues:

[sc-65318]

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.

@dwierichs dwierichs requested a review from trbromley June 18, 2024 09:39
Copy link

codecov bot commented Jun 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.66%. Comparing base (14a0b63) to head (f28f967).
Report is 242 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5870      +/-   ##
==========================================
- Coverage   99.67%   99.66%   -0.01%     
==========================================
  Files         422      422              
  Lines       40658    40362     -296     
==========================================
- Hits        40525    40228     -297     
- Misses        133      134       +1     

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

Copy link
Contributor

@vincentmr vincentmr left a comment

Choose a reason for hiding this comment

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

Some suggestions, but otherwise looks good to me. Thanks @dwierichs .

pennylane/gradients/parameter_shift.py Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
Copy link
Contributor

@mudit2812 mudit2812 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 lot @dwierichs . I'm quite happy with this overall. I left a bunch of suggestions. One thought I had while reviewing this is to potentially reorganize the sections. The first 4 sections are really about "what features are available and how to use them", and the next 4 sections are about "simulating MCMs", and maybe it's worth organizing the doc as such. Example hierarchy below

Mid-circuit measurements in PennyLane: info about `qml.measure`
- Qubit reuse/reset
- Conditional operations
- Postselection
- Collecting MCM statistics

Simulation of MCMs: mostly the same as this section is currently
- deferred measurements
- one-shot
- tree traversal

Configuring MCMs: as it is currently

Another suggestion (though I would really like @trbromley 's input here) is to avoid applying the transforms themselves to the qnodes in the examples, as I believe we want to start using mcm_method. We can probably still say that the transforms are available to apply directly to tapes, but that qnodes should request specific configurations using mcm_method rather than decorators.

doc/releases/changelog-dev.md Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
@dwierichs
Copy link
Contributor Author

Thanks @mudit2812 for the detailed feedback! 🚀
Regarding the structure, I went for your suggestion, except for the last part (configuring MCMs) being part of the "Simulating MCMs" section.

Regarding applying transforms vs QNode config, I would suggest that for now we do not explicitly discourage users from using the transforms, but we do so implicitly by advertising the config path in the examples.

@mudit2812
Copy link
Contributor

Couple of weird things are happening:

  • The panel on the left side is showing a "Simulation of MCMs" page, but it just links to the "Simulation of MCMs" section inside the MCMs doc.
    image

  • The contents table for the MCMs doc (right side of the page) doesn't show the "Simulation of MCMs" section.
    image

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 @dwierichs, this is looking great! I've left a few comments.

doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Thanks @dwierichs . Once again this looks really good. I'm quite happy with the content of the doc, and am happy to approve once the remaining (small) comments are resolved, with the only blocking comment being the note about defer_measurements differentiability 😄

doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@mudit2812 mudit2812 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. Mostly non-blocking comments. Happy to approve :)

doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
doc/introduction/mid_circuit_measurements.rst Outdated Show resolved Hide resolved
@dwierichs dwierichs enabled auto-merge (squash) June 20, 2024 20:55
@dwierichs dwierichs merged commit 70ee43c into master Jun 20, 2024
39 checks passed
@dwierichs dwierichs deleted the mcm-quickstart branch June 20, 2024 20:57
mudit2812 pushed a commit that referenced this pull request Jul 2, 2024
**Context:**
The PennyLane documentation has a quickstart page on measurements, which
includes a large section about mid-circuit measurements.
With the focus on dynamic circuits and mid-circuit measurements more
generally, we would like to make the content on MCMs more visible.

**Description of the Change:**
Extracts the MCM part of the measurements quickstart and adds it as its
own quickstart page.
Adds some details on simulation techniques and polishes the content.

**Benefits:**
Visibility, documentation extent for MCMs

**Possible Drawbacks:**

**Related GitHub Issues:**

[sc-65318]

---------

Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
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.

5 participants