Skip to main content
IBM Quantum Platform
Información sobre la traducción

Próximamente habrá traducciones a otros idiomas de esta página.

ParityQC Parity Twine Optimizer API reference


Inputs

See the following list for all input parameters this API accepts.

problem

Tipo: dict[str, float]

The cost function to be solved. Dictionary keys correspond to qubit labels, values to coefficients.

  • Required: Yes
  • Example: {"()": 3, "(0,)": 1, "(0, 1)": 2, "(1, 2)": -1}

variable_type

Tipo: str

Whether the variables are of type spin (s∈{−1,1}s \in \{-1, 1\}) or binary (x∈{0,1}x \in \{0, 1\}).

  • Required: Yes
  • Choices: spin or binary

backend_name

Tipo: str

Name of backend to use. If not specified, the least busy backend is chosen.

  • Required: No
  • Example: ibm_phoenix

problem_type

Tipo: str

Valor predeterminado: ""

Specifies the type of problem to enable specialized post-processing. At the moment, only mis (maximum independent set) is supported. If mis is set, the algorithm applies specific post-processing that exploits the MIS structure. If left empty, standard post-processing is applied.

  • Required: No
  • Choices: mis

function_size

Tipo: str

Valor predeterminado: "M"

Size the job runs at: "S", "M", or "L". The required size depends on the number of variables in problem and their interaction density, the fraction of all variable pairs that appear together in a term: up to 50 variables and a density of 0.1 is "S", up to 100 variables and a density of 0.25 is "M", and anything larger is "L". To calculate the size before you submit a job, see Function sizes. If the size is too small, the job fails with error 4600. If the size is larger than the job needs, the job runs normally and records a 4601 advisory event. function.sizes_map returns the mapping from size to compute profile, and function.default_size returns the default size.

  • Required: No
  • Example: "L"

Options

Tipo: dict[str, Any]

Input options, including the following: (Optional) Options are specified as a nested dictionary. See the full list of options and their default values.

  • Required: No
  • Example: {"shots": 1000, "problem_type": "my_problem", "postprocessing_level": 1, "transpile_only": False, "job_tags": ["my_tag"]}

Options list

shots

Tipo: int

Valor predeterminado: 100000

The number of shots to use.

postprocessing_level

Tipo: int

Valor predeterminado: 1

Whether to do classical post-processing or not. Possible values are 0 (no post-processing) and 1 (do post-processing).

transpile_only

Tipo: bool

Valor predeterminado: False

Boolean for whether only transpilation of the circuit is carried out. If so, circuit metrics are returned.

job_tags

Tipo: list[str]

Valor predeterminado: None

A label to identify job on IBM Quantum® Platform.

  • Default: None
  • Example: ["my_job_tag"]

Outputs

The output of this API is a dict object containing solution, solution bitstring, objective value, and metadata. If the transpile_only flag is set, only the circuit metric fields are populated with values.

Example:

{
    'solution': {'0': -1, '1': 1, '2': 1}, 
    'objective_value': -1.0,
    'solution_bitstring': '100',
    'metadata': {
        'circuit_metrics': {
            'depth': 23, 
            'gate_count': 200,
            'two_qubit_gate_depth': 4,
            'two_qubit_gate_count': 4,
            'num_qubits': 3,
            'operations': {'delay': 158, 'rz': 18, 'sx': 15, 'cz': 4, 'measure': 3, 'x': 2}
        }, 
        'solver_info': {
            'variable_mapping': {'0': 0, '1': 1, '2': 2},
            'bitstring_distributions': {
                'before_postprocessing': {'011': 3, '001': 1, '110': 1, '111': 3, '101': 1, '010': 1},
                'after_postprocessing': {'011': 4, '100': 6}
            }, 
            'best_parameters': {
                'beta': [-0.46259546391008877],
                'gamma': [0.6181957189727373]
            }
        },
        'resource_usage': {
            'RUNNING: MAPPING': {'CPU_TIME': 15.536},
            'RUNNING: OPTIMIZING_FOR_HARDWARE': {'CPU_TIME': 0.04}, 
            'RUNNING: WAITING_FOR_QPU': {'CPU_TIME': 0.0},
            'RUNNING: EXECUTING_QPU': {'QPU_TIME': 8.945},
            'RUNNING: POST_PROCESSING': {'CPU_TIME': 0.765}
        }
    }
}

Output structure

solution

Tipo: dict[str, int]

Value of solution. Keys correspond to those defined in problem.

  • Example: {'0': -1, '1': 1, '2': 1}

objective_value

Tipo: float

Cost of the solution. Quantifies the solution quality.

  • Example: -1.0

solution_bitstring

Tipo: str

The bitstring corresponding to the lowest cost.

  • Example: '100'

metadata

circuit_metrics

Tipo: dict[str, Any]

Information on the Twine transpilation.

depth

Tipo: int

The depth of circuit.

gate_count

Tipo: int

The number of gates in circuit.

two_qubit_gate_depth

Tipo: int

The two-qubit depth of circuit.

two_qubit_gate_count

Tipo: int

The two-qubit count of circuit.

num_qubits

Tipo: int

Number of qubits active in circuit.

operations

Tipo: dict[str, int]

Gate type (keys) and occurrence (value) in circuit.

solver_info

Tipo: dict[str, Any]

Algorithmic insights

variable_mapping

Tipo: dict[str, int]

The variable-to-qubit mapping used in the computation.

bitstring_distributions

Tipo: dict[str, Any]

A mapping of the basis state and how often it was sampled.

before_postprocessing

Tipo: dict[str, int]

Distribution of measured bitstrings before classical post-processing.

after_postprocessing

Tipo: dict[str, int]

Distribution of measured bitstrings after classical post-processing.

best_parameters

Tipo: dict[str, Any]

Optimized variational training parameters.

beta

Tipo: list[float]

Optimized variational parameter beta.

gamma

Tipo: list[float]

Optimized variational parameter gamma.

resource_usage

Tipo: dict[str, Any]

Information on timing.

RUNNING: MAPPING

Tipo: dict[str, float]

CPU time (s) for mapping problem.

RUNNING: OPTIMIZING_FOR_HARDWARE

Tipo: dict[str, float]

CPU time (s) for hardware optimization.

RUNNING: WAITING_FOR_QPU

Tipo: dict[str, float]

CPU time (s) waiting for QPU.

RUNNING: EXECUTING_QPU

Tipo: dict[str, float]

QPU time (s) used.

RUNNING: POST_PROCESSING

Tipo: dict[str, float]

CPU time (s) for post processing results.


Error handling

The function reports the following errors that relate to function_size. For all error codes, see the IBM Quantum error codes.

Code
Cause
4600The function_size is too small for the problem. The job fails, and the message names the size to use.
4601The function_size is larger than the job needs. The job runs normally and records an advisory event that you can read with job.events().
¿Le ha resultado útil esta página?
Informe de un error, de una errata o solicite contenido en GitHub.