Exemple #1
0
class GateModelParameters(BraketSchemaBase):
    """
    Defines parameters common to all gate model devices.

    Attributes:
        qubitCount: Number of qubits used by the circuit.
        disableQubitRewiring: Whether to run the circuit with the exact qubits chosen,
            without any rewiring downstream.
            If ``True``, no qubit rewiring is allowed; if ``False``, qubit rewiring is allowed.

    Examples:
        >>> import json
        >>> input_json = {
        ...    "braketSchemaHeader": {
        ...        "name": "braket.device_schema.gate_model_parameters",
        ...        "version": "1",
        ...    },
        ...    "qubitCount": 1,
        ...    "disableQubitRewiring": True
        ... }
        >>> GateModelParameters.parse_raw_schema(json.dumps(input_json))
    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name="braket.device_schema.gate_model_parameters", version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    qubitCount: conint(strict=True, ge=0)
    disableQubitRewiring: bool = False
class GateModelSimulatorParadigmProperties(BraketSchemaBase):
    """
    This class defines the properties that are specific to simulator device

    Attributes:
        qubitCount: number of qubits simulator device contains

    Examples:
        >>> import json
        >>> input_json = {
        ...    "braketSchemaHeader": {
        ...        "name":
        ...             "braket.device_schema.simulators.gate_model_simulator_paradigm_properties",
        ...        "version": "1",
        ...    },
        ...    "qubitCount": 32
        ... }
        >>> GateModelSimulatorParadigmProperties.parse_raw_schema(json.dumps(input_json))

    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name=
        "braket.device_schema.simulators.gate_model_simulator_paradigm_properties",
        version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    qubitCount: conint(ge=0)
Exemple #3
0
class DwaveDeviceParameters(BraketSchemaBase):
    """
    This is the description of the D-Wave parameters

    Attributes:
        providerLevelParameters: Parameters that are specific to D-Wave device.

    Examples:
        >>> import json
        >>> input_json = {
        ...     "braketSchemaHeader": {
        ...         "name": "braket.device_schema.dwave.dwave_device_parameters",
        ...         "version": "1",},
        ...     "providerLevelParameters": {
        ...         "braketSchemaHeader": {
        ...             "name": "braket.device_schema.dwave.dwave_provider_level_parameters",
        ...             "version": "1",
        ...         },
        ...         "annealingOffsets": [1],
        ...         "beta": 1,
        ...     }
        ... }
        >>> DwaveDeviceParameters.parse_raw_schema(json.dumps(input_json))

    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name="braket.device_schema.dwave.dwave_device_parameters", version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    providerLevelParameters: DwaveProviderLevelParameters
class GateModelQpuParadigmProperties(BraketSchemaBase):
    """
    This class defines the properties that are specific to gate model devices

    Attributes:
        connectivity: defines the connectivity if a gate model device.
            tells the graph and connection type.
        qubitCount: number of qubits the gate model device contains
        nativeGateSet: list of native gates

    Examples:
        >>> import json
        >>> input_json = {
        ...    "braketSchemaHeader": {
        ...        "name": "braket.device_schema.gate_model_qpu_paradigm_properties",
        ...        "version": "1",
        ...    },
        ...    "qubitCount": 32,
        ...    "nativeGateSet": ["ccnot", "cy"],
        ...    "connectivity": {
        ...        "fullyConnected": False,
        ...        "connectivityGraph": {"1": ["2", "3"]},
        ...    },
        ... }
        >>> GateModelQpuParadigmProperties.parse_raw_schema(json.dumps(input_json))
    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name="braket.device_schema.gate_model_qpu_paradigm_properties",
        version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    connectivity: DeviceConnectivity
    qubitCount: int
    nativeGateSet: List[str]
