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

Hotfix for rabi period estimate #677

Merged
merged 2 commits into from
Dec 21, 2023
Merged

Hotfix for rabi period estimate #677

merged 2 commits into from
Dec 21, 2023

Conversation

andrea-pasquale
Copy link
Contributor

@andrea-pasquale andrea-pasquale commented Dec 20, 2023

Closes #656.
I think there was a problem with some simplification in the correction formula for the rabi period estimate.

Checklist:

  • Reviewers confirm new code works as expected.
  • Tests are passing.
  • Coverage does not decrease.
  • Documentation is updated.
  • Compatibility with Qibo modules (Please edit this section if the current pull request is not compatible with the following branches).
    • Qibo: master
    • Qibolab: main
    • Qibolab_platforms_qrc: main

@andrea-pasquale andrea-pasquale added the bug Something isn't working label Dec 20, 2023
@andrea-pasquale andrea-pasquale added this to the Qibocal 0.0.7 milestone Dec 20, 2023
@andrea-pasquale andrea-pasquale self-assigned this Dec 20, 2023
Copy link

codecov bot commented Dec 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5f10133) 96.02% compared to head (2e48250) 96.02%.
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #677   +/-   ##
=======================================
  Coverage   96.02%   96.02%           
=======================================
  Files         106      106           
  Lines        7354     7355    +1     
=======================================
+ Hits         7062     7063    +1     
  Misses        292      292           
Flag Coverage Δ
unittests 96.02% <100.00%> (+<0.01%) ⬆️

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

Files Coverage Δ
...c/qibocal/protocols/characterization/rabi/utils.py 100.00% <100.00%> (ø)

@alecandido
Copy link
Member

My bad, the two functions are actually equal only in a certain range, and I see why you want the current one
round-vs-modf

I should have tested better...

Another option, that is exactly what you're doing, would be:

1.5 - ((x + 0.5) % 1)

round-vs-modf-vs-mod

But it is really a matter of taste...

@andrea-pasquale
Copy link
Contributor Author

Thanks for checking @alecandido.
Indeed I saw the same with behavior with np.modf. For the time being let's keep np.round.

@alecandido
Copy link
Member

alecandido commented Dec 21, 2023

Btw, is there a reason why you fixed the codomain between 0.5 and 1.5?

@andrea-pasquale
Copy link
Contributor Author

Btw, is there a reason why you fixed the codomain between 0.5 and 1.5?

Which codomain?

@alecandido
Copy link
Member

alecandido commented Dec 21, 2023

Which codomain?

The y-axis in the plot (the codomain of the function you're modifying in this PR).

Essentially, the amplitude is fixed to be 1 by np.round() (and all its friends), and you're deciding to center the range at 0, and to make f(0) = 1.

@andrea-pasquale
Copy link
Contributor Author

Which codomain?

The y-axis in the plot (the codomain of the function you're modifying in this PR).

Essentially, the amplitude is fixed to be 1 by np.round() (and all its friends), and you're deciding to center the range at 0, and to make f(0) = 1.

I see. Maybe it is better to go a step behind. The (half-)period corrected taking into account the phase should be the following:

$$ \frac{T^*}{2} = \underbracket{\Big( k - \frac{\phi}{\pi}\Big) }_{\xi} \frac{T}{2} $$

and since I now that this correction will be small I want to find $k \in \mathbb{Z}$ which minimizes this correction. Which means that I need to find $k$ s.t. $k - \frac{\phi}{\pi} \approx 1$. Therefore $k = \text{int}( 1 + \phi / \pi)$ and the total correction will be $\xi = \text{int}( 1 + \phi / \pi) - \phi/\pi$. The problem as far as I understood is how to treat this conversion to int.

Given that we want $k$ to be as close as possible to the float this is why I think that it is better to use np.round instead of np.modf. Here are more plots.
image
image

@alecandido
Copy link
Member

Yes, I keep forgetting it is a multiplicative correction, that's why you want the value to be around 1.

@andrea-pasquale andrea-pasquale added this pull request to the merge queue Dec 21, 2023
Merged via the queue into main with commit d145c8f Dec 21, 2023
21 checks passed
@andrea-pasquale andrea-pasquale deleted the fix_rabi_again branch December 21, 2023 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inaccurate fitted amplitude in rabi_amplitude_msr
3 participants