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

Adding CPMG protocol #1057

Open
wants to merge 4 commits into
base: 0.2
Choose a base branch
from
Open

Adding CPMG protocol #1057

wants to merge 4 commits into from

Conversation

andrea-pasquale
Copy link
Contributor

Closes #896.
Here is an example: http://login.qrccluster.com:9000/M0By3hjUTAakgT8Jg1VlXA==
I've also fixed a factor 2 in the spin_echo protocol.

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.02%. Comparing base (d7745ae) to head (1a8f9f7).
Report is 82 commits behind head on 0.2.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              0.2    #1057      +/-   ##
==========================================
- Coverage   97.03%   97.02%   -0.02%     
==========================================
  Files          98       99       +1     
  Lines        7895     7921      +26     
==========================================
+ Hits         7661     7685      +24     
- Misses        234      236       +2     
Flag Coverage Δ
unittests 97.02% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/qibocal/protocols/__init__.py 100.00% <100.00%> (ø)
src/qibocal/protocols/coherence/cpmg.py 100.00% <100.00%> (ø)
src/qibocal/protocols/coherence/spin_echo.py 100.00% <100.00%> (ø)
...rc/qibocal/protocols/coherence/spin_echo_signal.py 100.00% <100.00%> (ø)
src/qibocal/protocols/coherence/t1.py 100.00% <ø> (ø)
src/qibocal/protocols/coherence/t2.py 100.00% <100.00%> (ø)
src/qibocal/protocols/coherence/utils.py 98.11% <100.00%> (+0.77%) ⬆️
src/qibocal/protocols/coherence/zeno.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

In this section we show how to run the dynamical decoupling sequence CPMG.

The CPMG sequence consists in applying N equally spaced :math:`\pi` pulses
within two :math:`\pi` pulses. By increasing the number of :math:`\pi` pulses :math:`T_2`
Copy link
Contributor

Choose a reason for hiding this comment

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

within two :math:`\pi` pulses. 

It should be pi/2, right ?

return figures, fitting_report


cpmg = Routine(_acquisition, _fit, _plot, _update)
Copy link
Contributor

Choose a reason for hiding this comment

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

The _update is the spin_echo one, it means the t2_spin_echo value is updated. This is the case when N = 1, but generally speaking the the $T2^{(N)}$ is sensitive to different frequencies noise, so we should differentiate the cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was thinking about this. Perhaps at this point it is easier to just remove the update for this protocol. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we delete this routine to reduce code duplication ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, the spin-echo protocol doesn't implement the CPMG sequence but the CP sequence, which is slightly different.

sequence, delays = dynamical_decoupling_sequence(platform, targets, kind="CP")

Screenshot 2024-12-12 at 14 24 01

But yes, generally I agree the two protocols are exactly the same apart from the sequence type.

Comment on lines +59 to +74
sequence.append((qd_channel, rx90_pulse))

for i in range(n):
sequence.append((qd_channel, drive_delays[2 * i]))
sequence.append((ro_channel, ro_delays[2 * i]))
sequence.append((qd_channel, pulse))
sequence.append((qd_channel, drive_delays[2 * i + 1]))
sequence.append((ro_channel, ro_delays[2 * i + 1]))

sequence.append((qd_channel, rx90_pulse))

sequence.append(
(
ro_channel,
Delay(duration=2 * rx90_pulse.duration + n * pulse.duration),
)
Copy link
Contributor

@Edoardo-Pedicillo Edoardo-Pedicillo Dec 12, 2024

Choose a reason for hiding this comment

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

The sequence should be the following
2024-12-12_16:04:10

I don't see the t/2N delays after/before the first/last pulse.

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 sequence can be re-written as
RX90 - (wait(t/2N) RY wait(t/2N))^N RX90
which is exactly what I am doing in the for loop.

I've specified that the delay should have also a factor 1/2N in the acquisition

values=wait_range / 2 / params.n,

Copy link
Contributor

Choose a reason for hiding this comment

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

Smart !


The CPMG sequence consists in applying N equally spaced :math:`\pi` pulses
within two :math:`\pi` pulses. By increasing the number of :math:`\pi` pulses :math:`T_2`
should increase until reaching the :math:`2 T_1` limit.
Copy link
Contributor

Choose a reason for hiding this comment

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

This behaviour depends on the kind of noise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure about this. Generally by increasing the number of pi pulses according to here I believe that we should be able to mitigate noises of the type 1/f. Then I don't know whether we could have other noises which are not 1/f but I don't know if we can detect them through a CPMG sequence.
Did you have something else in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you have something else in mind?

You could have a white noise but I think the conclusions are the same. I just suggest to add what you have written in this comment in the docs.

Then I don't know whether we could have other noises which are not 1/f but I don't know if we can detect them through a CPMG sequence.

By changing the number of pulses increase the sensitivity to higher frequencies, so I would say yes

Copy link
Contributor Author

@andrea-pasquale andrea-pasquale left a comment

Choose a reason for hiding this comment

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

Thanks for the comments @Edoardo-Pedicillo.
I will try to reduce code duplication :)

return figures, fitting_report


cpmg = Routine(_acquisition, _fit, _plot, _update)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was thinking about this. Perhaps at this point it is easier to just remove the update for this protocol. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, the spin-echo protocol doesn't implement the CPMG sequence but the CP sequence, which is slightly different.

sequence, delays = dynamical_decoupling_sequence(platform, targets, kind="CP")

Screenshot 2024-12-12 at 14 24 01

But yes, generally I agree the two protocols are exactly the same apart from the sequence type.

Comment on lines +59 to +74
sequence.append((qd_channel, rx90_pulse))

for i in range(n):
sequence.append((qd_channel, drive_delays[2 * i]))
sequence.append((ro_channel, ro_delays[2 * i]))
sequence.append((qd_channel, pulse))
sequence.append((qd_channel, drive_delays[2 * i + 1]))
sequence.append((ro_channel, ro_delays[2 * i + 1]))

sequence.append((qd_channel, rx90_pulse))

sequence.append(
(
ro_channel,
Delay(duration=2 * rx90_pulse.duration + n * pulse.duration),
)
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 sequence can be re-written as
RX90 - (wait(t/2N) RY wait(t/2N))^N RX90
which is exactly what I am doing in the for loop.

I've specified that the delay should have also a factor 1/2N in the acquisition

values=wait_range / 2 / params.n,


The CPMG sequence consists in applying N equally spaced :math:`\pi` pulses
within two :math:`\pi` pulses. By increasing the number of :math:`\pi` pulses :math:`T_2`
should increase until reaching the :math:`2 T_1` limit.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure about this. Generally by increasing the number of pi pulses according to here I believe that we should be able to mitigate noises of the type 1/f. Then I don't know whether we could have other noises which are not 1/f but I don't know if we can detect them through a CPMG sequence.
Did you have something else in mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants