CompilationAveraging
Compilation averaging reduces the effect of choosing one particular physical compilation of an experiment. Perceval divides the requested measurement budget over several compilation seeds, runs those sub-computations, and combines their sample counts into one result.
It can be used when the target platform supports a compilation_seed parameter and different valid compilations
may have different physical performance:
>>> import perceval as pcvl
>>>
>>> computer.mitigations = [pcvl.CompilationAveraging(repetitions=3)]
The optional starting_seed makes the sequence of compilation seeds reproducible:
>>> mitigation = pcvl.CompilationAveraging(repetitions=3, starting_seed=100)
Practical considerations
The command must accept
compilation_seed. Otherwise, this mitigation leaves the computation unchanged.repetitionsmust be a positive integer.When
max_samplesormax_shotsis set, its value must be at least the number of repetitions. The total requested budget is divided between the repetitions rather than repeated in full for each one.
Note
Avoid setting a too high value for the number of repetitions, as compilation can take some time.
- class perceval.runtime.error_mitigation.compilation_averaging.CompilationAveraging(repetitions, starting_seed=None)
Reduce sensitivity to a single physical compilation by averaging the results over several compilations.
The requested samples and shots are divided between
repetitionssub-computations, each using a different compilation seed. Their sample counts are combined during post-processing. Commands that do not accept acompilation_seedparameter are left unchanged.- Parameters:
repetitions (
int) – Number of compilations to average. More repetitions require more compilation work.starting_seed (
Optional[int]) – Optional first compilation seed. When omitted, choose one randomly.
- extend_computation(computation, imperfections)
- Parameters:
computation (
Computation) – The computation asked by the upper layerimperfections (
Imperfections) – The Computer imperfections
- Return type:
list[Computation]- Returns:
a list of all computations to execute to apply the mitigation