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

Add convenience padding functionality #801

Closed
4 tasks done
terrorfisch opened this issue Oct 4, 2023 · 8 comments
Closed
4 tasks done

Add convenience padding functionality #801

terrorfisch opened this issue Oct 4, 2023 · 8 comments
Assignees
Labels
Framework integration Covers the integration of qupulse in measurement and experimental frameworks Implementation Priority: Desired

Comments

@terrorfisch
Copy link
Member

terrorfisch commented Oct 4, 2023

This is often required to adhere to external alignment requirements

def pad_to(self, to_new_duration: Union[ExpressionLike, Callable[[Expression], Expression]], pt_kwargs: dict = None):
    current_duration = self.duration
    if callable(to_new_duration):
        new_duration = to_new_duration(current_duration)
    else:
        new_duration = ExpressionScalar(to_new_duration)
    pad_duration = new_duration - current_duration
    if pad_duration == 0:
        return self
    pad_pt = ConstantPT(pad_duration, self.final_values)
    if pt_kwargs:
        return SequencePT(self, pad_pt , **pt_kwargs)
    else:
        return self @ pad_pt

def to_next_multiple(sample_rate: ExpressionLike, quantum: int):
    sample_rate = ExpressionScalar(sample_rate)
    return lambda duration: (duration * sample_rate + (quantum - 1)) // quantum * (quantum / sample_rate)
    

Usages

my_pt = ...

# pad to a fixed duration
padded_1 = my_pt.pad_to(1000)

# pad to a fixed sample coun
padded_2 = my_pt.pad_to('sample_rate * 1000')

# pad to the next muliple of 16 samples with a symbolic sample rate
padded_3 = my_pt.pad_to(to_next_multiple('sample_rate', 16))

# pad to the next muliple of 16 samples with a fixed sample rate of 1 GHz
padded_4 = my_pt.pad_to(to_next_multiple(1, 16))
  • Implement pad_to
  • Implement duration utility functions
    • multiple of
    • combination of minimum and multiple of
    • ...?
@terrorfisch terrorfisch added Priority: Desired Implementation Framework integration Covers the integration of qupulse in measurement and experimental frameworks labels Oct 4, 2023
@terrorfisch
Copy link
Member Author

@Nomos11 Optinions on the interface?

@Nomos11
Copy link
Collaborator

Nomos11 commented Oct 4, 2023

Looks like the right way to do it. What I do not fully grasp yet is:

  • how is the symbolic sample_rate provided?
  • I assume final_values contains the current channel allocations - this does not have to be provided via the pt_kwargs (what would be their usecase then?)?
  • does it entail potential disadvantages in program compilation afterwards if it is 'split' into 2 PTs?

One addition to the to_next_multiple might be an optional minimum_sample_count to not go below (e.g. the 192 samples for the Tabor)

@terrorfisch
Copy link
Member Author

how is the symbolic sample_rate provided?

At instantiation time, i.e. in create_program.

pt_kwargs (what would be their usecase then?)

pt_kwargs is for all optinal arguments that a SequencePT takes, f.i. an identifier or measurement definitions.

does it entail potential disadvantages in program compilation afterwards if it is 'split' into 2 PTs?

This can be automatically detected later or the resulting PT can be passed as a member of to_single_waveform.

@terrorfisch
Copy link
Member Author

Implemented in #802

@Nomos11
Copy link
Collaborator

Nomos11 commented Oct 12, 2023

Was the to_next_multiple convenience function supposed to be added as well, or to be constructed in own code?

@Nomos11 Nomos11 reopened this Oct 12, 2023
@terrorfisch
Copy link
Member Author

It was just an example here but it makes sense to provide it. Could you implement it?

@Nomos11
Copy link
Collaborator

Nomos11 commented Oct 13, 2023

is #805 suitable?

@Nomos11
Copy link
Collaborator

Nomos11 commented May 27, 2024

the corresponding branch has been merged, if I see it correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework integration Covers the integration of qupulse in measurement and experimental frameworks Implementation Priority: Desired
Projects
None yet
Development

No branches or pull requests

2 participants