qibocal.protocols.two_qubit_interaction.chsh package#

Submodules#

qibocal.protocols.two_qubit_interaction.chsh.circuits module#

Auxiliary functions to run CHSH using circuits.

qibocal.protocols.two_qubit_interaction.chsh.circuits.create_bell_circuit(theta=0.7853981633974483, bell_state=0)[source]#

Creates the circuit to generate the bell states and with a theta-measurement bell_state chooses the initial bell state for the test: 0 -> |00>+|11> 1 -> |00>-|11> 2 -> |10>-|01> 3 -> |10>+|01> Native defaults to only using GPI2 and GPI gates.

qibocal.protocols.two_qubit_interaction.chsh.circuits.create_bell_circuit_native(theta=0.7853981633974483, bell_state=0)[source]#

Creates the circuit to generate the bell states and with a theta-measurement bell_state chooses the initial bell state for the test: 0 -> |00>+|11> 1 -> |00>-|11> 2 -> |10>-|01> 3 -> |10>+|01> Native defaults to only using GPI2 and GPI gates.

qibocal.protocols.two_qubit_interaction.chsh.circuits.create_chsh_circuits(theta=0.7853981633974483, bell_state=0, native=True, readout_basis=['ZZ', 'ZX', 'XZ', 'XX'])[source]#

Creates the circuits needed for the 4 measurement settings for chsh. Native defaults to only using GPI2 and GPI gates. rerr adds a readout bitflip error to the simulation.

qibocal.protocols.two_qubit_interaction.chsh.protocol module#

Protocol for CHSH experiment using both circuits and pulses.

qibocal.protocols.two_qubit_interaction.chsh.protocol.CLASSICAL_BOUND = 2#

Classical limit of CHSH,

qibocal.protocols.two_qubit_interaction.chsh.protocol.QUANTUM_BOUND = 2.8284271247461903#

Quantum limit of CHSH.

qibocal.protocols.two_qubit_interaction.chsh.protocol.MITIGATION_MATRIX_FILE = 'mitigation_matrix'#

File where readout mitigation matrix is stored.

class qibocal.protocols.two_qubit_interaction.chsh.protocol.CHSHParameters(bell_states: list, ntheta: int, native: Optional[bool] = False, apply_error_mitigation: Optional[bool] = False)[source]#

Bases: Parameters

CHSH runcard inputs.

bell_states: list#

List with Bell states to compute CHSH. The following notation it is used: 0 -> |00>+|11> 1 -> |00>-|11> 2 -> |10>-|01> 3 -> |10>+|01>

ntheta: int#

Number of angles probed linearly between 0 and 2 pi.

native: Optional[bool] = False#

If True a circuit will be created using only GPI2 and CZ gates.

apply_error_mitigation: Optional[bool] = False#

Error mitigation model

hardware_average: bool = False#

By default hardware average will be performed.

nshots: int#

Number of executions on hardware.

relaxation_time: float#

Wait time for the qubit to decohere back to the gnd state.

class qibocal.protocols.two_qubit_interaction.chsh.protocol.CHSHData(bell_states: list, thetas: list, data: dict[typing.Union[str, int], typing.Union[str, int], int, tuple, str] = <factory>, mitigation_matrix: dict[tuple[typing.Union[str, int], ...], numpy.ndarray[typing.Any, numpy.dtype[+_ScalarType_co]]] = <factory>)[source]#

Bases: Data

CHSH Data structure.

bell_states: list#

Bell states list.

thetas: list#

Angles probed.

data: dict[Union[str, int], Union[str, int], int, tuple, str]#

Raw data acquired.

mitigation_matrix: dict[tuple[typing.Union[str, int], ...], numpy.ndarray[typing.Any, numpy.dtype[+_ScalarType_co]]]#

Mitigation matrix computed using the readout_mitigation_matrix protocol.

save(path: Path)[source]#

Saving data including mitigation matrix.

register_basis(pair, bell_state, basis, frequencies)[source]#

Store output for single qubit.

merge_frequencies(pair, bell_state)[source]#

Merge frequencies with different measurement basis.

_to_json(path: Path, filename: str)#

Helper function to dump to json.

_to_npz(path: Path, filename: str)#

Helper function to use np.savez while converting keys into strings.

