Qiskit わざとNoisyな回路
参考Qiskitチュートリアル:Qiskit Aer: Simulators
一般に量子回路では,CNOT数が増えるとノイズ増加するので,Qiskitで確認してみる.
IBMQ ExperienceのNotebook上で実行した.
準備
必要なライブラリをimport
%matplotlib inline
# Importing standard Qiskit libraries and configuring account
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.compiler import transpile, assemble
from qiskit.tools.jupyter import *
from qiskit.visualization import *
# Loading your IBM Q account(s)
provider = IBMQ.load_account()
from qiskit.providers.aer import noise
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.tools.visualization import plot_histogram
from qiskit.tools.monitor import job_monitor
provider.backends()
device = provider.get_backend('ibmq_essex')
properties = device.properties()
coupling_map = device.configuration().coupling_map
関数の定義
注意: CNOTが連続するとQiskitが勝手に消してくれるので,消されないようにqc.barrier()
を追加.
def qc_noise(nn):
q = QuantumRegister(2)
c = ClassicalRegister(2)
qc = QuantumCircuit(q,c)
qc.h( q[0] )
qc.cx( q[0], q[1] )
for ii in range(nn):
#CNOTが連続するとQiskitが勝手に消してくれるので,消されないようにする
qc.barrier()
qc.cx( q[1], q[0] )
qc.measure(q,c)
return qc
回路の例
noise_model
, basis_gates
, simulator
の設定
noise_model = noise.device.basic_device_noise_model(properties)
print(noise_model)
>>NoiseModel:
Basis gates: ['cx', 'id', 'u2', 'u3']
Instructions with noise: ['measure', 'id', 'u3', 'cx', 'u2']
Qubits with noise: [0, 1, 2, 3, 4]
Specific qubit errors: [('id', [0]), ('id', [1]), ('id', [2]), ('id', [3]), ('id', [4]), ('u2', [0]), ('u2', [1]), ('u2', [2]), ('u2', [3]), ('u2', [4]), ('u3', [0]), ('u3', [1]), ('u3', [2]), ('u3', [3]), ('u3', [4]), ('cx', [0, 1]), ('cx', [1, 0]), ('cx', [1, 2]), ('cx', [1, 3]), ('cx', [2, 1]), ('cx', [3, 1]), ('cx', [3, 4]), ('cx', [4, 3]), ('measure', [0]), ('measure', [1]), ('measure', [2]), ('measure', [3]), ('measure', [4])]
# Get the basis gates for the noise model
basis_gates = noise_model.basis_gates
# Select the QasmSimulator from the Aer provider
simulator = Aer.get_backend('qasm_simulator')
測定結果
result_noise = execute(qc_noise(0), simulator,
noise_model=noise_model,
coupling_map=coupling_map,
basis_gates=basis_gates).result()
counts_noise = result_noise.get_counts()
plot_histogram(counts_noise, title="Counts for qc_noise(0)")
qc_noise(10)
, qc_noise(100)
, qc_noise(500)
で測定してみる.
nn=500
になると,大きく結果が異なってしまう.
Author And Source
この問題について(Qiskit わざとNoisyな回路), 我々は、より多くの情報をここで見つけました https://qiita.com/skiing_LAL10/items/7e34a79cfb51a82f501b著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .