Error mitigation
Error mitigation uses knowledge about a computer’s imperfections to reduce their impact on the returned results. It does not make the underlying hardware error-free: a mitigation may prepare additional sub-computations, change how the measurement budget is distributed, and post-process the collected data.
Perceval provides four mitigation techniques:
CompilationAveraging reduces dependence on one physical compilation of an experiment.
DistinguishablePhotonMitigation corrects part of the error caused by imperfect photon indistinguishability and multi-photon emission.
DetectorBalancing compensates for detector losses and unequal detector efficiencies.
PhotonRecycling recovers information from events in which one or two photons were lost.
The techniques address different imperfections and can be combined. A higher correction strength is not always a better choice: it can add compilation or execution overhead, may require more samples and shots to work properly, and every technique has conditions under which it is useful.
Using mitigations with a Computer
Assign an ordered list of mitigation objects to a Computer before creating or running an execution:
>>> import perceval as pcvl
>>>
>>> computer = pcvl.SimulatedComputer("SLOS")
>>> computer.mitigations = [
... pcvl.DistinguishablePhotonMitigation(order=1),
... pcvl.DetectorBalancing(),
... ]
The computer applies the mitigations automatically to compatible computations. The caller still uses the normal ExecutionFactory and Execution interfaces, and receives the usual result dictionary:
>>> experiment = pcvl.Experiment(pcvl.BS())
>>> experiment.with_input(pcvl.BasicState("|1,1>"))
>>> experiment.min_detected_photons_filter(1)
>>> factory = pcvl.ExecutionFactory(computer, experiment)
>>> with computer.acquire():
... results = factory.sample_count(max_samples=10_000)
Computations are decomposed in list order, and post-processing happens in reverse order. The MitigationFactory provides a standard, recommended order for the mitigations.
Note
Error mitigation is applied only to Commands that declare themselves compatible with it. Standard probability and sampling commands are compatible.
Note
The pre and post processing always apply synchronously, no matter what was asked at the Execution level.
Choosing a preset
The MitigationFactory provides convenient presets:
>>> mitigation_factory = pcvl.MitigationFactory(pcvl.MitigationLevel.medium)
>>> computer.mitigations = mitigation_factory.build()
The presets are:
MitigationLevel.noneMitigationLevel.lowMitigationLevel.mediumMitigationLevel.high
Photon recycling is never enabled by a preset because its experiment and input requirements are more restrictive. It can be enabled explicitly on the factory when appropriate. See MitigationFactory for customization examples.
Disabling and temporarily changing mitigations
Assign an empty list or None to disable all mitigations explicitly:
>>> computer.mitigations = []
Use Computer.apply_configuration to change mitigations temporarily:
>>> temporary_mitigations = [pcvl.DetectorBalancing()]
>>> with computer.apply_configuration(mitigations=temporary_mitigations):
... results = factory.probs()
The previous configuration is restored when the context exits.
Warning
Temporarily changing a computer configuration is generally unsafe when using asynchronous work.
Remote computers
For a RemoteComputer, mitigations set to None means that the remote provider may apply its
default mitigations. An empty list explicitly disables them, while a non-empty list requests the selected techniques:
>>> remote_computer.mitigations = None # Use the remote platform defaults
>>> remote_computer.mitigations = [] # Disable remote mitigations
>>> remote_computer.mitigations = [pcvl.DetectorBalancing()]
By default, the requested mitigations are sent to the remote platform. Set use_mitigations_remotely to
False to execute the required sub-computations remotely but combine and correct their results on the local
machine:
>>> remote_computer.use_mitigations_remotely = False
Warning
With local mitigation of remote results, Perceval uses the imperfections known when the execution is launched. They may differ from the platform conditions when the remote job actually runs.