偽プロバイダー
qiskit.providers.fake_provider
概要
Qiskitの偽プロバイダモジュールには、トランスパイラやその他のバックエンド向け機能をテストするのに便利な偽の(シミュレートされた)バックエンドクラスが含まれています。
使用例
以下は、シミュレートされたバックエンドをトランパイルに使用し、実行する例である。
from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import GenericBackendV2
from qiskit.visualization import plot_histogram
# Generate a 5-qubit simulated backend
backend = GenericBackendV2(num_qubits=5)
# Create a simple circuit
circuit = QuantumCircuit(3)
circuit.h(0)
circuit.cx(0,1)
circuit.cx(0,2)
circuit.measure_all()
circuit.draw('mpl')
# Transpile the ideal circuit to a circuit that can be directly executed by the backend
transpiled_circuit = transpile(circuit, backend)
transpiled_circuit.draw('mpl')
# Run the transpiled circuit using the simulated backend
job = backend.run(transpiled_circuit)
counts = job.result().get_counts()
plot_histogram(counts)
V2 シミュレートされたバックエンド
GenericBackendV2(num_qubits[, basis_gates,...] ) | ジェネリック BackendV2 の実装で、設定可能なコンストラクタがあります。 |
このページは役に立ちましたか?
バグや誤字の報告、またはコンテンツの要求はGitHubで行ってください。