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

LRE ZNE comparison tutorial #2551

Merged
merged 10 commits into from
Nov 7, 2024
Merged

LRE ZNE comparison tutorial #2551

merged 10 commits into from
Nov 7, 2024

Conversation

FarLab
Copy link
Contributor

@FarLab FarLab commented Nov 1, 2024

A small tutorial applying LRE and ZNE on rotated randomized benchmarking circuits, comparing the performance on a small set of circuits and the resources required for it.

Copy link

codecov bot commented Nov 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.72%. Comparing base (36e0285) to head (70da77b).
Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2551   +/-   ##
=======================================
  Coverage   98.72%   98.72%           
=======================================
  Files          92       92           
  Lines        4161     4167    +6     
=======================================
+ Hits         4108     4114    +6     
  Misses         53       53           

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

@FarLab FarLab linked an issue Nov 1, 2024 that may be closed by this pull request
@purva-thakre
Copy link
Contributor

@FarLab Right now your example is not showing up in the RTD build. Instructions are available here.

@FarLab
Copy link
Contributor Author

FarLab commented Nov 4, 2024

@natestemen @cosenal in the docs-build, I am getting the following error:

build finished with problems, 1 warning.
make[1]: *** [Makefile:20: html] Error 1
make[1]: Leaving directory '/home/runner/work/mitiq/mitiq/docs'
make: *** [Makefile:38: docs] Error 2

what does this mean?

@purva-thakre
Copy link
Contributor

purva-thakre commented Nov 4, 2024

@FarLab You can see the error if you scroll up

https://github.com/unitaryfund/mitiq/actions/runs/11644169797/job/32425762750?pr=2551#step:8:1469

image

Seems like you referenced a file and there was an issue with creating the link. You can also see that the corresponding link is broken in the RTD build.

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.

Great demonstration Farrokh! I've left some minor comments, along with one larger suggestion for the second half.

docs/source/examples/lre-zne-comparison.md Outdated Show resolved Hide resolved
docs/source/examples/lre-zne-comparison.md Outdated Show resolved Hide resolved
docs/source/examples/lre-zne-comparison.md Outdated Show resolved Hide resolved
docs/source/examples/lre-zne-comparison.md Outdated Show resolved Hide resolved
docs/source/examples/lre-zne-comparison.md Outdated Show resolved Hide resolved
print(f'Average error for ideal values: {np.abs(np.mean(ideal_values) - p(0.7))}')
```

For the ideal values we still see a small error, since the circuits are randomly generated and the theoretical value is achieved in the limit where we generate all the possible circuits.
Copy link
Member

Choose a reason for hiding this comment

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

Is the error in the ideal because we only have a sample of 50 circuits? What would it mean to generate "all the possible circuits"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the ideal value (the function p that I defined) is the probability of measuring 0 when taking an average over all the rotated rb circuits. In this case we are only generating 50 such random circuits, so there will be noise due to randomness. I can try to rephrase it a bit better!

print(f'Average error of mitigated values using ZNE: {error_zne}')
```

## Resource estimation
Copy link
Member

Choose a reason for hiding this comment

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

In this section, instead of re-computing all the circuits, what if we

  1. converted our python function execute into an Executor,1 and
  2. used the Executor attributes executed_circuits and calls_to_executor to understand the overhead.

I think this would make for a cleaner tutorial, and demonstrate some of the maybe less-used functionality of the executor class. The downside of this approach is that it means we don't use the multivariate_layer_scaling and scaled_circuits functions here.

Footnotes

  1. Technically, we'll have to define two Executor objects, one for ZNE, and another for LRE so the circuits are kept separate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can discuss this in more detail, but I think it is nice to use these new functions to access the circuits that are to be executed.

Copy link
Member

Choose a reason for hiding this comment

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

Met with Farrokh to discuss today and we agreed the tutorial as written is good. The resource estimation workflow is good to demo on its own, even if the circuits have to be regenerated. It demonstrates a more realistic workflow, rather than running, and then looking at overhead.

docs/source/examples/lre-zne-comparison.md Outdated Show resolved Hide resolved
@natestemen natestemen merged commit 56f5e49 into main Nov 7, 2024
18 checks passed
@natestemen natestemen deleted the lre-tutorial branch November 7, 2024 02:28
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.

LRE Tutorials
3 participants