-
Notifications
You must be signed in to change notification settings - Fork 60
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
Fix pulse to signal converter #164
Fix pulse to signal converter #164
Conversation
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 for these very important fixes.
I've added a couple of comments in the code, but aside from this, I think we need more tests to make sure that the behaviour you're putting in is actually being implemented. The test you've added is a good test, but it doesn't test the interaction between delays and SetFrequency
/ShiftFrequency
instructions. Can you add another test like test_delay
, but where you do ShiftFrequency
before and after the delay, to test the correct signal is being generated as in the Ramsi experiment? I'd also like to see tests with multiple ShiftFrequency
and SetFrequency
instructions.
I also think we should update the doc string for InstructionToSignals
to be very clear about what rules it is using to generate samples. You could either do this here, or it can be done in a subsequent PR.
releasenotes/notes/fix_delay_and_phase_accumulation-25c8b4c501110c50.yaml
Outdated
Show resolved
Hide resolved
phase_accumulations[chan] -= ( | ||
(inst.frequency - (frequency_shifts[chan] + signals[chan].carrier_freq)) | ||
* start_sample | ||
* self._dt | ||
) |
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.
Can you change this to:
phase_accumulations[chan] -= ( | |
(inst.frequency - (frequency_shifts[chan] + signals[chan].carrier_freq)) | |
* start_sample | |
* self._dt | |
) | |
phase_accumulations[chan] += ( | |
((frequency_shifts[chan] + signals[chan].carrier_freq) - inst.frequency) | |
* start_sample | |
* self._dt | |
) |
I just find the negative slightly confusing in this case.
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 adapt this to phase_accumulations[chan] -= inst.frequency * start_sample * self._dt
.
Do I also need to change the sign to plus ?
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.
No that's okay - you can actually leave both as is - it was only a slight preference on my part, but doesn't really matter.
88ac45e
to
816a39d
Compare
Thank you for reviewing. |
duration = 20 | ||
dt = 0.222 |
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 defined variables often used here. We can find other frequently used number in other tests. So We can define these variables often used at setUp method. I may refactor after merging this PR.
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.
Nice changes to the tests - I think this pretty much covers everything.
I found the tests somewhat confusing to verify; the parentheses were a bit confusing and how the phase accumulation was calculated was not explicit. I've just opened a PR to your branch that changes the tests to how I'd like them to look.
If you can take a look at that and merge it if it looks fine, then the only things left to do are:
- It seems you need to sign the CLA still.
- Make sure this PR passes the linter.
65ab244
to
4440c98
Compare
Thank you for improving my codes. I fixed the author committing to this PR because I used the wrong one. |
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 just made some final documentation changes, and it looks good to me! Will merge once tests pass.
Co-authored-by: Daniel Puzzuoli <dan.puzzuoli@gmail.com>
Co-authored-by: Daniel Puzzuoli <dan.puzzuoli@gmail.com>
Summary
This PR fixes the behavior of InstructionToSignals.get_signals.
Related with #140
Details and comments
Fix the behavior of get_signals when using Delay in qiskit-pulse.
Add a phase accumulation term when using shift or set frequency in qiskit-pulse.