microsoft/qdk
Publicmirrored from https://github.com/microsoft/qdkAvailable
source/pip/qsharp/interop/qiskit/__init__.py
39lines · modecode
| 1 | # Copyright (c) Microsoft Corporation. |
| 2 | # Licensed under the MIT License. |
| 3 | |
| 4 | import json |
| 5 | from typing import Any, Dict, List, Optional, Union |
| 6 | |
| 7 | from ...estimator import EstimatorParams, EstimatorResult |
| 8 | from ..._native import OutputSemantics, ProgramType, QasmError |
| 9 | from .backends import QSharpBackend, ResourceEstimatorBackend, QirTarget |
| 10 | from .jobs import QsJob, QsSimJob, ReJob, QsJobSet |
| 11 | from .execution import DetaultExecutor |
| 12 | from qiskit import QuantumCircuit |
| 13 | |
| 14 | |
| 15 | def estimate( |
| 16 | circuit: QuantumCircuit, |
| 17 | params: Optional[Union[Dict[str, Any], List, EstimatorParams]] = None, |
| 18 | **options, |
| 19 | ) -> EstimatorResult: |
| 20 | """ |
| 21 | Estimates resources for Qiskit QuantumCircuit. |
| 22 | |
| 23 | :param circuit: The input Qiskit QuantumCircuit object. |
| 24 | :param params: The parameters to configure physical estimation. |
| 25 | :**options: Additional options for the execution. |
| 26 | - Any options for the transpiler, exporter, or Qiskit passes |
| 27 | configuration. Defaults to backend config values. Common |
| 28 | values include: 'optimization_level', 'basis_gates', |
| 29 | 'includes', 'search_path'. |
| 30 | :raises QasmError: If there is an error generating or parsing QASM. |
| 31 | |
| 32 | :returns `EstimatorResult`: The estimated resources. |
| 33 | """ |
| 34 | from ..._qsharp import ipython_helper |
| 35 | |
| 36 | ipython_helper() |
| 37 | backend = ResourceEstimatorBackend() |
| 38 | job = backend.run(circuit, params=params, **options) |
| 39 | return job.result() |
| 40 | |