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

Example stacking DDD and ZNE #2345

Merged
merged 15 commits into from
May 13, 2024
Merged

Example stacking DDD and ZNE #2345

merged 15 commits into from
May 13, 2024

Conversation

jordandsullivan
Copy link
Contributor

@jordandsullivan jordandsullivan commented May 3, 2024

Description

Tutorial to combine ZNE and DDD.


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.

… Currently combining DDD + ZNE is failing due to a return type incompatbility
@jordandsullivan jordandsullivan linked an issue May 3, 2024 that may be closed by this pull request
Copy link

codecov bot commented May 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.22%. Comparing base (2ff8134) to head (b70e53f).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2345   +/-   ##
=======================================
  Coverage   98.22%   98.22%           
=======================================
  Files          87       87           
  Lines        4059     4059           
=======================================
  Hits         3987     3987           
  Misses         72       72           

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

@nathanshammah
Copy link
Member

Thanks @jordandsullivan. To solve the issue that the notebook doesn't render in the documentation, you just need to add it to the TOC tree in the examples file. Eventually we use md files, but as a temporary file, it should work fine also with .ipynb format. The jupytext extension allows you to edit the md file as a notebook.

@nathanshammah nathanshammah changed the title 2344 stack ddd zne Example stacking DDD and ZNE May 6, 2024
@nathanshammah
Copy link
Member

My suggestion is that the executor should be only called by ZNE. The DD part is a "pre-processing", with input the initial circuit (e.g., GHZ state) and output the DD compiled quantum circuit. This is fed to ZNE. This should remove incompatibility types.
ddd.insert_ddd_sequences should be used. See the documentation here and here.

@jordandsullivan
Copy link
Contributor Author

My suggestion is that the executor should be only called by ZNE. The DD part is a "pre-processing", with input the initial circuit (e.g., GHZ state) and output the DD compiled quantum circuit. This is fed to ZNE. This should remove incompatibility types. ddd.insert_ddd_sequences should be used. See the documentation here and here.

Thanks for the tip @nathanshammah , that did it. Now the question is mainly how to find a combination of error levels and circuit depth for which using DDD and ZNE together is in fact useful. Unfortunately, DDD seems to do best when you insert a lot of idle time in the circuit (which I modeled by inserting identity gates), while ZNE does significantly worse. ZNE itself shines in lower depth circuits.

Perhaps it would be useful to do a characterization sweep of the range of noise levels or circuit depths at which each technique was useful?

@jordandsullivan jordandsullivan marked this pull request as ready for review May 8, 2024 04:35
@jordandsullivan jordandsullivan self-assigned this May 8, 2024
Copy link
Contributor

@cosenal cosenal left a comment

Choose a reason for hiding this comment

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

Left some preliminary comments, but I haven't run the notebook yet.

docs/source/examples/combine_ddd_zne.md Outdated Show resolved Hide resolved
docs/source/examples/combine_ddd_zne.ipynb Outdated Show resolved Hide resolved
docs/source/examples/combine_ddd_zne.md Show resolved Hide resolved
docs/source/examples/combine_ddd_zne.md Show resolved Hide resolved
mitiq/benchmarks/mirror_circuits.py Outdated Show resolved Hide resolved
@jordandsullivan
Copy link
Contributor Author

I'm not sure why the output does not seem to be getting included in the docs build :/ https://mitiq--2345.org.readthedocs.build/en/2345/examples/combine_ddd_zne.html

@cosenal
Copy link
Contributor

cosenal commented May 10, 2024

@jordandsullivan hm? I can see the output in the doc build.

@jordandsullivan
Copy link
Contributor Author

jordandsullivan commented May 10, 2024

@cosenal Ah I just needed to do a hard reload (CMD+SHIFT+R) in my browser. It's showing up for me now :)

Copy link
Contributor

@cosenal cosenal left a comment

Choose a reason for hiding this comment

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

The one at the bottom is the most important comment.

docs/source/examples/combine_ddd_zne.md Outdated Show resolved Hide resolved
docs/source/examples/combine_ddd_zne.md Outdated Show resolved Hide resolved
docs/source/examples/combine_ddd_zne.md Show resolved Hide resolved
docs/source/examples/combine_ddd_zne.md Outdated Show resolved Hide resolved
docs/source/examples/combine_ddd_zne.md Outdated Show resolved Hide resolved
docs/source/examples/combine_ddd_zne.md Outdated Show resolved Hide resolved
@cosenal cosenal self-requested a review May 13, 2024 17:22
@cosenal
Copy link
Contributor

cosenal commented May 13, 2024

LGTM!

@jordandsullivan jordandsullivan merged commit bf9e33d into main May 13, 2024
18 checks passed
@jordandsullivan jordandsullivan deleted the 2344-stack-ddd-zne branch May 13, 2024 18:42
cosenal pushed a commit that referenced this pull request Jun 26, 2024
* First draft tutorial DDD + ZNE

* Ammended error model to be time-correlated to allow DDD to be useful. Currently combining DDD + ZNE is failing due to a return type incompatbility

* Add measurements. Still return type incompatibility

* Switched from using ddd.mitigate_executor to inserting ddd sequences into the circuit itself and passing that to zne. Now functional

* Adding markdown version of tutorial

* Updated docstring for generate_mirror_circuits to reflect accurate return types

* Identified error model and qubit idle regime in which the techniques work better together

* Added new md notebook to examples toctree

* Change format to myst so that cells execute in docs build

* Adding formats: md:myst to display notebook correctly

* Rephrase final sentence

* Correct execute call to be `noisy-exec`, add clarity.

* Remove unnecessary new executor instantiation.

* correct typo
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.

DDD + ZNE tutorial.
3 participants