ข้ามไปยังเนื้อหาหลัก

Noise learning helper

Package versions

The code on this page was developed using the following requirements. We recommend using these versions or newer.

qiskit[all]~=2.3.0
qiskit-ibm-runtime~=0.43.1

เทคนิค error mitigation PEA และ PEC ต่างใช้ noise learning component ที่อาศัย Pauli-Lindblad noise model ซึ่งโดยทั่วไปจัดการระหว่าง execution หลังจากส่ง job ผ่าน qiskit-ibm-runtime โดยไม่มีการเข้าถึง fitted noise model ในเครื่อง อย่างไรก็ตาม ตั้งแต่ qiskit-ibm-runtime 0.27.1 เป็นต้นมา ได้มีการสร้าง NoiseLearner และ class NoiseLearnerOptions ที่เกี่ยวข้อง เพื่อรับผลลัพธ์ของการทดลอง noise learning เหล่านี้ ผลลัพธ์เหล่านี้สามารถเก็บไว้ในเครื่องเป็น NoiseLearnerResult และใช้เป็น input ในการทดลองครั้งต่อไป หน้านี้ให้ภาพรวมของการใช้งานและตัวเลือกที่มี

ภาพรวม

class NoiseLearner ทำการทดลองที่ characterize กระบวนการ noise ตาม Pauli-Lindblad noise model สำหรับ Circuit หนึ่งตัว (หรือมากกว่า) มี method run() ที่ execute การทดลอง learning และรับ input เป็นรายการ Circuit หรือ PUB และคืน NoiseLearnerResult ที่มี noise channel ที่เรียนรู้แล้วและ metadata เกี่ยวกับ job ที่ส่ง ด้านล่างคือ code snippet ที่แสดงการใช้งาน helper program

# Added by doQumentation — required packages for this notebook
!pip install -q qiskit qiskit-ibm-runtime
from qiskit import QuantumCircuit
from qiskit.transpiler import CouplingMap
from qiskit.transpiler import generate_preset_pass_manager

from qiskit_ibm_runtime import QiskitRuntimeService, EstimatorV2
from qiskit_ibm_runtime.noise_learner import NoiseLearner
from qiskit_ibm_runtime.options import (
NoiseLearnerOptions,
ResilienceOptionsV2,
EstimatorOptions,
)

# Build a circuit with two entangling layers
num_qubits = 27
edges = list(CouplingMap.from_line(num_qubits, bidirectional=False))
even_edges = edges[::2]
odd_edges = edges[1::2]

circuit = QuantumCircuit(num_qubits)
for pair in even_edges:
circuit.cx(pair[0], pair[1])
for pair in odd_edges:
circuit.cx(pair[0], pair[1])

# Choose a backend to run on
service = QiskitRuntimeService()
backend = service.least_busy()

# Transpile the circuit for execution
pm = generate_preset_pass_manager(backend=backend, optimization_level=3)
circuit_to_learn = pm.run(circuit)

# Instantiate a NoiseLearner object and execute the noise learning program
learner = NoiseLearner(mode=backend)
job = learner.run([circuit_to_learn])
noise_model = job.result()

NoiseLearnerResult.data ที่ได้คือรายการของ LayerError object ที่มี noise model สำหรับแต่ละ entangling layer ที่เป็นส่วนหนึ่งของ Circuit เป้าหมาย แต่ละ LayerError เก็บข้อมูล layer ในรูปแบบของ Circuit และชุด qubit label ควบคู่กับ PauliLindbladError สำหรับ noise model ที่เรียนรู้สำหรับ layer นั้น

print(
f"Noise learner result contains {len(noise_model.data)} entries"
f" and has the following type:\n {type(noise_model)}\n"
)
print(
f"Each element of `NoiseLearnerResult` then contains"
f" an object of type:\n {type(noise_model.data[0])}\n"
)
print(
f"And each of these `LayerError` objects possess"
f" data on the generators for the error channel: \n{noise_model.data[0].error.generators}\n"
)
print(f"Along with the error rates: \n{noise_model.data[0].error.rates}\n")
Noise learner result contains 2 entries and has the following type:
<class 'qiskit_ibm_runtime.utils.noise_learner_result.NoiseLearnerResult'>

