-
Notifications
You must be signed in to change notification settings - Fork 15
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
Migrate Pulse to dataclass #709
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #709 +/- ##
==========================================
- Coverage 63.58% 62.94% -0.65%
==========================================
Files 49 49
Lines 6539 6399 -140
==========================================
- Hits 4158 4028 -130
+ Misses 2381 2371 -10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
1c62187
to
fcff1cc
Compare
@stavros11 @andrea-pasquale at this point I would actually also like to drop ❯ rg '\._if'
tests/test_pulses.py
694: 2 * np.pi * pulse._if * pulse.start / 1e9
697: i, q, num_samples, pulse._if, global_phase + pulse.relative_phase, sampling_rate
719: == f"Modulated_Waveform_I(num_samples = {num_samples}, amplitude = {format(pulse.amplitude, '.6f').rstrip('0').rstrip('.')}, shape = {str(pulse.shape)}, frequency = {format(pulse._if, '_')}, phase = {format(global_phase + pulse.relative_phase, '.6f').rstrip('0').rstrip('.')})"
723: == f"Modulated_Waveform_Q(num_samples = {num_samples}, amplitude = {format(pulse.amplitude, '.6f').rstrip('0').rstrip('.')}, shape = {str(pulse.shape)}, frequency = {format(pulse._if, '_')}, phase = {format(global_phase + pulse.relative_phase, '.6f').rstrip('0').rstrip('.')})"
764: i, q, num_samples, pulse._if, global_phase + pulse.relative_phase, sampling_rate
786: == f"Modulated_Waveform_I(num_samples = {num_samples}, amplitude = {format(pulse.amplitude, '.6f').rstrip('0').rstrip('.')}, shape = {str(pulse.shape)}, frequency = {format(pulse._if, '_')}, phase = {format(global_phase + pulse.relative_phase, '.6f').rstrip('0').rstrip('.')})"
790: == f"Modulated_Waveform_Q(num_samples = {num_samples}, amplitude = {format(pulse.amplitude, '.6f').rstrip('0').rstrip('.')}, shape = {str(pulse.shape)}, frequency = {format(pulse._if, '_')}, phase = {format(global_phase + pulse.relative_phase, '.6f').rstrip('0').rstrip('.')})"
834: 2 * np.pi * pulse._if * pulse.start / 1e9
837: i, q, num_samples, pulse._if, global_phase + pulse.relative_phase, sampling_rate
859: == f"Modulated_Waveform_I(num_samples = {num_samples}, amplitude = {format(pulse.amplitude, '.6f').rstrip('0').rstrip('.')}, shape = {str(pulse.shape)}, frequency = {format(pulse._if, '_')}, phase = {format(global_phase + pulse.relative_phase, '.6f').rstrip('0').rstrip('.')})"
863: == f"Modulated_Waveform_Q(num_samples = {num_samples}, amplitude = {format(pulse.amplitude, '.6f').rstrip('0').rstrip('.')}, shape = {str(pulse.shape)}, frequency = {format(pulse._if, '_')}, phase = {format(global_phase + pulse.relative_phase, '.6f').rstrip('0').rstrip('.')})"
src/qibolab/instruments/qblox/controller.py
183: pulse._if = int(pulse.frequency - pulse_channel.lo_frequency)
src/qibolab/pulses.py
168: if abs(pulse._if) * 2 > sampling_rate:
176: 2 * np.pi * pulse._if * time + global_phase + pulse.relative_phase
179: 2 * np.pi * pulse._if * time + global_phase + pulse.relative_phase
200: modulated_waveform_i.serial = f"Modulated_Waveform_I(num_samples = {num_samples}, amplitude = {format(pulse.amplitude, '.6f').rstrip('0').rstrip('.')}, shape = {str(pulse.shape)}, frequency = {format(pulse._if, '_')}, phase = {format(global_phase + pulse.relative_phase, '.6f').rstrip('0').rstrip('.')})"
202: modulated_waveform_q.serial = f"Modulated_Waveform_Q(num_samples = {num_samples}, amplitude = {format(pulse.amplitude, '.6f').rstrip('0').rstrip('.')}, shape = {str(pulse.shape)}, frequency = {format(pulse._if, '_')}, phase = {format(global_phase + pulse.relative_phase, '.6f').rstrip('0').rstrip('.')})" @PiergiorgioButtarini is it possible to store this information anywhere else in Qblox? |
5f1e7ca
to
5b142f0
Compare
If it possible I would also drop it at this point. I believe that in theory the |
This I'm trying to understand myself. But, as you can see from the quoted line, Qblox is actually setting this information from the LO at some point, a point when the pulse is accessible (thus during an invocation of some kind of |
5b142f0
to
1c62187
Compare
1c62187
to
9370b05
Compare
Tested on Qblox, working ✅ Pytest report
|
Tested on Zurich, broken ❌ Pytest report
But it's not my fault, it's broken exactly in the same way on |
Unfortunately, qiboteam/qibolab_platforms_qrc#88 is outdated, so I don't have a runcard to test |
Btw, I obviously can't test on QM, unless someone can point me out a suitable platform to do it... With this, I'm ready for the review :) |
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.
Thanks @alecandido. In terms of hardware deployment, I also played with this branch a bit and it seems to work so it should be safe to merge. Regarding the Zurich tests, I wouldn't worry on this PR, but we should certainly fix them in a different one.
For QM, I would also say it's not worth spending time testing now as I will be doing some major updates in the driver soon to support the Octaves. Also the qua version in our pyproject is very old - they finally put back support for py311 so I will update it when I do the driver. If you really want to try I can provide a runcard (dummy since it is not connected to anything, but still using the real instrument), but not really required.
Other than that, I understand that this PR is only a first step and there are several TODOs remaining so it should be fine to even merge as it is. One thing that could still be addressed here is the Pulse
subclasses (ReadoutPulse
, DrivePulse
, etc.), I think you did not touch them, but in principle they could also be dataclasses. Unless you have a different plan for them, such as dropping them at some point (since they're kind of duplicating the pulse.type
attribute).
Two other things that we should do in a different PR (to avoid large changes) but in principle we could do immediately after are:
- Create a pulse module (directory) and seperate pulse, shape and sequence to different files,
- Move plot methods outside the objects (potentially in another file under the pulse module).
These are trivial since it is just copy-pasting existing code but I think it would simplify the review of later changes on these files. Maybe (1) won't be as useful if we manage to simplify pulses a lot, but I think some structure would still help.
It is certainly possible to do this and drop |
Indeed, the plan is actually to drop. I forgot to spell it out explicitly in #683, where I only detailed the very few additions to main
Agreed. I'm trimming the file, but even trimmed it will keep doing quite a bunch of things, so it is useful to split as well.
Indeed. I was thinking about a |
About hw deployment I wanted to be sure that I was not breaking currently working and used drivers.
Indeed, I already opened |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
As they already were
6357d01
to
e6168d4
Compare
First batch of #683.
Since these updates are going to affect many places, the idea is to attempt bundling changes in a few units, and make sure everything is still working every time (also to avoid a single huge PR).
Checklist: