-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
PT + ZNE tutorial #2601
base: main
Are you sure you want to change the base?
PT + ZNE tutorial #2601
Conversation
@natestemen Do you mind taking a quick look at the general outline of this tutorial? I have to clean up the code a bit. So, you could ignore the code blocks for now. I am not too sure if I need to describe something in excruciating detail as the PT user guide is still WIP. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2601 +/- ##
==========================================
+ Coverage 98.72% 98.74% +0.01%
==========================================
Files 92 93 +1
Lines 4168 4219 +51
==========================================
+ Hits 4115 4166 +51
Misses 53 53 ☔ View full report in Codecov by Sentry. |
Took a quick look through things and this looks great! I think it's a nice split of theory and practice. I can imagine some of the material working its way in to the user guide, but lets not worry about that for now. |
@natestemen The comparison plot is missing data related to only ZNE values. This is because the circuit I am using is very small for ZNE. If I increase the circuit size used for the comparison plot, the time taken by the tutorial during execution is a lot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't finished reading through everything just yet, but wanted to get feedback soon so we can start iterating.
Overall this is a really great mix of theory and practice. Well done setting the bones up.
I restarted the RTD build; having a rendered version will make it easier to review. |
3f6f478
to
cf8b1a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really solid tutorial! Can't wait to get it up!
plt.ylabel("Expectation Values Difference") | ||
plt.title("Comparison of expectation values with ideal as a function of noise strength") | ||
plt.legend() | ||
plt.show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we understand why ZNE is so good when the noise strength = 0.5?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not too sure for the circuit used in this example.
If I use a smaller GHZ circuit of 2 qubits, the noise does not do anything as the final state vector before and after adding coherent noise is the same. Interestingly, this behavior is not preserved as the number of qubits in the initial ghz circuit is increased. Worth looking into!
Co-authored-by: nate stemen <[email protected]>
5c95219
to
d0d4b2c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments, but hopefully nothing major!
docs/source/examples/pt_zne.md
Outdated
**Incoherent noise** is a process that results in the quantum system entangling with its environment i.e. this type of noise is irreversible. The system and the environment end up in a mixed state. It scales linearly in the small error limit. | ||
The noise channel can be described using Pauli operators which makes it easy to analyze and simulate. Worst case error rate is directly proportional to the **average gate infidelity**. | ||
|
||
For example, a depolarizing noise channel is a stochastic noise channel where a noiseless process is probabilistically mixed with orthogonal errors. If $\rho$ is a single qubit state, $p$ is the probabilistic error rate and $\mathcal{E}(\rho)$ is the noise channel: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great example, but it needs a connection back to (in)coherent noise. Can you add something, maybe at the end?
Do you think we should have an example for coherent noise too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The depolarizing noise example is to show how Pauli twirling is equivalent to tailoring the noise into a depolarizing noise channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite see how this relates to pauli twirling. Can you help spell it out?
From my perspective the main idea in pauli twirling is to add gates that compile to the identity, but change the impact of noise. So when you say the depolarizing channel can be written in terms of paulis, I don't see how that is pauli twirling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my perspective the main idea in pauli twirling is to add gates that compile to the identity,
Uh, no. Pauli twirling's goal is to transform some noise channel into a local depolarizing noise channel. The circuits average over to a mixed noise channel which is what I was trying to show in my example.
docs/source/examples/pt_zne.md
Outdated
print("Example noisy twirled circuit", noisy_twirled_circuits[-1], sep="\n") | ||
``` | ||
|
||
The twirled PTM is averaged over each noisy twirled circuit such that the new PTM is close to that of the PTM of incoherent noise. We skip the step in this section as we require a very large number of twirled circuits to demonstrate the desired effect of averaging over multiple numpy arrays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit anti-climatic, I was looking forward to seeing the effect of this on those PTM heatmaps :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, well, this increases the notebook execution time by a lot. The coherent noise that I used is obviously not included in the noisy options allowed by generate_pauli_twirl_variants
. We should create an issue to clean this portion of pauli twirling.
So, if I want to generate 100 pauli twirled circuits, I have to splice each of the circuits to make sure the noise is inserted in the correct spot and the pauli twirling gates are also inserted accordingly. Then, the next step is to get their PTM's and sum them up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we included an image of the twirled PTM heatmap saying "this is what would happen if you generated the twirled PTM"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added 3 4 examples. See 2fbf94f.
I also changed the color palette to make the heatmap easy to read.
Ideally, I would prefer this to be a gif (something like this) to show how the heatmap changes as the number of pauli twirled circuits is increased. We could keep this as a unitary hackathon issue if there are not a lot of non-quantum issues. WDYT?
I manually created a gif in 818a864 Hopefully, this fixes Alessandro's comment.
I was looking forward to seeing the effect of this on those PTM heatmaps
|
||
We are going to add coherent noise to this circuit and then get the error-mitigated expectation value. For a detailed discussion on this, refer to the [ZNE user guide](../guide/zne-1-intro.md). | ||
|
||
As we are using a simulator, we have to make sure the noise model adds coherent noise to CZ/CNOT gates in our circuit. For this, `get_noise_model` is used to add noise to CZ/CNOT gates. See [PT user guide](../guide/pt-1-intro.md) for more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solid function that get_noise_model
📦 😃
Co-authored-by: nate stemen <[email protected]>
4ea318f
to
c890f2b
Compare
@natestemen @cosenal This is ready. Whenever you guys are free... Good luck with FOSDEM! |
docs/source/examples/pt_zne.md
Outdated
print("Example noisy twirled circuit", noisy_twirled_circuits[-1], sep="\n") | ||
``` | ||
|
||
The twirled PTM is averaged over each noisy twirled circuit such that the new PTM is close to that of the PTM of incoherent noise. We skip the step in this section as we require a very large number of twirled circuits to demonstrate the desired effect of averaging over multiple numpy arrays. The variations in pauli twirled PTMs are shown below when averaged over a different number of pauli twirled circuits: [3](../img/pt_zne_3_circuits.png), [5](../img/pt_zne_5_circuits.png), [30](../img/pt_zne_30_circuits.png) and [300](../img/pt_zne_100_circuits.png). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Fixes #2374
License
Before opening the PR, please ensure you have completed the following where appropriate.