Each element of `NoiseLearnerResult` then contains an object of type:
<class 'qiskit_ibm_runtime.utils.noise_learner_result.LayerError'>

And each of these `LayerError` objects possess data on the generators for the error channel:
['IIIIIIIIIIIIIIIIIIIIIIIIIIX', 'IIIIIIIIIIIIIIIIIIIIIIIIIIY',
'IIIIIIIIIIIIIIIIIIIIIIIIIIZ', 'IIIIIIIIIIIIIIIIIIIIIIIIIXI',
'IIIIIIIIIIIIIIIIIIIIIIIIIXX', 'IIIIIIIIIIIIIIIIIIIIIIIIIXY',
'IIIIIIIIIIIIIIIIIIIIIIIIIXZ', 'IIIIIIIIIIIIIIIIIIIIIIIIIYI',
'IIIIIIIIIIIIIIIIIIIIIIIIIYX', 'IIIIIIIIIIIIIIII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IIIIIIIIIIIIIIYXIII', 'IIIIIIIIIIIIIIIIIIIIIIYYIII',
'IIIIIIIIIIIIIIIIIIIIIIYZIII', 'IIIIIIIIIIIIIIIIIIIIIIZIIII',
'IIIIIIIIIIIIIIIIIIIIIIZXIII', 'IIIIIIIIIIIIIIIIIIIIIIZYIII',
'IIIIIIIIIIIIIIIIIIIIIIZZIII', 'IIIIIIIIIIIIIIIIIIIIIXIIIII',
'IIIIIIIIIIIIIIIIIIIIIXXIIII', 'IIIIIIIIIIIIIIIIIIIIIXYIIII',
'IIIIIIIIIIIIIIIIIIIIIXZIIII', 'IIIIIIIIIIIIIIIIIIIIIYIIIII',
'IIIIIIIIIIIIIIIIIIIIIYXIIII', 'IIIIIIIIIIIIIIIIIIIIIYYIIII',
'IIIIIIIIIIIIIIIIIIIIIYZIIII', 'IIIIIIIIIIIIIIIIIIIIIZIIIII',
'IIIIIIIIIIIIIIIIIIIIIZXIIII', 'IIIIIIIIIIIIIIIIIIIIIZYIIII',
'IIIIIIIIIIIIIIIIIIIIIZZIIII', 'IIIIIIIIIIIIIIIIIIIIXIIIIII',
'IIIIIIIIIIIIIIIIIIIIYIIIIII', 'IIIIIIIIIIIIIIIIIIIIZIIIIII',
'IIIIIIIIIIIIIIIIIIIXIIIIIII', 'IIIIIIIIIIIIIIIIIIIXXIIIIII',
'IIIIIIIIIIIIIIIIIIIXYIIIIII', 'IIIIIIIIIIIIIIIIIIIXZIIIIII',
'IIIIIIIIIIIIIIIIIIIYIIIIIII', 'IIIIIIIIIIIIIIIIIIIYXIIIIII',
'IIIIIIIIIIIIIIIIIIIYYIIIIII', 'IIIIIIIIIIIIIIIIIIIYZIIIIII', ...]