class RigettiMetadata(BraketSchemaBase):
    """
    The Rigetti metadata result schema.

    Attributes:
        braketSchemaHeader (BraketSchemaHeader): Schema header.
            Users do not need to set this value. Only default is allowed.
        nativeQuilMetadata (NativeQuilMetadata)
        program (str): The compiled program executed on the QPU

    Examples:
        >>> quil_metadata = NativeQuilMetadata(finalRewiring=[32,21],
                                              gateDepth=5,
                                              gateVolume=6,
                                              multiQubitGateDepth=1,
                                              programDuration=300.1,
                                              programFidelity=0.8989,
                                              qpuRuntimeEstimation=191.21,
                                              topologicalSwaps=0)
        >>> RigettiMetadata(program="DECLARE ro BIT[2]", nativeQuilMetadata=quil_metadata)


    """

    _RIGETTI_METADATA_HEADER = BraketSchemaHeader(
        name="braket.task_result.rigetti_metadata", version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(
        default=_RIGETTI_METADATA_HEADER, const=_RIGETTI_METADATA_HEADER)

    nativeQuilMetadata: Optional[NativeQuilMetadata]
    compiledProgram: constr(min_length=2)
Exemple #6
0
class IonqDeviceParameters(BraketSchemaBase):
    """
    This defines the parameters common to all the IonQ devices.

    Attributes:
        paradigmParameters: Parameters that are common to gatemodel paradigm

    Examples:
        >>> import json
        >>> input_json = {
        ...    "braketSchemaHeader": {
        ...        "name": "braket.device_schema.ionq.ionq_device_parameters",
        ...        "version": "1",
        ...    },
        ...    "paradigmParameters": {"braketSchemaHeader": {
        ...        "name": "braket.device_schema.gate_model_parameters",
        ...        "version": "1",
        ...    },"qubitCount": 1},
        ... }
        >>> IonqDeviceParameters.parse_raw_schema(json.dumps(input_json))
    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name="braket.device_schema.ionq.ionq_device_parameters", version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    paradigmParameters: GateModelParameters
class DeviceServiceProperties(BraketSchemaBase):
    """
    This class defines the common service properties for each device.

    Attributes:
        executionWindows (List[DeviceExecutionWindow]): List of the execution windows,
            it tells us which days the device can execute a task.
        shotsRange (Tuple[int, int]): range of the shots for a given device.
        deviceCost (Optional[DeviceCost]): cost of the device to run the quantum circuits
        deviceDocumentation (Optional[DeviceDocumentation]): provides device specific
            details like image, summary etc.
        deviceLocation (Optional[str]): location fo the device
        updatedAt (Optional[datetime]): time when the device properties are last updated.

    Examples:
        >>> import json
        >>> input_json = {
        ...    "braketSchemaHeader": {
        ...        "name": "braket.device_schema.device_service_properties",
        ...        "version": "1",
        ...    },
        ...    "executionWindows": [
        ...        {
        ...            "executionDay": "Everyday",
        ...            "windowStartHour": "09:00",
        ...            "windowEndHour": "09:55",
        ...        }
        ...    ],
        ...    "shotsRange": [1,10],
        ...    "deviceCost": {
        ...        "price": 0.25,
        ...        "unit": "minute"
        ...    },
        ...    "deviceDocumentation": {
        ...        "imageUrl": "image_url",
        ...        "summary": "Summary on the device",
        ...        "externalDocumentationUrl": "exter doc link",
        ...    },
        ...    "deviceLocation": "us-east-1",
        ...    "updatedAt": "2020-06-16T19:28:02.869136"
        ... }
        >>> DeviceServiceProperties.parse_raw_schema(json.dumps(input_json))

    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name="braket.device_schema.device_service_properties", version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    executionWindows: List[DeviceExecutionWindow]
    shotsRange: Tuple[int, int]
    deviceCost: Optional[DeviceCost]
    deviceDocumentation: Optional[DeviceDocumentation]
    deviceLocation: Optional[str]
    updatedAt: Optional[datetime]
Exemple #8
0
class RigettiProviderProperties(BraketSchemaBase):
    """
    This defines the parameters common to all rigetti devices.

    Attributes:
        specs (Dict[str, Dict[str, Dict[str, float]]]): Basic specifications for the device,
            such as gate fidelities and coherence times. More details at
            https://pyquil-docs.rigetti.com/en/stable/apidocs/autogen/pyquil.device.Specs.html

    Examples:
        >>> import json
        >>> input_json = {
        ...    "braketSchemaHeader": {
        ...        "name": "braket.device_schema.rigetti.rigetti_provider_properties",
        ...        "version": "1",
        ...    },
        ...    "specs": {
        ...        "1Q": {
        ...            "0": {
        ...                "T1": 1.69308193540552e-05,
        ...                "T2": 1.8719137150144e-05,
        ...                "f1QRB": 0.995048041389577,
        ...                "f1QRB_std_err": 0.000244061520274907,
        ...                "f1Q_simultaneous_RB": 0.989821537688075,
        ...                "f1Q_simultaneous_RB_std_err": 0.000699235456806402,
        ...                "fActiveReset": 0.978,
        ...                "fRO": 0.919,
        ...            },
        ...        },
        ...        "2Q": {
        ...            "0-1": {
        ...                "Avg_T1": 2.679913663417025e-05,
        ...                "Avg_T2": 2.957247297939755e-05,
        ...                "Avg_f1QRB": 0.9973200289413551,
        ...                "Avg_f1QRB_std_err": 0.000219048562898114,
        ...                "Avg_f1Q_simultaneous_RB": 0.9933270881335465,
        ...                "Avg_f1Q_simultaneous_RB_std_err": 0.000400066119480196,
        ...                "Avg_fActiveReset": 0.8425,
        ...                "Avg_fRO": 0.9165000000000001,
        ...                "fCZ": 0.843255182448229,
        ...                "fCZ_std_err": 0.00806009046760912,
        ...            }
        ...        },
        ...  }
        >>> RigettiProviderProperties.parse_raw_schema(json.dumps(input_json))
    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name="braket.device_schema.rigetti.rigetti_provider_properties",
        version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    specs: Dict[str, Dict[str, Dict[str, float]]]
Exemple #9
0
class Dwave2000QDeviceParameters(BraketSchemaBase):
    """
    This is the description of the D-Wave parameters

    Attributes:
        providerLevelParameters: Parameters that are specific to D-Wave device.
    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name="braket.device_schema.dwave.dwave_2000Q_device_parameters",
        version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    deviceLevelParameters: Dwave2000QDeviceLevelParameters
Exemple #10
0
class TaskMetadata(BraketSchemaBase):
    """
    The task metadata schema.

    Attributes:
        braketSchemaHeader (BraketSchemaHeader): Schema header. Users do not need
            to set this value. Only default is allowed.
        id (str): The ID of the task. For AWS tasks, this is the task ARN.
        shots (str): The number of shots for the task
        deviceId (str): The ID of the device on which the task ran.
            For AWS devices, this is the device ARN.
        deviceParameters any of (DwaveDeviceParameters, RigettiDeviceParameters,
            IonqDeviceParameters, GateModelSimulatorDeviceParameters).
            The device parameters of the task. Default is None.
        createdAt (str): The timestamp of creation;
            the format must be in ISO-8601/RFC3339 string format YYYY-MM-DDTHH:mm:ss.sssZ.
            Default is None.
        endedAt (str): The timestamp of when the task ended;
            the format must be in ISO-8601/RFC3339 string format YYYY-MM-DDTHH:mm:ss.sssZ.
            Default is None.
        status (str): The status of the task. Default is None.
        failureReason (str): The failure reason of the task. Default is None.

    Examples:
        >>> TaskMetadata(id="task_id", shots=100, deviceId="device_id")

    """

    _TASK_METADATA_HEADER = BraketSchemaHeader(
        name="braket.task_result.task_metadata", version="1")

    braketSchemaHeader: BraketSchemaHeader = Field(
        default=_TASK_METADATA_HEADER, const=_TASK_METADATA_HEADER)
    id: constr(min_length=1)
    shots: conint(ge=0)
    deviceId: constr(min_length=1)
    deviceParameters: Optional[Union[DwaveDeviceParameters,
                                     DwaveAdvantageDeviceParameters,
                                     Dwave2000QDeviceParameters,
                                     RigettiDeviceParameters,
                                     IonqDeviceParameters,
                                     GateModelSimulatorDeviceParameters, ]]
    createdAt: Optional[constr(min_length=1, max_length=24)]
    endedAt: Optional[constr(min_length=1, max_length=24)]
    status: Optional[constr(min_length=1, max_length=20)]
    failureReason: Optional[constr(min_length=1)]
class IonqProviderProperties(BraketSchemaBase):
    """
    This defines the properties common to all the IonQ devices.

    Attributes:
        fidelity(Dict[str, Dict[str, float]]): Average fidelity, the measured success
            to perform operations of the given type.
        timing(Dict[str, float]): The timing characteristics of the device. 1Q, 2Q, readout,
            and reset are the operation times. T1 and T2 are decoherence times

    Examples:
        >>> import json
        >>> input_json = {
        ...    "braketSchemaHeader": {
        ...        "name": "braket.device_schema.ionq.ionq_provider_properties",
        ...        "version": "1",
        ...    },
        ...    "fidelity": {
        ...        "1Q": {
        ...          "mean": 0.99717
        ...        },
        ...        "2Q": {
        ...          "mean": 0.9696
        ...        },
        ...        "spam": {
        ...          "mean": 0.9961
        ...        }
        ...      },
        ...      "timing": {
        ...        "T1": 10000000000,
        ...        "T2": 500000,
        ...        "1Q": 1.1e-05,
        ...        "2Q": 0.00021,
        ...        "readout": 0.000175,
        ...        "reset": 3.5e-05
        ...      },
        ...}
        >>> IonqProviderProperties.parse_raw_schema(json.dumps(input_json))
    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name="braket.device_schema.ionq.ionq_provider_properties", version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    fidelity: Dict[str, Dict[str, float]]
    timing: Dict[str, float]
class SimulatorMetadata(BraketSchemaBase):
    """
    The simulator metadata result schema.

    Attributes:
        braketSchemaHeader (BraketSchemaHeader): Schema header.
            Users do not need to set this value. Only default is allowed.
        executionDuration (int): The number of milliseconds it took to execute
            the circuit on the simulator.

    Examples:
        >>> SimulatorMetadata(executionDuration=100)

    """

    _SIMULATOR_METADATA_HEADER = BraketSchemaHeader(
        name="braket.task_result.simulator_metadata", version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(
        default=_SIMULATOR_METADATA_HEADER, const=_SIMULATOR_METADATA_HEADER)
    executionDuration: conint(ge=0)
Exemple #13
0
class DwaveMetadata(BraketSchemaBase):
    """
    The D-Wave metadata result schema.

    Attributes:
        braketSchemaHeader (BraketSchemaHeader): Schema header. Users do not need
            to set this value. Only default is allowed.
        activeVariables (List[int]): The active variables of the task on D-Wave
        timing (DwaveTiming): Additional timing metadata of the task on D-Wave

    Examples:
        >>> timing = DwaveTiming(qpuSamplingTime=1575, qpuAnnealTimePerSample=20)
        >>> DwaveMetadata(activeVariables=[0, 3, 4], timing=timing)
    """

    _DWAVE_METADATA_HEADER = BraketSchemaHeader(
        name="braket.task_result.dwave_metadata", version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(
        default=_DWAVE_METADATA_HEADER, const=_DWAVE_METADATA_HEADER)
    activeVariables: conlist(conint(ge=0))
    timing: DwaveTiming
Exemple #14
0
class Problem(BraketSchemaBase):
    """ Specifies a quantum annealing problem.

    Attributes:
        braketSchemaHeader (BraketSchemaHeader): Schema header. Users do not need
            to set this value. Only default is allowed.
        type (ProblemType): The type of problem; can be either "QUBO" or "ISING"
        linear (Dict[int, float]): Linear terms of the model.
        quadratic (Dict[str, float]): Quadratic terms of the model, keyed on comma-separated
            variables as strings

    Examples:
        >>> Problem(type=ProblemType.QUBO, linear={0: 0.3, 4: -0.3}, quadratic={"0,5": 0.667})
    """

    _PROBLEM_HEADER = BraketSchemaHeader(name="braket.ir.annealing.problem",
                                         version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROBLEM_HEADER,
                                                   const=_PROBLEM_HEADER)
    type: ProblemType
    linear: Dict[conint(ge=0), float]
    quadratic: Dict[str, float]
class GateModelTaskResult(BraketSchemaBase):
    """
    The gate model task result schema

    Attributes:
        braketSchemaHeader (BraketSchemaHeader): Schema header. Users do not need
            to set this value. Only default is allowed.
        measurements (List[List[int]]: List of lists, where each list represents a shot
            and each index of the list represents a qubit. Default is `None`.
        measurementProbabilities (Dict[str, float]): A dictionary of probabilistic results.
            Key is the measurements in a big endian binary string.
            Value is the probability the measurement occurred.
            Default is `None`.
        measuredQubits (List[int]): The indices of the measured qubits.
            Indicates which qubits are in `measurements`. Default is `None`.
        resultTypes (List[ResultTypeValue]): Requested result types and their values.
            Default is `None`.
        taskMetadata (TaskMetadata): The task metadata
        additionalMetadata (AdditionalMetadata): Additional metadata of the task
    """

    _GATE_MODEL_TASK_RESULT_HEADER = BraketSchemaHeader(
        name="braket.task_result.gate_model_task_result", version="1")

    braketSchemaHeader: BraketSchemaHeader = Field(
        default=_GATE_MODEL_TASK_RESULT_HEADER,
        const=_GATE_MODEL_TASK_RESULT_HEADER)
    measurements: Optional[conlist(conlist(conint(ge=0, le=1), min_items=1),
                                   min_items=1)]
    measurementProbabilities: Optional[Dict[
        constr(regex="^[01]+$", min_length=1),
        confloat(ge=0, le=1)]]
    resultTypes: Optional[List[ResultTypeValue]]
    measuredQubits: Optional[conlist(conint(ge=0), min_items=1)]
    taskMetadata: TaskMetadata
    additionalMetadata: AdditionalMetadata
Exemple #16
0
class GateModelParameters(BraketSchemaBase):
    """
    This defines the parameters common to all the gatemodel devices.

    Attributes:
        qubitCount: number of qubits for a device

    Examples:
        >>> import json
        >>> input_json = {
        ...    "braketSchemaHeader": {
        ...        "name": "braket.device_schema.gate_model_parameters",
        ...        "version": "1",
        ...    },
        ...    "qubitCount": 1
        ... }
        >>> GateModelParameters.parse_raw_schema(json.dumps(input_json))
    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name="braket.device_schema.gate_model_parameters", version="1"
    )
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
    qubitCount: conint(ge=0)
Exemple #17
0
class IonqDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
    """
    This defines the capabilities of an IonQ device.

    Attributes:
        action(Dict[DeviceActionType, JaqcdDeviceActionProperties]): Actions that an IonQ device
            can support
        paradigm(GateModelQpuParadigmProperties): Paradigm properties
        provider(Optional[IonqProviderProperties]): IonQ provider specific properties

    Examples:
        >>> import json
        >>> input_json = {
        ...    "braketSchemaHeader": {
        ...        "name": "braket.device_schema.ionq.ionq_device_capabilities",
        ...        "version": "1",
        ...    },
        ...    "service": {
        ...        "braketSchemaHeader": {
        ...            "name": "braket.device_schema.device_service_properties",
        ...            "version": "1",
        ...        },
        ...        "executionWindows": [
        ...            {
        ...                "executionDay": "Everyday",
        ...                "windowStartHour": "09:00",
        ...                "windowEndHour": "09:05",
        ...            }
        ...        ],
        ...        "shotsRange": [1, 10],
        ...        "deviceCost": {
        ...             "price": 0.25,
        ...             "unit": "minute"
        ...         },
        ...         "deviceDocumentation": {
        ...             "imageUrl": "image_url",
        ...             "summary": "Summary on the device",
        ...             "externalDocumentationUrl": "external doc link",
        ...         },
        ...         "deviceLocation": "us-east-1",
        ...         "updatedAt": "2020-06-16T19:28:02.869136"
        ...    },
        ...    "action": {
        ...        "braket.ir.jaqcd.program": {
        ...            "actionType": "braket.ir.jaqcd.program",
        ...            "version": ["1"],
        ...            "supportedOperations": ["x", "y"],
        ...            "supportedResultTypes": [{
        ...                 "name": "resultType1",
        ...                 "observables": ["observable1"],
        ...                 "minShots": 0,
        ...                 "maxShots": 4,
        ...             }],
        ...        }
        ...    },
        ...    "paradigm": {
        ...        "braketSchemaHeader": {
        ...            "name": "braket.device_schema.gate_model_qpu_paradigm_properties",
        ...            "version": "1",
        ...        },
        ...        "qubitCount": 11,
        ...        "nativeGateSet": ["ccnot", "cy"],
        ...        "connectivity": {
        ...            "fullyConnected": False,
        ...            "connectivityGraph": {"1": ["2", "3"]},
        ...        },
        ...    },
        ...    "deviceParameters": {IonqDeviceParameters.schema_json()},
        ... }
        >>> IonqDeviceCapabilities.parse_raw_schema(json.dumps(input_json))
    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name="braket.device_schema.ionq.ionq_device_capabilities", version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    action: Dict[DeviceActionType, JaqcdDeviceActionProperties]
    paradigm: GateModelQpuParadigmProperties
    provider: Optional[IonqProviderProperties]
Exemple #18
0
class GateModelSimulatorDeviceCapabilities(BraketSchemaBase,
                                           DeviceCapabilities):
    """
    This defines the capabilities of a simulator device.

    Attributes:
        action (Dict[DeviceActionType, JaqcdDeviceActionProperties]): Actions that a
            gate model simulator device can support
        paradigm (GateModelSimulatorParadigmProperties): Paradigm properties of a simulator

    Examples:
        >>> import json
        >>> input_json = {
        ...    "braketSchemaHeader": {
        ...        "name":
        ...             "braket.device_schema.simulators.gate_model_simulator_device_capabilities",
        ...        "version": "1",
        ...    },
        ...    "service": {
        ...        "braketSchemaHeader": {
        ...            "name": "braket.device_schema.device_service_properties",
        ...            "version": "1",
        ...        },
        ...        "executionWindows": [
        ...            {
        ...                "executionDay": "Everyday",
        ...                "windowStartHour": "09:00",
        ...                "windowEndHour": "11:00",
        ...            }
        ...        ],
        ...        "shotsRange": [1, 10],
        ...        "deviceCost": {
        ...             "price": 0.25,
        ...             "unit": "minute"
        ...         },
        ...         "deviceDocumentation": {
        ...             "imageUrl": "image_url",
        ...             "summary": "Summary on the device",
        ...             "externalDocumentationUrl": "external doc link",
        ...         },
        ...         "deviceLocation": "us-east-1",
        ...         "updatedAt": "2020-06-16T19:28:02.869136",
        ...    },
        ...    "action": {
        ...        "braket.ir.jaqcd.program": {
        ...            "actionType": "braket.ir.jaqcd.program",
        ...            "version": ["1"],
        ...            "supportedOperations": ["x", "y"],
        ...            "supportedResultTypes":[{
        ...                 "name": "resultType1",
        ...                 "observables": ["observable1"],
        ...                 "minShots": 0,
        ...                 "maxShots": 4,
        ...             }],
        ...        }
        ...    },
        ...    "paradigm": {
        ...        "braketSchemaHeader": {
        ...            "name":
        ...             "braket.device_schema.simulators.gate_model_simulator_paradigm_properties",
        ...            "version": "1",
        ...        },
        ...        "qubitCount": 31
        ...    },
        ...    "deviceParameters": {GateModelSimulatorDeviceParameters.schema_json()},
        ... }
        >>> GateModelSimulatorDeviceCapabilities.parse_raw_schema(json.dumps(input_json))

    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name=
        "braket.device_schema.simulators.gate_model_simulator_device_capabilities",
        version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    action: Dict[DeviceActionType, JaqcdDeviceActionProperties]
    paradigm: GateModelSimulatorParadigmProperties
def test_import_schema_module_error():
    schema = BraketSchemaBase(braketSchemaHeader=BraketSchemaHeader(
        name="braket.task_result.task_metadata", version="0.0"), )
    BraketSchemaBase.import_schema_module(schema)
class Program(BraketSchemaBase):
    """
    Root object of the JsonAwsQuantumCircuitDescription IR.



    Attributes:
        braketSchemaHeader (BraketSchemaHeader): Schema header. Users do not need
            to set this value. Only default is allowed.
        instructions (List[Any]): List of instructions.
        basis_rotation_instructions (List[Any]): List of instructions for
            rotation to desired measurement bases. Default is None.
        results (List[Union[Amplitude, Expectation, Probability, Sample, StateVector, Variance]]):
            List of requested results. Default is None.

    Examples:
        >>> Program(instructions=[H(target=0), Rz(angle=0.15, target=1)])
        >>> Program(instructions=[H(target=0), CNot(control=0, target=1)],
        ...     results=[Expectation(targets=[0], observable=['x'])],
        ...     basis_rotation_instructions=[H(target=0)])


    Note:
        The following instructions are supported:
        CCNot,
        CNot,
        CPhaseShift,
        CPhaseShift00,
        CPhaseShift01,
        CPhaseShift10,
        CSwap,
        CY,
        CZ,
        H,
        I,
        ISwap,
        PhaseShift,
        PSwap,
        Rx,
        Ry,
        Rz,
        S,
        Swap,
        Si,
        T,
        Ti,
        Unitary,
        V,
        Vi,
        X,
        XX,
        XY,
        Y,
        YY,
        Z,
        ZZ
    """

    _PROGRAM_HEADER = BraketSchemaHeader(name="braket.ir.jaqcd.program",
                                         version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    instructions: List[Any]
    results: Optional[List[Results]]
    basis_rotation_instructions: Optional[List[Any]]

    @validator("instructions",
               "basis_rotation_instructions",
               each_item=True,
               pre=True)
    def validate_instructions(cls, value, field):
        """
        Pydantic uses the validation subsystem to create objects. We use this custom validator for
        2 reasons:
        1. Implement O(1) deserialization
        2. Validate that the input instructions are supported
        """
        if isinstance(value, BaseModel):
            if value.type not in _valid_gates:
                raise ValueError(
                    f"Invalid gate specified: {value} for field: {field}")
            return value

        if value is None or "type" not in value or value[
                "type"] not in _valid_gates:
            raise ValueError(
                f"Invalid gate specified: {value} for field: {field}")
        return _valid_gates[value["type"]](**value)
class DwaveProviderLevelParameters(BraketSchemaBase):
    """
    This is the description of the D-Wave parameters

    Attributes:
        annealingOffsets (Optional[List[float]]): Provides offsets to annealing paths, per qubit.
        annealingSchedule (Optional[List[List[float]]]): Introduces variations to the global anneal
            schedule.
        annealingDuration (Optional[int] = Field(gt=1)): Sets the duration (in microseconds) of
            quantum annealing time, per read.
        autoScale (Optional[bool]): Indicates whether h and J values are rescaled.
        beta (Optional[float]): Provides a value for the Boltzmann distribution parameter.
            Used when sampling postprocessing is enabled on D-Wave 2000Q and earlier systems.
        chains (Optional[List[List[int]]]): Defines which qubits represent the same logical
            variable. Used only when postprocessing is enabled on D-Wave 2000Q and earlier systems.
            Ensures that all qubits in the same chain have the same value within each sample.
        compensateFluxDrift (Optional[bool]): Boolean flag indicating whether the D-Wave system
            compensates for flux drift.
        fluxBiases (Optional[List[float]]): List of flux-bias offset values with which to calibrate
            a chain. Often required when using the extended J range to create a strongly coupled
            chain for certain embeddings.
        initialState (Optional[List[int]]): When using the reverse annealing feature,
            you must supply the initial state to which the system is set.
        maxResults (Optional[int] = Field(gt=1)): Specifies the maximum number of
            answers returned from the solver.
        postprocessingType (Optional[PostProcessingType]): Defines what type of postprocessing the
            system runs online on raw solutions.
        programmingThermalizationDuration (Optional[int]): Gives the time (in microseconds) to wait
            after programming the QPU for it to cool back to base temperature (i.e.,
            post-programming thermalization time).
        readoutThermalizationDuration (Optional[int]): Gives the time (in microseconds) to wait
            after each state is read from the QPU for it to cool back to base temperature
            (i.e., post-readout thermalization time).
        reduceIntersampleCorrelation (Optional[bool]): Reduces sample-to-sample correlations caused
            by the spin-bath polarization effect by adding a delay between reads.
        reinitializeState (Optional[bool]): When using the reverse annealing feature,
            you must supply the initial state to which the system is set.
        resultFormat (Optional[ResultFormat]): Type of the result format returned by the QPU.
        spinReversalTransformCount (Optional[int] = Field(gt=0)): Specifies the number of
            spin-reversal transforms to perform.

    Examples:
        >>> import json
        >>> input_json = {
        ...    "braketSchemaHeader": {
        ...        "name": "braket.device_schema.dwave.dwave_provider_level_parameters",
        ...        "version": "1",
        ...    },
        ...    "beta": 1
        ... }
        >>> DwaveProviderLevelParameters.parse_raw_schema(json.dumps(input_json))

    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name="braket.device_schema.dwave.dwave_provider_level_parameters", version="1"
    )
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
    annealingOffsets: Optional[List[float]]
    annealingSchedule: Optional[List[List[float]]]
    annealingDuration: Optional[int] = Field(gt=1)
    autoScale: Optional[bool]
    beta: Optional[float]
    chains: Optional[List[List[int]]]
    compensateFluxDrift: Optional[bool]
    fluxBiases: Optional[List[float]]
    initialState: Optional[List[int]]
    maxResults: Optional[int] = Field(gt=1)
    postprocessingType: Optional[PostProcessingType]
    programmingThermalizationDuration: Optional[int]
    readoutThermalizationDuration: Optional[int]
    reduceIntersampleCorrelation: Optional[bool]
    reinitializeState: Optional[bool]
    resultFormat: Optional[ResultFormat]
    spinReversalTransformCount: Optional[int] = Field(gt=0)
class Program(BraketSchemaBase):
    """
    Root object of the JsonAwsQuantumCircuitDescription IR.



    Attributes:
        braketSchemaHeader (BraketSchemaHeader): Schema header. Users do not need
            to set this value. Only default is allowed.
        instructions (List[GateInstructions]): List of instructions.
        basis_rotation_instructions (List[GateInstructions]): List of instructions for
            rotation to desired measurement bases. Default is None.
        results (List[Union[Amplitude, Expectation, Probability, Sample, StateVector, Variance]]):
            List of requested results. Default is None.

    Examples:
        >>> Program(instructions=[H(target=0), Rz(angle=0.15, target=1)])
        >>> Program(instructions=[H(target=0), CNot(control=0, target=1)],
        ...     results=[Expectation(targets=[0], observable=['x'])],
        ...     basis_rotation_instructions=[H(target=0)])


    Note:
        The type `GateInstructions` includes the following instructions:
        CCNot,
        CNot,
        CPhaseShift,
        CPhaseShift00,
        CPhaseShift01,
        CPhaseShift10,
        CSwap,
        CY,
        CZ,
        H,
        I,
        ISwap,
        PhaseShift,
        PSwap,
        Rx,
        Ry,
        Rz,
        S,
        Swap,
        Si,
        T,
        Ti,
        Unitary,
        V,
        Vi,
        X,
        XX,
        XY,
        Y,
        YY,
        Z,
        ZZ
    """

    _PROGRAM_HEADER = BraketSchemaHeader(name="braket.ir.jaqcd.program",
                                         version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    instructions: List[GateInstructions]
    results: Optional[List[Results]]
    basis_rotation_instructions: Optional[List[GateInstructions]]
Exemple #23
0
class DwaveProviderProperties(BraketSchemaBase):
    """

    This defines the properties specific to D-Wave device

    Attributes:
        qubits: the list of the qubits available in D-Wave
        qubitCount: number of qubits available in D-Wave
        topology: the connections between each qubits

    Examples:
        >>> import json
        >>> input_json = {
        ...    "braketSchemaHeader": {
        ...        "name": "braket.device_schema.dwave.dwave_provider_properties",
        ...        "version": "1",
        ...    },
        ...    "annealingOffsetStep": 1.45,
        ...    "annealingOffsetStepPhi0": 1.45,
        ...    "annealingOffsetRanges": [[1.45, 1.45], [1.45, 1.45]],
        ...    "annealingDurationRange": [1, 2, 3],
        ...    "couplers": [[1, 2, 3], [1, 2, 3]],
        ...    "defaultAnnealingDuration": 1,
        ...    "defaultProgrammingThermalizationDuration": 1,
        ...    "defaultReadoutThermalizationDuration": 1,
        ...    "extendedJRange": [1.1, 2.45, 3.45],
        ...    "hGainScheduleRange": [1.11, 2.56, 3.67],
        ...    "hRange": [1.4, 2.6, 3.66],
        ...    "jRange": [1.67, 2.666, 3.666],
        ...    "maximumAnnealingSchedulePoints": 1,
        ...    "maximumHGainSchedulePoints": 1,
        ...    "perQubitCouplingRange": [1.777, 2.567, 3.1201],
        ...    "programmingThermalizationDurationRange": [1, 2, 3],
        ...    "qubits": [1, 2, 3],
        ...    "qubitCount": 1,
        ...    "quotaConversionRate": 1.341234,
        ...    "readoutThermalizationDurationRange": [1, 2, 3],
        ...    "taskRunDurationRange": [1, 2, 3],
        ...    "topology": {},
        ... }
        >>> DwaveProviderProperties.parse_raw_schema(json.dumps(input_json))
    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name="braket.device_schema.dwave.dwave_provider_properties",
        version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    annealingOffsetStep: float
    annealingOffsetStepPhi0: float
    annealingOffsetRanges: List[List[float]]
    annealingDurationRange: List[int]
    couplers: List[List[int]]
    defaultAnnealingDuration: int
    defaultProgrammingThermalizationDuration: int
    defaultReadoutThermalizationDuration: int
    extendedJRange: List[float]
    hGainScheduleRange: List[float]
    hRange: List[float]
    jRange: List[float]
    maximumAnnealingSchedulePoints: int
    maximumHGainSchedulePoints: int
    perQubitCouplingRange: List[float]
    programmingThermalizationDurationRange: List[int]
    qubits: List[int]
    qubitCount: int
    quotaConversionRate: float
    readoutThermalizationDurationRange: List[int]
    taskRunDurationRange: List[int]
    topology: dict
Exemple #24
0
class DwaveDeviceCapabilities(DeviceCapabilities, BraketSchemaBase):
    """
    These are the capabilities specific to D-Wave device

    Attributes:
        provider: Properties specific to D-Wave provider

    Examples:
        >>> import json
        >>> input_json = ...{
        ...    "braketSchemaHeader": {
        ...        "name": "braket.device_schema.dwave.dwave_device_capabilities",
        ...        "version": "1",
        ...    },
        ...    "provider": {
        ...        "braketSchemaHeader": {
        ...            "name": "braket.device_schema.dwave.dwave_provider_properties",
        ...            "version": "1",
        ...        },
        ...        "annealingOffsetStep": 1.45,
        ...        "annealingOffsetStepPhi0": 1.45,
        ...        "annealingOffsetRanges": [[1.45, 1.45], [1.45, 1.45]],
        ...        "annealingDurationRange": [1, 2, 3],
        ...        "couplers": [[1, 2, 3], [1, 2, 3]],
        ...        "defaultAnnealingDuration": 1,
        ...        "defaultProgrammingThermalizationDuration": 1,
        ...        "defaultReadoutThermalizationDuration": 1,
        ...        "extendedJRange": [1, 2, 3],
        ...        "hGainScheduleRange": [1, 2, 3],
        ...        "hRange": [1, 2, 3],
        ...        "jRange": [1, 2, 3],
        ...        "maximumAnnealingSchedulePoints": 1,
        ...        "maximumHGainSchedulePoints": 1,
        ...        "perQubitCouplingRange": [1, 2, 3],
        ...        "programmingThermalizationDurationRange": [1, 2, 3],
        ...        "qubits": [1, 2, 3],
        ...        "qubitCount": 1,
        ...        "quotaConversionRate": 1,
        ...        "readoutThermalizationDurationRange": [1, 2, 3],
        ...        "taskRunDurationRange": [1, 2, 3],
        ...        "topology": {},
        ...    },
        ...    "service": {
        ...        "braketSchemaHeader": {
        ...            "name": "braket.device_schema.device_service_properties",
        ...            "version": "1",
        ...        },
        ...        "executionWindows": [
        ...            {
        ...                "executionDay": "Everyday",
        ...                "windowStartHour": "09:00",
        ...                "windowEndHour": "19:00",
        ...            }
        ...        ],
        ...        "shotsRange": [1, 10],
        ...        "deviceCost": {
        ...             "price": 0.25,
        ...             "unit": "minute"
        ...         },
        ...         "deviceDocumentation": {
        ...             "imageUrl": "image_url",
        ...             "summary": "Summary on the device",
        ...             "externalDocumentationUrl": "exter doc link",
        ...         },
        ...         "deviceLocation": "us-east-1",
        ...         "updatedAt": "2020-06-16T19:28:02.869136"
        ...    },
        ...    "action": {
        ...        "braket.ir.annealing.problem": {
        ...            "actionType": "braket.ir.annealing.problem",
        ...            "version": ["1"],
        ...        }
        ...    },
        ...    "deviceParameters": {DwaveDeviceParameters.schema_json()},
        ... }
        >>> DwaveDeviceCapabilities.parse_raw_schema(json.dumps(input_json))
    """

    _PROGRAM_HEADER = BraketSchemaHeader(
        name="braket.device_schema.dwave.dwave_device_capabilities",
        version="1")
    braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER,
                                                   const=_PROGRAM_HEADER)
    provider: DwaveProviderProperties