static load_data(path: Path, filename: str)#

Load data stored in a npz file.

static load_params(path: Path, filename: str)#

Load parameters stored in a json file.

property pairs#

Access qubit pairs ordered alphanumerically from data structure.

property params#

Convert non-arrays attributes into dict.

property qubits#

Access qubits from data structure.

register_qubit(dtype, data_keys, data_dict)#

Store output for single qubit.

Parameters:
  • data_keys (tuple) – Keys of Data.data.

  • data_dict (dict) – The keys are the fields of dtype and

  • arrays. (the values are the related) –

class qibocal.protocols.two_qubit_interaction.chsh.protocol.CHSHResults(chsh: dict[tuple[typing.Tuple[typing.Union[str, int], typing.Union[str, int]], int], float] = <factory>, chsh_mitigated: dict[tuple[typing.Tuple[typing.Union[str, int], typing.Union[str, int]], int], float] = <factory>)[source]#

Bases: Results

CHSH Results class.

_to_json(path: Path, filename: str)#

Helper function to dump to json.

_to_npz(path: Path, filename: str)#

Helper function to use np.savez while converting keys into strings.

static load_data(path: Path, filename: str)#

Load data stored in a npz file.

static load_params(path: Path, filename: str)#

Load parameters stored in a json file.

property params: dict#

Convert non-arrays attributes into dict.

save(path: Path)#

Store results to file.

chsh: dict[tuple[Tuple[Union[str, int], Union[str, int]], int], float]#

Raw CHSH value.

chsh_mitigated: dict[tuple[Tuple[Union[str, int], Union[str, int]], int], float]#

Mitigated CHSH value.

qibocal.protocols.two_qubit_interaction.chsh.protocol._acquisition_pulses(params: CHSHParameters, platform: Platform, targets: list[list[Union[str, int]]]) CHSHData[source]#

Data acquisition for CHSH protocol using pulse sequences.

qibocal.protocols.two_qubit_interaction.chsh.protocol._acquisition_circuits(params: CHSHParameters, platform: Platform, targets: list[Tuple[Union[str, int], Union[str, int]]]) CHSHData[source]#

Data acquisition for CHSH protocol using circuits.

qibocal.protocols.two_qubit_interaction.chsh.protocol._plot(data: CHSHData, fit: CHSHResults, target: Tuple[Union[str, int], Union[str, int]])[source]#

Plotting function for CHSH protocol.

qibocal.protocols.two_qubit_interaction.chsh.protocol._fit(data: CHSHData) CHSHResults[source]#

Fitting for CHSH protocol.

qibocal.protocols.two_qubit_interaction.chsh.protocol.chsh_circuits = Routine(acquisition=<function _acquisition_circuits>, fit=<function _fit>, report=<function _plot>, update=<function _dummy_update>, two_qubit_gates=True)#

CHSH experiment using circuits.

qibocal.protocols.two_qubit_interaction.chsh.protocol.chsh_pulses = Routine(acquisition=<function _acquisition_pulses>, fit=<function _fit>, report=<function _plot>, update=<function _dummy_update>, two_qubit_gates=True)#

CHSH experiment using pulses.

qibocal.protocols.two_qubit_interaction.chsh.pulses module#

Auxialiary functions to run CHSH using pulses.

qibocal.protocols.two_qubit_interaction.chsh.pulses.create_bell_sequence(platform, qubits, theta=0.7853981633974483, bell_state=0)[source]#

Creates the pulse sequence to generate the bell states and with a theta-measurement bell_state chooses the initial bell state for the test: 0 -> |00>+|11> 1 -> |00>-|11> 2 -> |10>-|01> 3 -> |10>+|01>

qibocal.protocols.two_qubit_interaction.chsh.pulses.create_chsh_sequences(platform, qubits, theta=0.7853981633974483, bell_state=0, readout_basis=['ZZ', 'ZX', 'XZ', 'XX'])[source]#

Creates the pulse sequences needed for the 4 measurement settings for chsh.

qibocal.protocols.two_qubit_interaction.chsh.utils module#

Auxiliary functions to run CHSH protocol.

qibocal.protocols.two_qubit_interaction.chsh.utils.compute_chsh(frequencies, basis, i)[source]#

Computes the chsh inequality out of the frequencies of the 4 circuits executed.