Pulser icon indicating copy to clipboard operation
Pulser copied to clipboard

Changing the device of a Sequence

Open HGSilveri opened this issue 3 years ago • 15 comments

It might be useful to switch the device of an already constructed sequence.

Off the top of my head, I can think of two main features here:

  • Compatibility with the new device of each element in the sequence's schedule. This would be easier if the validation methods currently residing in Sequence were moved to the Device class, where the constraints reside.
  • A systematic matching between the channels of different devices.

HGSilveri avatar Apr 22 '21 17:04 HGSilveri

The construction of the Sequence class has since changed to store every relevant call that is made in its construction. As such, a device switch can instead be achieved by simply attempting to rebuild the sequence on the new device. This process will subject the creation to all checks that are normally in place.

Nonetheless, it is still necessary to design a systematic matching between hardware channels across different devices, because it should not be expected that they have the same name or exactly the same characteristics.

HGSilveri avatar May 10 '22 14:05 HGSilveri

Hello @HGSilveri . I would like to work on this issue.

Varda-star avatar Sep 08 '22 14:09 Varda-star

Great @Varda-star , it's yours!

HGSilveri avatar Sep 09 '22 09:09 HGSilveri

Hi @HGSilveri after reviewing the pulser sequence class, in order to switch devices, I finally decided to use all the different calls used while building the former sequence (stored in sequence._calls) then try to follow them with the target device and return only if there are no errors. What do you think about? Because modifying directly the former sequence will require more time because the validation methods are entangled in the sequence class.

Varda-star avatar Sep 14 '22 09:09 Varda-star

Hi @Varda-star , that's I would go about it too, I agree with this approach. Still, don't forget that there is no requirement on the channels of the device having the same name, so you will need to develop some clever way of matching the channels between two devices by comparing the specs of each one.

HGSilveri avatar Sep 15 '22 08:09 HGSilveri

With the two existing devices, channels have the same but the parameters are different actually.

Varda-star avatar Sep 15 '22 08:09 Varda-star

With the two existing devices, channels have the same but the parameters are different actually.

Yes, there is no requirement associated with the name given to the channels, so that is not a valid criterium for comparison.

HGSilveri avatar Sep 15 '22 08:09 HGSilveri

Yes, I just take into account the channel_id. From a given channel, I check if the channel_id is available on the target device, if so I declare the channel on the target device otherwise I stop the process.

Varda-star avatar Sep 15 '22 08:09 Varda-star

Yes, I just take into account the channel_id. From a given channel, I check if the channel_id is available on the target device, if so I declare the channel on the target device otherwise I stop the process.

That's too restrictive, actually. Even if two channels don't have exactly the same specs, they can still be interchangeable in some cases. By the way, when I was mentioning "channel names" before, I actually meant the IDs. There is no information or rule for the name given to the channel IDs, so it's not a valid comparison criteria. I could make a new device with a channel with exactly the same specs as rydberg_global on Chadoq2 and call it foo.

HGSilveri avatar Sep 15 '22 08:09 HGSilveri

I got your point. In this case, I must find how it is possible to interchange two channels given their specs

Varda-star avatar Sep 15 '22 09:09 Varda-star

Let's assume I replace channel A with channel B, channel A respecting a given criteria allowing this switch. To make the new sequence realising quite the same task as the former one, I will probably have to modify pulses too.

Varda-star avatar Sep 15 '22 09:09 Varda-star

Let's assume I replace channel A with channel B, channel A respecting a given criteria allowing this switch. To make the new sequence realising quite the same task as the former one, I will probably have to modify pulses too.

Indeed, that might happen if e.g. the clock period is different between the channels, but it doesn't necessarily mean the results will be changed significantly. I think the way to handle this is to add a keyword argument to the conversion method, like strict=False, where if you set it to True it is more strict on the channel requirements.

HGSilveri avatar Sep 15 '22 09:09 HGSilveri

Yes, I just take into account the channel_id. From a given channel, I check if the channel_id is available on the target device, if so I declare the channel on the target device otherwise I stop the process.

That's too restrictive, actually. Even if two channels don't have exactly the same specs, they can still be interchangeable in some cases. By the way, when I was mentioning "channel names" before, I actually meant the IDs. There is no information or rule for the name given to the channel IDs, so it's not a valid comparison criteria. I could make a new device with a channel with exactly the same specs as rydberg_global on Chadoq2 and call it foo.

We can then make our decision on the pulser.channels classes, check whether it's Rydberg Global/local, Raman...

Varda-star avatar Sep 15 '22 09:09 Varda-star

Yes, I just take into account the channel_id. From a given channel, I check if the channel_id is available on the target device, if so I declare the channel on the target device otherwise I stop the process.

That's too restrictive, actually. Even if two channels don't have exactly the same specs, they can still be interchangeable in some cases. By the way, when I was mentioning "channel names" before, I actually meant the IDs. There is no information or rule for the name given to the channel IDs, so it's not a valid comparison criteria. I could make a new device with a channel with exactly the same specs as rydberg_global on Chadoq2 and call it foo.

We can then make our decision on the pulser.channels classes, check whether it's Rydberg Global/local, Raman...

The addressing (global/local) and the basis (Rydberg, Raman, ...) are necessary criteria for two channels to match, there can't be any flexibility there. But I think we can allow some flexibility on the other parameters

HGSilveri avatar Sep 15 '22 09:09 HGSilveri

There are three main points to verify:

  1. The Register
  2. Channels
  3. Pulses
  • Register:

Shall I strictly end everything if there is one flaw e.g. one atom more than the target device capacity/ if some atom distance valid for the former register is no more valid for the target register... Shall I reconfigure the register? It might bring more issues than solutions...

There migth be cases where the structure is important, if we reconfigure we must preserve the structure. In case of a random configuration we must rescale the register

Varda-star avatar Sep 15 '22 09:09 Varda-star

Finally solved!!!

Varda-star avatar Dec 03 '22 12:12 Varda-star

Solved in #398

HGSilveri avatar Dec 12 '22 14:12 HGSilveri