Open CdeTerra opened 1 year ago
Hi @CdeTerra ! I agree that this would be beneficial, but it's easier said than done... If my memory serves me right, I tried to do this at some point but ended giving up on the idea. I'll have to take a closer look to remind myself of the difficulties.
Ok, I looked at it again. The main issue is that currently everything is setup assuming that the arguments to the Sequence
calls are Parametrized
instances.
This is why, for example, we turn Waveforms
and Pulses
into ParametrizedObj
when they are instantiated with at least one Parametrized
argument.
What you are suggesting is that we drop this assumption and start accepting that, although the argument of method is not parametrized (eg is a list
), its elements might be. This will naturally increase the complexity of the creation and building process to a point that I'm not sure is absolutely necessary.
As supporting argument, the use case you presented above could be relatively easily circumvented through a wrapper around the sequence building call:
seq = Sequence(reg, Chadoq2)
seq.declare_channel("ising", "rydberg_global")
time_list = seq.declare_variable("time_list", size=1, dtype=float)
amplitudes= seq.declare_variable("amplitudes", dtype=float, size=3)
pulse = Pulse(
InterpolatedWaveform(time_list[0], amplitudes),
ConstantWaveform(time_list[0], 10),
0
)
seq.add(pulse, "ising")
def get_built_seq(time_list, amplitude_start, amplitude_end):
return seq.build(time_list=[20], amplitudes=[amplitude_start, 5, amplitude_end])
built_seq = get_built_seq(time_list=[20], amplitude_start=0, amplitude_end=10)
On Pulser, it's possible to parametrize a sequence with a whole list. It's also possible to specify a single value with a list item. For example:
Providing a list constituted of items would also be nice:
Unfortunately, it fails on the following error:
Could it be considered to implement this possibility? It would help a lot in cases like SciPy minimization when we want it to minimize specific items of a list, without having to construct and deconstruct the list.
Note: the following also fails for the same reason: