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

Turn Waveform into a bare array #774

Merged
merged 4 commits into from
Jan 22, 2024
Merged

Turn Waveform into a bare array #774

merged 4 commits into from
Jan 22, 2024

Conversation

alecandido
Copy link
Member

Now Waveform is only useful as a type hint.

There is only one caveat: Waveform was hashable, np.ndarray is not (because mutable). The gap was filled by calling array.tobytes() (since the generated bytes are immutable, as a snapshot of an array at a specific time).
It's not optimal, since it's still a hash of an actually mutable object, but we just have to be consistent.

However, I'm still using the trick explicitly in QM.
Are you aware of any other place where the Waveform had to be hashable?

@alecandido alecandido requested a review from stavros11 January 19, 2024 18:38
Copy link

codecov bot commented Jan 19, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (a5b7248) 61.94% compared to head (ba476ee) 61.68%.

Files Patch % Lines
src/qibolab/pulses/shape.py 82.60% 4 Missing ⚠️
src/qibolab/instruments/qblox/sequencer.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##           simplify-pulse-7     #774      +/-   ##
====================================================
- Coverage             61.94%   61.68%   -0.26%     
====================================================
  Files                    52       51       -1     
  Lines                  5723     5690      -33     
====================================================
- Hits                   3545     3510      -35     
- Misses                 2178     2180       +2     
Flag Coverage Δ
unittests 61.68% <82.05%> (-0.26%) ⬇️

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

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

@alecandido alecandido linked an issue Jan 19, 2024 that may be closed by this pull request
19 tasks
Copy link
Member

@stavros11 stavros11 left a comment

Choose a reason for hiding this comment

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

I did not test (further than CI), but looks good to me. I think we can postpone hardware testing to 0.2 branch after all these are merged because now it's already pointing to other branches.

However, I'm still using the trick explicitly in QM. Are you aware of any other place where the Waveform had to be hashable?

Personally, I am not aware. For QM, we need to associate a name (str) to each waveform in order to register it in the config and assign it to pulses. In principle str(id(waveform)) would even work, but hash is better because it is the same for equal waveforms, so we don't need to register the same waveform multiple times (eg. during unrolling), while id is different for every instance (if I am correct). But I believe your current solution is okay (alternatives https://stackoverflow.com/questions/16589791/most-efficient-property-to-hash-for-numpy-array)

Base automatically changed from simplify-pulse-7 to 0.2 January 22, 2024 17:01
@alecandido alecandido merged commit d8c723c into 0.2 Jan 22, 2024
21 checks passed
@stavros11 stavros11 deleted the simplify-pulse-8 branch January 22, 2024 18:53
@stavros11 stavros11 mentioned this pull request Jan 22, 2024
5 tasks
@alecandido alecandido added this to the Qibolab 0.2.0 milestone Jan 25, 2024
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.

Pulse simplification
2 participants