Along with the error rates:
[8.80e-04 6.50e-04 3.10e-04 5.60e-04 0.00e+00 0.00e+00 0.00e+00 3.00e-04
6.00e-05 1.30e-04 7.00e-05 3.90e-04 0.00e+00 0.00e+00 3.00e-05 3.70e-04
0.00e+00 5.00e-05 7.50e-04 5.50e-04 5.00e-05 0.00e+00 7.60e-04 5.00e-04
5.60e-04 5.60e-04 2.50e-04 5.00e-05 7.00e-05 2.00e-04 1.40e-04 8.00e-05
2.80e-04 0.00e+00 1.70e-04 4.20e-04 3.00e-05 1.00e-05 1.30e-04 4.40e-04
1.00e-04 2.60e-04 7.10e-04 1.10e-04 2.60e-04 1.00e-04 6.80e-04 1.02e-03
4.60e-04 5.30e-04 3.00e-04 0.00e+00 0.00e+00 3.40e-04 0.00e+00 0.00e+00
2.70e-04 0.00e+00 5.00e-05 6.70e-04 0.00e+00 2.20e-04 0.00e+00 4.40e-04
4.30e-04 8.30e-04 1.42e-03 0.00e+00 0.00e+00 1.44e-03 8.70e-04 0.00e+00
0.00e+00 1.05e-03 6.80e-04 5.90e-04 5.10e-04 3.10e-04 5.60e-04 0.00e+00
4.00e-05 0.00e+00 5.50e-04 1.00e-05 2.00e-05 0.00e+00 1.10e-04 0.00e+00
1.20e-04 0.00e+00 2.20e-04 7.00e-05 4.00e-05 3.80e-04 2.80e-04 4.00e-05
7.00e-05 3.00e-04 1.20e-04 6.00e-04 5.80e-04 1.80e-04 5.00e-04 1.20e-04
2.00e-05 2.00e-05 4.80e-04 2.00e-05 0.00e+00 1.40e-04 4.00e-04 3.00e-05
0.00e+00 0.00e+00 4.40e-04 1.10e-04 5.00e-05 6.00e-04 2.30e-04 5.00e-05
1.10e-04 5.30e-04 3.60e-04 6.80e-04 6.70e-04 2.80e-04 4.90e-04 1.30e-04
6.00e-05 7.20e-04 3.00e-05 9.00e-05 1.10e-04 3.30e-04 6.00e-05 1.30e-04
7.60e-04 1.30e-04 1.50e-04 1.30e-04 0.00e+00 3.10e-04 2.50e-04 5.10e-04
0.00e+00 6.00e-05 2.50e-04 2.40e-04 8.00e-05 0.00e+00 0.00e+00 2.70e-04
0.00e+00 8.00e-05 0.00e+00 7.80e-04 7.00e-05 0.00e+00 0.00e+00 2.50e-04
1.70e-04 2.00e-05 4.50e-04 3.10e-04 2.00e-05 1.70e-04 4.60e-04 1.30e-04
3.20e-04 3.50e-04 3.80e-04 2.70e-04 2.00e-04 8.00e-05 1.00e-05 4.10e-04
0.00e+00 0.00e+00 0.00e+00 2.36e-03 0.00e+00 7.00e-05 1.20e-04 9.40e-04
0.00e+00 1.90e-04 1.38e-03 7.50e-04 1.90e-04 0.00e+00 1.14e-03 7.30e-04
5.70e-04 4.20e-04 6.20e-04 0.00e+00 2.20e-04 5.00e-05 1.20e-04 0.00e+00
0.00e+00 1.90e-04 6.00e-05 1.10e-04 2.10e-04 1.50e-04 1.20e-04 2.90e-04
4.60e-04 2.10e-04 4.00e-05 3.00e-05 1.70e-04 3.10e-04 1.00e-04 1.70e-04
3.00e-05 3.90e-04 0.00e+00 6.00e-04 5.60e-04 1.40e-04 3.50e-04 1.00e-04
1.20e-04 9.00e-05 3.20e-04 2.00e-05 1.70e-04 3.00e-05 4.00e-04 1.50e-04
0.00e+00 1.60e-04 1.90e-04 9.00e-05 6.00e-05 4.50e-04 3.10e-04 6.00e-05
9.00e-05 3.70e-04 2.80e-04 6.50e-04 5.30e-04 3.30e-04 8.00e-05 8.00e-05
5.00e-05 2.50e-04 3.50e-04 4.00e-05 0.00e+00 0.00e+00 1.70e-04 1.30e-04
0.00e+00 0.00e+00 7.00e-05 1.70e-04 1.00e-05 4.20e-04 2.00e-04 1.00e-05
1.70e-04 4.80e-04 1.40e-03 4.70e-04 4.00e-04 3.90e-04 4.40e-04 2.00e-04
1.90e-04 7.20e-04 1.80e-04 1.00e-04 0.00e+00 5.70e-04 1.90e-04 2.00e-04
8.70e-04 1.20e-04 1.70e-04 0.00e+00 0.00e+00 3.80e-04 2.40e-04 4.80e-04
6.00e-05 0.00e+00 9.00e-05 6.50e-04 2.00e-05 8.00e-05 1.40e-04 5.80e-04
1.30e-04 0.00e+00 2.00e-05 1.00e-05 1.60e-04 1.00e-05 1.80e-04 4.40e-04
8.00e-05 1.40e-04 4.40e-04 3.90e-04 1.40e-04 8.00e-05 3.90e-04 4.10e-04
8.80e-04 7.30e-04 1.90e-04]

