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.Pattern object

circ

Perceval circuit corresponding to the pattern.

Type

perceval.Circuit object

backend

Name of a Perceval simulator or Quandela device

Type

str

__init__(circuit: Circuit, photons: list[graphix_perceval.experiment.Photon])[source]
Parameters
  • circuit (perceval.Circuit object) – Perceval circuit corresponding to the pattern.

  • photons (list[Photon object]) – 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

PhotonDistribution

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

PhotonCount

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.Source object, 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}>

set_postselection()[source]

Postselect the results according to the pattern.

set_remote_processor(backend: str, token: str)[source]

Set the remote computing backend.

Parameters
  • backend (str) – Name of a remote backend.

  • token (str) – Token for the remote processor.

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.

__init__(counts: dict[str, int] = {})[source]
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.

items() a set-like object providing a view on D's items[source]
replace_keys(replace_dict: dict[str, str])[source]

Replace the keys of the counts.

Parameters

replace_dict (dict) – Dictionary of the replacement.

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.

__init__(distribution: dict[str, float] = {})[source]
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.

items() a set-like object providing a view on D's items[source]
replace_keys(replace_dict: dict[str, str])[source]

Replace the keys of the distribution.

Parameters

replace_dict (dict) – Dictionary of the replacement.