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

Adding dmm config and modulation to sequence #564

Merged
merged 36 commits into from
Sep 22, 2023
Merged

Conversation

a-corni
Copy link
Collaborator

@a-corni a-corni commented Jul 25, 2023

In #565:

  • we introduced Traps to define RegisterLayout and WeightMap.
  • Write unit tests that don't depend on changes in Sequence.

In #576:

  • We added the possibility to define slug in define_detuning_map of Register, MappableRegister, RegisterLayout

Here:

  • Configure DMM using config_det_map (impossible to declare a DMM using declare_channel
  • Configure SLM using config_slm_mask:
    • if in xy: it works as before
    • if in ising: it configures a DMM and either modulates the DMM from the first pulse found on the first declared Global channel having one, or (if no such pulse has been defined) the DMM will be modulated from the first pulse added to a Global Channel.
    • If in neither of them, the dmm to use for SLM configuration is stored and behaves in xy/ising if next channel is in xy/ising.
    • Modification of find_slm_mask_times: it does not stop on a detuned_delay pulse.
  • add_dmm_detuning: Add the waveform of the detuning to a DMM. Same as using add to add a Pulse zero amplitude and negative detuning to a DMM. If the DMM is configured as an SLM Mask, this is only possible if a Pulse has been defined on a Global channel before.

In #576:

  • The dmm ids are switched when using 'switch_device' (useful when going from a virtual device to a real one). This is also performed for the dmm id used in config_slm_mask.
  • Parametrized sequences are now taken into account. The SLM Mask and config detuning map are seen as operations. They are stored to be performed at build. This has an impact on the way declared channels work since we now go into the to_build_calls to find the declared dmms.
  • Tests for compatibility between mappable register and detuning maps

In #568 and #576:

  • Update serializer and deserializer for devices with DMM channels
  • Write UTs for DMM channel serialization
  • Update serializer and deserializer for the sequence using detuning map modulation
  • Write UTs for sequence serialization and deserialization with detuning map modulation
  • Update to the final sequence JSON schema
  • Stores Config_det_map as an operation in the schema.

In #565, we develop a Special handling of samples from a DMM channel:

  • We add a DMMSamples subclass of ChannelSamples, that stores the DetuningMap and the qubits of the register.
  • Note: it is not possible to sample a Sequence with a Mappable Register and a configured DMM.

In #569:

  • Fixes on the drawing of Register, RegisterLayout, DetuningMap:
    • The minimal height is extended and a label is added, "atom" for Register and "trap" for the others.
    • Display the DetuningMaps as traps (like a RegisterLayout, because it is not enforced to have an atom at the coordinates at which there is a weight). Label 'traps' is added to plot (label "atoms" added for general registers).
    • labels in DetuningMaps could only take integers, now it can handle QubitId.
  • Addition to Sequence:
    • Add possibility to draw detuning maps (2D or 3D). Can be drawn with/without register.
    • Add possibility to draw local amplitude and detuning per group of qubits, that are represented on the register.
  • Tutorials:
    • Creates a tutorial explaining how to create a DetuningMap, a DMM channel, how to modulate a detuning map in a Schedule and how to display amplitude and detuning per qubits.
    • Modifies the tutorial on state preparation with the SLM Mask to show difference between XY and Ising mode.
    • Updates some notebooks to take into account changes on Register

tests/test_simulation.py Outdated Show resolved Hide resolved
tests/test_json.py Outdated Show resolved Hide resolved
a-corni and others added 2 commits July 28, 2023 12:52
* Add `DetuningMap.get_qubit_weight_map()`

* Define `_DMMSchedule.get_samples()`

* Extract DMMSamples from a Sequence

* Creating the `Traps` class

* Eliminating the effects of the SLM mask

* Use COORD_PRECISION in comparison

* `Traps.coords` -> `Traps.sorted_coords`

* Subclass `Traps` in `WeightMap`

* Preserve effects of SLM mask in XY mode

* Explicitly ask for labels in DetuningMap.draw()

* Including slug in WeightMap

* UTs for DetuningMap

* Isort

* Specialize pulse validation in DMM

* Revamp test_dmm UTs

* Formatting

* Add support for legacy serializer
Copy link
Collaborator

@HGSilveri HGSilveri left a comment

Choose a reason for hiding this comment

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

I still have to review the changes in Sequence by already have some comments

pulser-core/pulser/sampler/sampler.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/_schedule.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/_schedule.py Outdated Show resolved Hide resolved
tests/test_json.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
tests/test_sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
tests/test_sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@HGSilveri HGSilveri left a comment

Choose a reason for hiding this comment

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

Things are a bit confusing with this latest commit

pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/_schedule.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/_schedule.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
@HGSilveri
Copy link
Collaborator

  • Note 1: If in ising, I am wondering if I should not be simply using find_slm_mask_times/ an equivalent strategy.

I think this is a good idea. Instead of manually searching for the first pulse, we can call find_slm_mask_times, see if the list of times comes out empty or not and take the first non-empty list we get. Just remember that we forgot so far to filter out detuned delays in find_slm_mask_times(), so this should be changed.

@a-corni
Copy link
Collaborator Author

a-corni commented Aug 1, 2023

  • Note 1: If in ising, I am wondering if I should not be simply using find_slm_mask_times/ an equivalent strategy.

I think this is a good idea. Instead of manually searching for the first pulse, we can call find_slm_mask_times, see if the list of times comes out empty or not and take the first non-empty list we get. Just remember that we forgot so far to filter out detuned delays in find_slm_mask_times(), so this should be changed.

I think the latter should be addressed in another PR, I have tried to modify this and saw an unexpected error that did not seem so trivial (see Note 2).
image

@HGSilveri
Copy link
Collaborator

  • Note 1: If in ising, I am wondering if I should not be simply using find_slm_mask_times/ an equivalent strategy.

I think this is a good idea. Instead of manually searching for the first pulse, we can call find_slm_mask_times, see if the list of times comes out empty or not and take the first non-empty list we get. Just remember that we forgot so far to filter out detuned delays in find_slm_mask_times(), so this should be changed.

I think the latter should be addressed in another PR, I have tried to modify this and saw an unexpected error that did not seem so trivial (see Note 2). image

It's just a bad test because the first pulse is empty, so when you start ignoring it the qubits are no longer masked and you see the interaction terms appearing. If you put some amplitude on the rise pulse, this should go away

@a-corni
Copy link
Collaborator Author

a-corni commented Aug 2, 2023

  • Note 1: If in ising, I am wondering if I should not be simply using find_slm_mask_times/ an equivalent strategy.

I think this is a good idea. Instead of manually searching for the first pulse, we can call find_slm_mask_times, see if the list of times comes out empty or not and take the first non-empty list we get. Just remember that we forgot so far to filter out detuned delays in find_slm_mask_times(), so this should be changed.

I think the latter should be addressed in another PR, I have tried to modify this and saw an unexpected error that did not seem so trivial (see Note 2). image

It's just a bad test because the first pulse is empty, so when you start ignoring it the qubits are no longer masked and you see the interaction terms appearing. If you put some amplitude on the rise pulse, this should go away

So I have been adding an amplitude to the first pulse but the test is failing anyway, there are off-diagonal elements in the hamiltonian that depends on the amplitude of the pulse. I can't figure out where it is coming from (I have looked at the qobj_list in get_hamiltonian() but nothing easy came up)
image

@HGSilveri
Copy link
Collaborator

So I have been adding an amplitude to the first pulse but the test is failing anyway, there are off-diagonal elements in the hamiltonian that depends on the amplitude of the pulse. I can't figure out where it is coming from (I have looked at the qobj_list in get_hamiltonian() but nothing easy came up)

I can look into this, don't waste too much time on it

@HGSilveri
Copy link
Collaborator

So I have been adding an amplitude to the first pulse but the test is failing anyway, there are off-diagonal elements in the hamiltonian that depends on the amplitude of the pulse. I can't figure out where it is coming from (I have looked at the qobj_list in get_hamiltonian() but nothing easy came up)

The off-diagonal terms appear precisely because we changed the Rabi frequency of the first pulse. Makes sense, since now the only unmasked atom (atom3) does feel something at t=0.

@a-corni
Copy link
Collaborator Author

a-corni commented Aug 2, 2023

So I have been adding an amplitude to the first pulse but the test is failing anyway, there are off-diagonal elements in the hamiltonian that depends on the amplitude of the pulse. I can't figure out where it is coming from (I have looked at the qobj_list in get_hamiltonian() but nothing easy came up)

The off-diagonal terms appear precisely because we changed the Rabi frequency of the first pulse. Makes sense, since now the only unmasked atom (atom3) does feel something at t=0.

Ookay "atom3" is the only atom feeling something because "atom1" is masked, so "atom0", "atom2" and "atom3" can feel something but due to state preparation error "atom0" and "atom_2" are not present (hence don't feel anything), is that right ?

@HGSilveri
Copy link
Collaborator

Ookay "atom3" is the only atom feeling something because "atom1" is masked, so "atom0", "atom2" and "atom3" can feel something but due to state preparation error "atom0" and "atom_2" are not present (hence don't feel anything), is that right ?

Yup, that's it :)

pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/_schedule.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Show resolved Hide resolved
pulser-core/pulser/sequence/sequence.py Outdated Show resolved Hide resolved
a-corni and others added 4 commits August 2, 2023 17:01
* Support for DMM channel serialization

* WIP: Prepare for incoming updates to JSON schema

* Add descr sequence, _config_detuning_map

* Finishing UTs, fixing typos

* de-/serializing det maps, adding schema, slug

* Dev tests

* Fixing doc

---------

Co-authored-by: a_corni <[email protected]>
Copy link
Collaborator

@HGSilveri HGSilveri left a comment

Choose a reason for hiding this comment

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

Here's a review of the changes before the merge of #568, clearly nothing stands out

tests/test_simulation.py Outdated Show resolved Hide resolved
tests/test_simulation.py Outdated Show resolved Hide resolved
@HGSilveri HGSilveri added this to the v0.15 Release milestone Sep 14, 2023
a-corni and others added 11 commits September 14, 2023 18:26
… config_det_map as an operation (#576)

* Add slug description

* Handle DMM & parametrized/switch_device/MapReg

* Modifying schema, fixing type

* Moving to a store decoration

* Storing config_det_map

* Taking into account review comments

* Delete seq_tools

* Testing MappableRegister, strict conversion

* Replace modulate_det_map by add_dmm_detuning
* adding dmm, draw to DetuningMap

* Testing avoiding circular import

* Refactoring to avoid circular imports

* Fix broken UTs

* Import sorting

* Fixing plot DetuningMap

* Serialization/Deserialization of DMM in device

* Fixing typos

* Testing DMM and DetuningMap

* Fixing typo

* adding xfails, fixing type

* Remove DMM from devices and finish UTs

* Take into account review comments

* Add annotations

* Error in Global and Local

* Defining _DMMSchedule

* Fixing nits

* Fixing typo

* Creating DMM notebook, modif SLM notebook

* Taking into account review comments

* Fixing type

* Fix labels in reg_drawer, draw det_maps in seq

* Fixing doc build, add draw_detuning_maps to docs

* Separating register/det_maps drawing from channels

* introducing get_qubit_data

* Add drawing of quantities per qubit

* Fixing for local pulses

* Adding bounds to label

* Drawing legend for local targetting

* FIX sampling rate, QutipEmulator

* Updating figures

* Updating SLM Mask & local addressability notebook

* Adding explanation text

* Fixing type

* Replace modulate_det_map by add_dmm_detuning

* Replace modulate_det_map for add_dmm_detuning

* Fixing tests

* Revert changes to Bayesian optimization notebook

* Fixing docs

* clearing outputs

* Deleting scaling in favor extending to draw reg

* Placing legend in lower part of drawing

* Updating figures

* Relaunching bayesian optimisation

* Taking into account review comments

* Printing sequence with DMM

* Adding subscript and indent

* Defining __str__ for DMM

---------

Co-authored-by: HGSilveri <[email protected]>
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@a-corni a-corni marked this pull request as ready for review September 21, 2023 07:35
Copy link
Collaborator

@HGSilveri HGSilveri left a comment

Choose a reason for hiding this comment

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

🎉 🎉 🎉

@a-corni a-corni merged commit c08dfa8 into develop Sep 22, 2023
@HGSilveri HGSilveri mentioned this pull request Sep 27, 2023
HGSilveri added a commit that referenced this pull request Sep 27, 2023
Main changes:

e0943d9 Override `optimal_detuning_off` on stored calls (#588)
3e40319 Deprecate legacy serializer + Improve error messages (#585)
9e05982 Adding register_is_from_calibrated_layout and is_calibrated_layout to Device (#586)
c08dfa8 Adding dmm config and modulation to sequence (#564)
5270944 Clarify the Conventions in Pulser (#573)
2315989 Give access to all EOM block parameters and allow for phase drift correction (#566)
d5ac020 Adding  DetuningMap, DMM (#539)
f56a19f Remove expired deprecations in pulser-pasqal
@HGSilveri HGSilveri deleted the add_dmm_sequence branch October 20, 2023 08:55
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.

2 participants