Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Serializable parametric pulse #7821
Serializable parametric pulse #7821
Changes from 3 commits
afe4f96
9a8a582
6f2496a
0424636
1bf11fa
2335f32
2af235d
0cc7383
a59af77
21ef762
509470a
ed2f661
c4b41d5
71ef841
cf7f302
c2981d0
cf17341
ba685ef
f2ef950
2ea6390
f48796e
0738497
92f42eb
1440a23
4345c3b
1c63ddb
d121b0d
48ff3cc
b9cab67
42b3dd9
761235d
cc12bf8
6c21edd
43e0e0b
6b956de
eefa5e4
252f62b
f24e648
4d191be
2c8e7f8
3a0f506
d5517d5
be2ed0c
67ac61f
78288ac
cbada64
ecb4ea7
45ae755
a4a56db
d957458
6776743
d4e8c43
41bf4f5
2aa4f5a
2e521a7
09855d7
b99eb5c
ac23d6f
401c1f4
686e77b
84344c2
914018e
045d67b
3b2c571
8edaba9
9b0adc3
cda7336
ef35cd9
15e9f7c
d844253
526aaed
87d3538
be2b4e0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 liked storing the params as tuples. It's probably premature optimization though (and maybe bad if
.parameters
gets used a lot). I wish Python had a compact frozen dict type.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.
Unfortunately this is called multiple times. Seems like we have frozendict in python. https://pypi.org/project/frozendict/ What do you think of adding this? @mtreinish
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.
If you want truly an immutable type that's really tricky to do in python. You can create one like frozendict pretty easily without that library just something that implements
__getitem__()
and the other read only mapping protocol functions will work. Basically just subclasscollections.abc.Mapping
. You could also do it via rust via aHashMap
orIndexMap
rust struct if you wanted something with statically typed keys which performed better. But that only limits it to top level immutability (basically only blocking inserts and value replacements) you'll always still be able to modify a value inplace. For example, using frozendict you could do something like:Would print:
frozendict.frozendict({'a': [2]})
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.
Should we cast
amp
to complex here if it is in theparameters
and not aParameterExpression
? Right now this is only done in all the subclasses.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.
Yes, but treating
amp
as special parameter is a convention in IBM backend and this code is backend-agnostic. So one might want treatamp
as a real value in phasor representation (I really prefer this).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.
Hmm, I agree with the spirit of not treating amp, but we are still treating it specially in all the subclasses and in the parameter assignment. I think it would be more consistent just to cast it to complex here for now.
I'd like to look at what it would take to get the backend to accept float or complex for all the parameters so terra does not have to special case parameters, but that would be follow up work.
I also prefer the phasor representation. I think one can use
a * exp(1j * phi)
for theamp
paremeter wherea
andphi
are paraemters to get this?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.
Fair enough. This is forcibly typecasted in parameter assignment anyways. Done in ef35cd9. It would be great if we can remove this check since current implementation means we cannot write pulses with phase representation.
Yes, this is a technique I often use, i.e.
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.
Does this midpoint sampling work the way one would expect with gaussian pulse shapes being lifted to 0? The zeroes are at -1 and
duration + 1
. I think the backend has the zeroes at -1 andduration
for samplesrange(duration)
, so the zeroes are half a sample further away for these pulses than for the backend.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.
Good point. So far I have never heard critical failure in pulse simulator. As long as we have enough duration/sigma this doesn't become serious problem. I think
t_zero
value is insensitive to sampling strategy (because it is computed before sampling), thus offset value should be the same. We are sampling the same waveform at slightly different point.I agree there is undiscoverable difference in frontend and backend as discussed in this #7659 (comment). I sometime see the difference of calibrated parameters in parametric pulse v.s. waveform. I think
SymbolicPulse
will improve this situation. In principle backend compiler doesn't need to have own pulse factory. It just need to convert the symbolic pulse into waveform and reuse compiler pass for the waveform (smart controller could do runtime waveform generation in microarchitecture, then it doesn't have waveform memory to save it). In this sense, I feel we don't need to conform to the backend.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.
Does the sampling behavior here match exactly what the old parametric pulse classes would produce? If so, it is fine to leave this. If it is already a minor change in behavior, why not try to match what the IBM backend does exactly?
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.
This conforms to the behavior of parametric pulse classes. We can update this with extra work for unittest (in unittest reference data is generated with midpoint sampler).