attribute LayerError.error ของผลลัพธ์ noise learning มี generator และ error rate ของ fitted Pauli Lindblad model ซึ่งมีรูปแบบ

Λ(ρ)=expjrj(PjρPjρ),\Lambda(\rho) = \exp{\sum_j r_j \left(P_j \rho P_j^\dagger - \rho\right)},

โดยที่ rjr_j คือ LayerError.rates และ PjP_j คือ Pauli operator ที่ระบุใน LayerError.generators

ตัวเลือก noise learning

คุณสามารถเลือกตัวเลือกหลายอย่างเพื่อใส่เมื่อสร้าง NoiseLearner object ตัวเลือกเหล่านี้ถูก encapsulate โดย class qiskit_ibm_runtime.options.NoiseLearnerOptions และรวมถึงความสามารถในการระบุจำนวน layer สูงสุดที่จะเรียนรู้ จำนวน randomization และ twirling strategy เป็นต้น ดูเอกสาร API เกี่ยวกับ NoiseLearnerOptions สำหรับข้อมูลโดยละเอียดเพิ่มเติม

ด้านล่างคือตัวอย่างง่ายๆ ที่แสดงวิธีใช้ NoiseLearnerOptions ในการทดลอง NoiseLearner:

# Build a GHZ circuit
circuit = QuantumCircuit(10)
circuit.h(0)
circuit.cx(range(0, 9), range(1, 10))
# Choose a backend to run on
service = QiskitRuntimeService()
backend = service.least_busy()

# Transpile the circuit for execution
pm = generate_preset_pass_manager(backend=backend, optimization_level=3)
circuit_to_run = pm.run(circuit_to_learn)

# Instantiate a noise learner options object
learner_options = NoiseLearnerOptions(
max_layers_to_learn=3, num_randomizations=32, twirling_strategy="all"
)

# Instantiate a NoiseLearner object and execute the noise learning program
learner = NoiseLearner(mode=backend, options=learner_options)
job = learner.run([circuit_to_run])
noise_model = job.result()

ส่ง noise model ให้กับ primitive

noise model ที่เรียนรู้บน Circuit ยังสามารถใช้เป็น input ให้กับ EstimatorV2 primitive ที่ implement ใน Qiskit IBM Runtime ซึ่งสามารถส่งเข้า primitive ได้หลายวิธี ตัวอย่างสามตัวถัดไปแสดงวิธีที่คุณสามารถส่ง noise model ไปยัง attribute estimator.options โดยตรง ผ่าน ResilienceOptionsV2 object ก่อนสร้าง Estimator primitive และโดยการส่ง dictionary ที่จัดรูปแบบอย่างเหมาะสม

# pass the noise model to the `estimator.options` attribute directly
estimator = EstimatorV2(mode=backend)
estimator.options.resilience.layer_noise_model = noise_model
# Specify options via a ResilienceOptionsV2 object
resilience_options = ResilienceOptionsV2(layer_noise_model=noise_model)
estimator_options = EstimatorOptions(resilience=resilience_options)
estimator = EstimatorV2(mode=backend, options=estimator_options)
# Specify options via a dictionary
options_dict = {
"resilience_level": 2,
"resilience": {"layer_noise_model": noise_model},
}

estimator = EstimatorV2(mode=backend, options=options_dict)

เมื่อส่ง noise model เข้าไปใน EstimatorV2 object แล้ว สามารถใช้รัน workload และทำ error mitigation ได้ตามปกติ

ขั้นตอนถัดไป

Recommendations
Source: IBM Quantum docs — updated 27 เม.ย. 2569
English version on doQumentation — updated 7 พ.ค. 2569
This translation based on the English version of 11 มี.ค. 2569