-
Notifications
You must be signed in to change notification settings - Fork 65
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
Sequence sampler #345
Sequence sampler #345
Conversation
plain dataframe of samples extract samples in the nested dict form A note: basis that are unused by declared channels are arrays full of zeros, while it is simply not initilized in the dict in the simulation module. add test to compare with extraction from simulation module Add various docstrings type annotations sample per qubit, test passes add support for LocalNoises add seed to the amplitude_noise generator fix the doppler noise to use a normal distribution Write test for doppler noise. It fails. It fails probably because of the different seeds in the random generators ? refactor a bit Rename as module sampler Refactor by distinguishing the local and global extraction Remove unused import Refactor the noises to their own modules Add modulation, but no implementation Revert "Refactor the noises to their own modules" This reverts commit 37093330c57a9152604f239e79ec6940a213b432. Use strategies for _TimeSlot extraction Remove functions made useless by refactor to strategy pattern Add doctrings and make some functions private Extend test to local channels Remove dead code Add modulation Refactor a bit: docstrings, order of functions, etc. Fix _TimeSlot grouping by handling delays correctly Tidy the comments refactor the extraction strategies Docstring
Deprecate temporarily the amplitude_noise as it misses the point It urges for a correct implementation Refactor sample writing Allow local decay with on SLM Add support for noises on global channel Add TODO for global modulation Fix usage of noises.apply() Fix modulation and apply SLM on local channels as well Fix imports
Also fix imports for mypy compliance
One first comment from just looking at the file structure: it's important that we keep simulation-specific features contained in the |
Adds a post_init check for same length of quantities arrays Add documentation, testing and refactoring Refactor the dict construction with modulation Simple comment to clarify the design of sampler.sample() Remove unnecessary value in enum _GroupType Add a diagram for _TimeSlot grouping Fix embedded NoiseModel by using copies Update docstrings with args Expose the sample() function from the __init__ Test the amplitude noise Remove unused commented import Add usage note on doppler noise Add a docstring for the amplitude noise Remove empty line Create a better test for doppler noise Small refactor Mark the doppler test as expected to fail Refactor the control flow of sampler.sample() Refactor the dict exporting Refactor Fix typo Add a docstring Refactor the TimeSlot grouping and strategy
Global and local channels are sampled identically. The export to a dict form like the simulation one handles the distinctions. It introduces an additional dict keeping track of the addressing of each channel: Global, Decayed, Local. Trim dead code, refactor, defensive coding Write global channel from QubitSamples Rename modulation function
Table based tests Add a modulation test I don't like it. It is testing the sampling for sure, but still I would like to test against a known output of the modulation. Remove unnecessary if branch functools.reduce got us covered already Extend to digital Fix mypy error because of weird scope of variables Test sequence in XY and fix a typo in the relevant code Test for corner cases and omit defensive coding with pragma no cover
The latest commits make the sampler a working feature.
A comment on the design choice: for now I think a function is enough. sampler.sample(seq)
# just like
json.dumps(obj) Though, I am not satisfied with the way noises are specified. It will be reworked with along with the other features I want to add. So it may evolve towards a more complex implementation. |
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.
Here is a non-exhaustive review of what you've done so far (I'm still missing most of the tests).
I would say that overall, there is a tendency to abuse helper functions in a way that makes the code harder to read sometimes. I left a couple comments on that, but I feel that overall the code could use a going over with that in mind.
Other than that, it seems to be in a good shape already!
[Note: Actually, GitHub seems to be crashing so I'll leave these comments for now and follow up with the ones I've lost]
Sequence._slm_mask_time is not a list of times, but a pair with a start and end time of the SLM masking.
For global channels, we hold the same data in N copies, N the number of qubits of the register. It scales poorly with the size of the register, but it remains manageable for current size of registers. If needed, we should patch this, at the expense of a more complex control flow in the sample() function at least.
Apart from the doppler noise effect discussion—which fails on purpose now—it looks nice to me. |
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.
Looks good to me too! Let's go with the current implementation of Doppler noise, it doesn't make sense to delay this PR because of it.
🎉 |
Main changes: - 3921795 Remove string variables (#365) - b23ff22 Splitting `pulser` into `pulser-core` and `pulser-simulation`. (#362) - 4f684f3 Address qubits with indices (#356) - f2ee5e2 Make evaluation times uniform including final time (#330) - c34dffb Changes for compatibility with upcoming export format (#353) - 3ac1f66 Sequence sampler (#345)
Main changes: - 3921795 Remove string variables (#365) - b23ff22 Splitting `pulser` into `pulser-core` and `pulser-simulation`. (#362) - 4f684f3 Address qubits with indices (#356) - f2ee5e2 Make evaluation times uniform including final time (#330) - c34dffb Changes for compatibility with upcoming export format (#353) - 3ac1f66 Sequence sampler (#345)
Close #342.
A working but unfinished Sequence sampler. The tests fail on purpose: I am still thinking about the best way to test this. Also, not all noise sources have been considered.
A new module called
sampler
exposes thesampler.sample()
function, which is given a sequence in argument and returns a nested dict of Global and Local samples per basis. The construction of this dict mimics the one in thesimulation
module.Arguments given to
sampler.sample()
allow for modulation and noise models relevant at the sampling level.Some comment on the internals:
Samples
andQubitSamples
are two data class to holds and pass the samples around before pasting them to the dictNoiseModel
alias ; we expose generators from thesampler.noises
module to construct the desired noise function