Skip to main content
IBM Quantum Platform

게이트의 노이즈 모델 이해하기

이 튜토리얼에서는 고수준 프로토콜 함수 및 prepare_vanilla_program() 을 통해 이용할 수 있는 표준 학습 프로토콜을 사용하여 유니타리 게이트에 대한 노이즈 모델을 학습하는 방법을 보여줍니다 process_vanilla_result().

  1. 게이트 정의하기
  2. 로컬 시뮬레이션 설정
  3. 양자 프로그램 준비하기
  4. 양자 프로그램 실행하기
  5. 결과 보기
실제 하드웨어에서 실행

아래 회로들은 로컬에서 시뮬레이션되므로, 이 안내를 따라가려면 IBM Quantum® 인증 정보가 필요하지 않습니다. 실제 기기에서 실행하려면 다음과 같이 하세요:

  • 1단계 : 를 실제 백엔드로 FakeMarrakesh 교체합니다.
  • 2단계 : 해당 백엔드를 실행기의 모드로 지정하고, 시뮬레이터 옵션을 제거합니다.

1. 게이트를 정의하십시오

이 게이트는 서로 겹치지 않는 6개의 CZ 게이트가 나선형으로 겹쳐진 구조를 BoxOp 이루고 있습니다.

from qiskit.circuit import QuantumCircuit
from qiskit_ibm_runtime.fake_provider import FakeMarrakesh
from samplomatic import InjectNoise, Tag, Twirl

backend = FakeMarrakesh()

cz_pairs = [(91, 92), (93, 94), (95, 99), (98, 111), (112, 113), (114, 115)]

circuit = QuantumCircuit(backend.num_qubits)
with circuit.box([Twirl(), Tag("cz_gate"), InjectNoise("cz_gate")]):
    for pair in cz_pairs:
        circuit.cz(*pair)
실제 하드웨어에서 실행
from qiskit_ibm_runtime import QiskitRuntimeService

backend = QiskitRuntimeService().backend("ibm_marrakesh")

2. 로컬 시뮬레이션 설정

각 맵 내부의 파울리 지수는 게이트에 국한되며, 물리적 큐비트 순서대로 오름차순으로 나열되어 있습니다:

cz_qubits = sorted({qubit for pair in cz_pairs for qubit in pair})
local = {qubit: index for index, qubit in enumerate(cz_qubits)}
local
{91: 0,
 92: 1,
 93: 2,
 94: 3,
 95: 4,
 98: 5,
 99: 6,
 111: 7,
 112: 8,
 113: 9,
 114: 10,
 115: 11}

각 CZ 쌍에 대해 상관 ZZ 항과 더 약한 항 XX , 그리고 모든 위치에 단일 큐비트 Z 항을 포함하여 잡음을 정의하고, 측정에는 큐비트당 비트 반전 항을 부여한다.

from qiskit.quantum_info import PauliLindbladMap

num_qubits = len(cz_qubits)

cz_noise = PauliLindbladMap.from_sparse_list(
    [("ZZ", [local[a], local[b]], 8e-4) for a, b in cz_pairs]
    + [("XX", [local[a], local[b]], 4e-4) for a, b in cz_pairs]
    + [("Z", [index], 3e-4) for index in range(num_qubits)],
    num_qubits=num_qubits,
)

readout_noise = PauliLindbladMap.from_sparse_list(
    [("X", [index], 5e-3) for index in range(num_qubits)], num_qubits=num_qubits
)

배움을 위해 측정용 상자를 만들어 보세요.

measurement = QuantumCircuit(backend.num_qubits, num_qubits)
with measurement.box([Twirl(), Tag("readout"), InjectNoise("readout")]):
    for clbit, qubit in enumerate(cz_qubits):
        measurement.measure(qubit, clbit)

각 항목은 해당 상자 중 하나와 그 상자에 적용할 지도를 한 쌍으로 layer_noise_model 매칭합니다. 안정화 시뮬레이션 방법을 사용하고, 시뮬레이션된 데이터를 재현할 수 있도록 seed_simulator 를 설정하십시오.

from qiskit_aer import AerSimulator
from qiskit_ibm_runtime import Executor

executor = Executor(
    mode=AerSimulator(method="stabilizer"),
    options={
        "simulator": {
            "layer_noise_model": [
                (circuit[0], cz_noise),
                (measurement[0], readout_noise),
            ],
            "seed_simulator": 1234,
        }
    },
)
실제 하드웨어에서 실행
executor = Executor(mode=backend)

3. 양자 프로그램 준비하기

를 사용하여 학습 실험이 포함된 양자 프로그램을 작성하십시오 prepare_vanilla_program() .

from qiskit_noise_learning.protocols import prepare_vanilla_program

program = prepare_vanilla_program(
    backend,
    [circuit[0], measurement[0]],
    fragment_depths=[2, 16, 64, 128],
    num_randomizations=50,
    shots_per_randomization=20,
)

print(f"Number of template circuits: {len(program.items)}")
Number of template circuits: 5

4. 양자 프로그램을 실행합니다

양자 프로그램을 제출하세요. 이 단계는 실행 대상이 시뮬레이터이든 실제 기기이든 상관없이 동일합니다.

result = executor.run(program).result()

5. 결과를 확인하세요

결과를.로 처리합니다 process_vanilla_result().

from qiskit_noise_learning.protocols import process_vanilla_result

noise_maps, gate_names, fit = process_vanilla_result(result)

큐비트 쌍별 충실도 감쇠 곡선을 그래프로 나타내십시오: 데이터와 지수 함수 적합선 모두를 포함하십시오.

fit.plot_qubit_pair_decays(
    pairs=cz_pairs,
    observable_type="means",
    exponential_fit=True,
)
이 페이지가 도움이 되었습니까?
GitHub에서 버그, 오타를 보고하거나 컨텐츠를 요청하십시오.