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

Complete first section of Pauli Twirling user guide #2454

Merged
merged 11 commits into from
Jul 31, 2024
Merged

Conversation

cosenal
Copy link
Contributor

@cosenal cosenal commented Jul 26, 2024

Description

Fullfills acceptance criteria of #2435.

Still a draft PR to discuss the noise model that should be used to highlight the effect of Pauli Twirling.
The noise model of choice is a coherent error introduced by applying a Rx(theta) gate on the output of each 2-qubit gate.

Imho this is a strict improvement on the current state of the guide, where the final and arguably the most important notebook cell was commented out and not working correctly.

⚠️ I renamed the API method pauli_twirl_circuit in the mitiq.pt.pt module to generate_pauli_twirl_variants, because it wasn't clear from the old name that it generate a list of twirled circuits (in fact the docstring itself was wrong on describing the output of the function.) Since the Pauli Twirling module is still under construction, I wouldn't consider this a breaking change. However, if you have objections, I can revert this renaming back.


License

  • I license this contribution under the terms of the GNU GPL, version 3 and grant Unitary Fund the right to provide additional permissions as described in section 7 of the GNU GPL, version 3.

Before opening the PR, please ensure you have completed the following where appropriate.

Copy link

codecov bot commented Jul 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.70%. Comparing base (02ebc4b) to head (75359e6).
Report is 45 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2454   +/-   ##
=======================================
  Coverage   98.70%   98.70%           
=======================================
  Files          88       88           
  Lines        4083     4083           
=======================================
  Hits         4030     4030           
  Misses         53       53           

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

return CircuitOperation(
Circuit(
op.gate.on(*op.qubits),
depolarize(p=noise_level, n_qubits=2).on_each(op.qubits)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if you change depolarize to a coherent noise channel? As we can describe a depolarizing channel using paulis, I don't think pauli twirling is going to do anything to tailor the noise of the input circuit.

See section 2.1.3 of https://arxiv.org/pdf/1509.02921 If a Pauli Transfer Matrix of some noise channel has off-diagonal terms, we expect the noise to be tailored after twirling.

Copy link
Contributor Author

@cosenal cosenal Jul 28, 2024

Choose a reason for hiding this comment

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

I have now changed the noise to a coherent one, please take a look.

@cosenal cosenal marked this pull request as ready for review July 28, 2024 17:38
@cosenal cosenal requested a review from purva-thakre July 28, 2024 17:45
Copy link
Collaborator

@purva-thakre purva-thakre left a comment

Choose a reason for hiding this comment

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

LGTM! Made some minor suggestions on the wording.

docs/source/guide/pt-1-intro.md Outdated Show resolved Hide resolved
docs/source/guide/pt-1-intro.md Outdated Show resolved Hide resolved
docs/source/guide/pt-1-intro.md Outdated Show resolved Hide resolved
docs/source/guide/pt-1-intro.md Outdated Show resolved Hide resolved
docs/source/guide/pt-1-intro.md Outdated Show resolved Hide resolved
docs/source/guide/pt-1-intro.md Outdated Show resolved Hide resolved
docs/source/guide/pt-1-intro.md Outdated Show resolved Hide resolved
docs/source/guide/pt-1-intro.md Show resolved Hide resolved
@purva-thakre
Copy link
Collaborator

renamed the API method pauli_twirl_circuit in the mitiq.pt.pt module to generate_pauli_twirl_variants

Since the Pauli Twirling module is still under construction, I wouldn't consider this a breaking change. However, if you have objections, I can revert this renaming back

I am fine with the change. It's consistent with the pattern of how we named benchmarking circuits functions.

Thanks for catching the docstring leftovers!

@cosenal cosenal requested a review from purva-thakre July 30, 2024 14:29
@cosenal
Copy link
Contributor Author

cosenal commented Jul 30, 2024

@purva-thakre Addressed your comments and made further improvements to the docstring. PTAL

Copy link
Member

@natestemen natestemen left a comment

Choose a reason for hiding this comment

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

Good clean/elucidation! A few minor things from me.

mitiq/pt/pt.py Show resolved Hide resolved
docs/source/guide/pt-1-intro.md Outdated Show resolved Hide resolved
docs/source/guide/pt-1-intro.md Show resolved Hide resolved
docs/source/guide/pt-1-intro.md Outdated Show resolved Hide resolved
docs/source/guide/pt-1-intro.md Show resolved Hide resolved
@cosenal cosenal requested a review from natestemen July 30, 2024 22:37
Copy link
Collaborator

@purva-thakre purva-thakre left a comment

Choose a reason for hiding this comment

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

MWR!

@cosenal
Copy link
Contributor Author

cosenal commented Jul 31, 2024

Merging, as the failing test test_with_observable_batched_factory is unrelated to those changes. We will investigate separately, see #2442.

@cosenal cosenal merged commit 357f2c0 into main Jul 31, 2024
17 of 18 checks passed
@cosenal cosenal deleted the pt-user-guide-fix-0 branch July 31, 2024 13:34
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