Skip to content

Support reference sample in simulators #30

@rafaelha

Description

@rafaelha

To mirror stim, the compilers should have an argument skip_reference_sample: bool = False.

In our case, skip_reference_sample: bool = False actually takes extra work, since we have to compute a noiseless sample. However, we should still support this and make it the default to be compatible with stim.

From the stim docs:

def compile_sampler(self, *, skip_reference_sample: bool = False, seed: object = None) -> stim.CompiledMeasurementSampler:
    """Returns a CompiledMeasurementSampler, which can quickly batch sample measurements, for the circuit.

    Args:
        skip_reference_sample: Defaults to False. When set to True, the reference sample used by the sampler is
            initialized to all-zeroes instead of being collected from the circuit. This means that the results
            returned by the sampler are actually whether or not each measurement was *flipped*, instead of true
            measurement results.

            Forcing an all-zero reference sample is useful when you are only interested in error propagation and
            don't want to have to deal with the fact that some measurements want to be On when no errors occur.
            It is also useful when you know for sure that the all-zero result is actually a possible result from
            the circuit (under noiseless execution), meaning it is a valid reference sample as good as any
            other. Computing the reference sample is the most time consuming and memory intensive part of
            simulating the circuit, so promising that the simulator can safely skip that step is an effective
            optimization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions