qibocal.protocols.two_qubit_interaction.chsh package

Submodules

qibocal.protocols.two_qubit_interaction.chsh.circuits module

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 = np.float64(2.8284271247461903)

Quantum limit of CHSH.

class qibocal.protocols.two_qubit_interaction.chsh.protocol.CHSHParameters(bell_states: list[int], ntheta: int, native: bool | None = True)[source]

Bases: Parameters

CHSH runcard inputs.

bell_states: list[int]

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: bool | None = True

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

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.

qibocal.protocols.two_qubit_interaction.chsh.protocol.merge_frequencies(data: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], int, tuple, str], pair: tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], bell_state: int)[source]

Merge frequencies with different measurement basis.

qibocal.protocols.two_qubit_interaction.chsh.protocol.mitigated_frequencies(frequencies, mitigation_matrix, thetas)[source]
class qibocal.protocols.two_qubit_interaction.chsh.protocol.CHSHData(bell_states: list[int], thetas: list, data: dict[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], int, tuple, str] = <factory>, frequencies: dict[int, list[dict[str, list[int]]]] = <factory>, mitigated_frequencies: dict[int, list[dict[str, list[int]]]] = <factory>)[source]

Bases: Data

CHSH Data structure.

bell_states: list[int]

Bell states list.

thetas: list

Angles probed.

data: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], int, tuple, str]

Raw data acquired.

frequencies: dict[int, list[dict[str, list[int]]]]
mitigated_frequencies: dict[int, list[dict[str, list[int]]]]
register_basis(pair, bell_state, basis, frequencies)[source]

Store output for single qubit.

_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: dict

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)

save(path: Path)

Store data to file.

class qibocal.protocols.two_qubit_interaction.chsh.protocol.CHSHResults(chsh: dict[tuple[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)], int], float] = <factory>, chsh_mitigated: dict[tuple[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)], 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[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)], int], float]

Raw CHSH value.

chsh_mitigated: dict[tuple[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)], int], float]

Mitigated CHSH value.

qibocal.protocols.two_qubit_interaction.chsh.protocol._acquisition(params: CHSHParameters, platform: Platform, targets: list[list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]]]) CHSHData[source]

Data acquisition for CHSH protocol using pulse sequences.

qibocal.protocols.two_qubit_interaction.chsh.protocol._plot(data: ~qibocal.protocols.two_qubit_interaction.chsh.protocol.CHSHData, fit: ~qibocal.protocols.two_qubit_interaction.chsh.protocol.CHSHResults, target: ~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)])[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 = Routine(acquisition=<function _acquisition>, fit=<function _fit>, report=<function _plot>, update=<function _dummy_update>, two_qubit_gates=True)

CHSH experiment using pulses.

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.