Device interface
graphix_perceval.experiment module
- class graphix_perceval.experiment.PercevalExperiment(circuit: Circuit, photons: list[graphix_perceval.experiment.Photon])[source]
PercevalExperiment class for running MBQC patterns on Perceval simulators and Quandela devices.
- pattern
MBQC pattern to be run on the device
- Type
graphix.Patternobject
- circ
Perceval circuit corresponding to the pattern.
- Type
perceval.Circuitobject
- backend
Name of a Perceval simulator or Quandela device
- Type
str
- __init__(circuit: Circuit, photons: list[graphix_perceval.experiment.Photon])[source]
- Parameters
circuit (
perceval.Circuitobject) – Perceval circuit corresponding to the pattern.photons (list[
Photonobject]) – List of photons.
- get_probability_distribution(format_result: bool = True, postselection: bool = True) PhotonDistribution[source]
Get the probability distribution of the measurement results.
- Parameters
format_result (bool, optional) – whether to format the result so that only the result corresponding to the output qubit is taken out.
postselection (bool, optional) – whether to postselect the results.
- Returns
result – Probability distribution of the measurement results.
- Return type
- sample(num_samples=1024, format_result: bool = True, postselection: bool = True) PhotonCount[source]
Run the MBQC pattern on IBMQ devices
- Parameters
num_samples (int, optional) – Number of samples.
format_result (bool, optional) – whether to format the result so that only the result corresponding to the output qubit is taken out.
postselection (bool, optional) – whether to postselect the results.
- Returns
result – Measurement result.
- Return type
- set_input_state()[source]
Set the input states for the processor. The default input state is
|{P:H}>for each photon and|0>for each ancillary mode.
- set_local_processor(backend: str, source: ~perceval.components.source.Source = <perceval.components.source.Source object>, name: ~typing.Optional[str] = None)[source]
Set the local computing backend.
- Parameters
backend (str) – Name of a local backend.
source (
perceval.Sourceobject, optional) – Setting of single-photon source.name (str, optional) – Name for the processor.
- set_output_states()[source]
Set the output states. Currently, Perceval does not support feed-forward opetations, so we postselect the output states where
The witness photons are in
|{P:H}>and translated to|0,1>The computing photons are in
|{P:H}>and translated to|0,1>The readout photons are in
|{P:H}>or|{P:V}>
- class graphix_perceval.experiment.PhotonCount(counts: dict[str, int] = {})[source]
PhotonCount class for storing the counts of the measurement results.
perceval.BSCount does not seem to show fock state with one qubit properly.
- draw(sort: bool = True)[source]
Draw the counts result in a table.
If the code is run in a Jupyter notebook, the table will be displayed in HTML format. If the code is run in a terminal, the table will be displayed in ASCII format.
- Parameters
sort (bool, optional) – Whether to sort the counts by the key.
- class graphix_perceval.experiment.PhotonDistribution(distribution: dict[str, float] = {})[source]
PhotonDistribution class for storing the probability distribution of the measurement results.
perceval.BSDistribution does not seem to show fock state with one qubit properly.
- draw(sort: bool = True)[source]
Draw the probability distribution in a table. If the code is run in a Jupyter notebook, the table will be displayed in HTML format. If the code is run in a terminal, the table will be displayed in ASCII format.
- Parameters
sort (bool, optional) – Whether to sort the distribution by the key.