qutech / qupulse

Quantum Computing Toolkit for Qubit Control
54 stars 31 forks source link

Sample a non constant waveform at reduced sample rate #824

Open terrorfisch opened 2 months ago

terrorfisch commented 2 months ago

We need to insert the information that specific pulse templates can be sampled with a reduced rate into the build process at some point. The program builder needs to recognize these. These can be done in three ways.

  1. Tell the program builder which PTs are special before create_program is calle
  2. Tell create_program which PTs are special (like the current to_single_waveform kwarg)
  3. Mark the PTs themselves

IMO point 2 is the one that fits best into qupulse design philosophy because we do not attach any metadata to the PTs right now. However, this leads to a rather unintuitive interface in practice as the to_single_waveform case demonstrated (anecdotal evidence).

My current preferred idea would be the following:

@Nomos11 Does this sound reasonable?

Example for 2.:

fast_pt = ...
slow_pt = ...

final_pt =  fast_pt @ slow_pt

program = final_pt.create_program(metadata: {slow_pt: dict(minimal_sample_rate=10**3)})

Example for 3.:

slow_pt = SequencePT(..., minimal_sample_rate='f_shuttle * 100')
Nomos11 commented 1 month ago

yes, that sounds reasonable to me. However, would the user then explicitly have to take care of the changed requirements for pulse granularity? That might run into some not so user friendly handling issues again if the time is not by chance compatible with all relevant powers of 2 (but maybe the pad_to_next_multiple or how it was called can help in some form)

terrorfisch commented 1 month ago

Yes this is also somewhing that bothers me.

The best I can come up with is

shuttle = FunctionPT('sin(t / t_dur)', duration='t_dur')
s1 = shuttle.with_mapping({'t_dur': '192 * 2**i'})
s2 = shuttle.with_mapping({'t_dur': '256 * 2**i'})
s3 = shuttle.with_mapping({'t_dur': '320 * 2**i'})

sweep = (s1 @ s2 @ s3).with_iteration(i, 10, 1000)
Nomos11 commented 1 month ago

In the end I think this is sufficient though. qupulse should probably enforce strict regulations and throw errors otherwise, and another layer on top [c/sh]ould allow potential inacurracies be handled. maybe some convenience functions can be drafted to assist this.

terrorfisch commented 1 month ago

In principle we can add timing requirements to PulseMetaData as well in the future to allow imprecise timing.

Nomos11 commented 1 month ago

additionally, something with rolling out loops that would not natively be supported by the linspacebuilder/the hardware could potentially be included.

terrorfisch commented 1 month ago

minimal_sample_rate mixes physical information and setup information (depends on hardware filtering and interpolation)

Option 3 is the best bet