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

ย้ายจาก cloud simulators ไปสู่ local simulators

ในการคอมพิวติ้งเชิงควอนตัม การเลือกว่าจะใช้ simulator หรือฮาร์ดแวร์ควอนตัมจริงนั้นสำคัญมากต่อความก้าวหน้าในสาขานี้ แม้ simulator จะมีประโยชน์สำหรับการทดสอบและดีบัก แต่ในยุคของ quantum utility การพัฒนาควอนตัมและความก้าวหน้าทางอุตสาหกรรมต้องการฮาร์ดแวร์จริง ในฐานะส่วนหนึ่งของการเคลื่อนไปสู่ quantum utility IBM Quantum® cloud simulators ถูกปลดระวางเมื่อวันที่ 15 พฤษภาคม 2024 คู่มือนี้อธิบายรายละเอียดการปลดระวางและวิธีย้ายจาก cloud-based simulators เช่น ibmq_qasm_simulator มาสู่ local simulators

ทำไม cloud simulators ถึงถูกปลดระวาง?

cloud simulators ถูกปลดระวางด้วยเหตุผลหลายประการ:

Simulators มีข้อจำกัด

Simulators มีประโยชน์ แต่มีข้อจำกัดมากเกินไปสำหรับการวิจัยหรือการทดลอง:

  • Simulators มีคุณค่าสำหรับการทำความเข้าใจ QPU (quantum processing units) ขนาดเล็ก แต่ประโยชน์จะถึงขีดสูงสุดที่ประมาณ 50 qubits แม้จะมีซูเปอร์คอมพิวเตอร์ประสิทธิภาพสูง ข้อจำกัดนี้มาจากการเติบโตแบบเลขชี้กำลังของทรัพยากรการคำนวณที่จำเป็นสำหรับการจำลองคอมพิวเตอร์ควอนตัมขนาดใหญ่ขึ้น (ดู Massively parallel quantum computer simulator, eleven years later สำหรับคำอธิบายเต็ม) การสำรวจคอมพิวเตอร์ควอนตัมที่มี 100 qubits ขึ้นไปต้องการฮาร์ดแวร์จริง

  • แม้ simulator บางตัวจะมี noise model แต่การจับพลวัตทั้งหมดของ QPU จริงเป็นปัญหาที่ยากมาก ฮาร์ดแวร์ควอนตัมเปิดโอกาสให้นักวิจัยรับมือกับความท้าทายที่มีอยู่จริงในคอมพิวเตอร์ควอนตัม เช่น noise, errors และ decoherence ในสภาพแวดล้อมการทดสอบที่สมจริง

การใช้ฮาร์ดแวร์ควอนตัมสร้างทักษะพิเศษ

การโต้ตอบกับฮาร์ดแวร์ควอนตัมช่วยพัฒนาทักษะและประสบการณ์ที่ไม่สามารถได้จากการใช้แค่ simulator:

  • การโต้ตอบโดยตรงกับฮาร์ดแวร์ควอนตัมสร้างทักษะเพราะต้องนำ error mitigation หรือ suppression techniques มาใช้งานจริงเพื่อให้ได้การคำนวณที่น่าเชื่อถือ

  • ประสบการณ์ลงมือทำกับฮาร์ดแวร์ควอนตัมพัฒนาความเข้าใจเชิงลึกเกี่ยวกับปรากฏการณ์ควอนตัมและวิธีปรับแต่งอัลกอริทึมให้เข้ากับคุณลักษณะของ quantum processors

  • การทำงานกับฮาร์ดแวร์ควอนตัมให้ข้อมูลเชิงปฏิบัติเกี่ยวกับความท้าทายและโอกาสของการคอมพิวติ้งเชิงควอนตัม ซึ่งช่วยเพิ่มความสามารถของนักพัฒนาในการขับเคลื่อนนวัตกรรมในสาขานี้

อัลกอริทึมควรได้รับการปรับแต่งสำหรับฮาร์ดแวร์ควอนตัม

อัลกอริทึมควอนตัมที่ประสบความสำเร็จต้องถูกปรับแต่งให้ใช้ประโยชน์จากความสามารถของฮาร์ดแวร์ควอนตัม เพื่อเพิ่มประสิทธิภาพและประสิทธิผลสูงสุด

  • ฮาร์ดแวร์ควอนตัมให้การแสดงแทน QPU ในโลกจริงที่แม่นยำกว่า simulator

  • การปรับแต่งอัลกอริทึมสำหรับฮาร์ดแวร์ควอนตัมเกี่ยวข้องกับการปรับ ansatz, การนำ Circuit ไปใช้, พารามิเตอร์, และการกำหนดค่าเพื่อเพิ่มประสิทธิภาพสูงสุด กระบวนการนี้ทำได้ดีที่สุดผ่านการทดลองโดยตรงกับฮาร์ดแวร์ควอนตัม

ควรใช้ simulator เมื่อไร?

Quantum simulators ควรใช้เพื่อช่วยพัฒนาและทดสอบโปรแกรมก่อนที่จะปรับแต่งและส่งไปยังฮาร์ดแวร์ควอนตัม Local simulators สามารถทำสิ่งนี้ได้ด้วยประสิทธิภาพและประสิทธิผลที่ดี Clifford circuits สามารถ simulate ได้อย่างมีประสิทธิภาพมาก และผลลัพธ์สามารถยืนยันได้ ซึ่งเป็นวิธีที่มีประโยชน์ในการสร้างความเชื่อมั่นในการทดลอง

หมายเหตุ

Local testing mode ไม่มี error suppression หรือ mitigation ในตัว แต่ต้องระบุตัวเลือกเหล่านั้นอย่างชัดเจน ดู Configure error mitigation for Qiskit Runtime สำหรับรายละเอียด

ย้ายไปใช้ local simulators

ด้วย qiskit-ibm-runtime 0.22.0 หรือใหม่กว่า สามารถใช้ local testing mode เพื่อแทนที่ cloud simulators ได้ ขึ้นอยู่กับความต้องการ มีหลายวิธีในการใช้ local testing mode เริ่มต้นด้วยการระบุ fake backends ใน qiskit_ibm_runtime.fake_provider หรือระบุ Qiskit Aer Backend เมื่อสร้าง primitive หรือ Session

แนวทางการเลือก simulator

ใช้ตารางต่อไปนี้เพื่อช่วยเลือก simulator

SimulatorFake BackendsAerSimulatorClifford Simulation
จุดประสงค์จำลองพฤติกรรม IBM® QPUs โดยใช้ snapshotsการ simulation อเนกประสงค์ประสิทธิภาพสูงการ simulation ที่มีประสิทธิภาพสำหรับ Clifford circuits
Noise modelใช้ noise model จาก QPU snapshots โดยอัตโนมัติกำหนดเองหรืออิงจากข้อมูล calibration ของ QPU จริงเหมาะสำหรับการ simulation แบบไม่มี noise
ขนาด Circuitจำกัดตามความสามารถของ QPU ที่จำลองรองรับ circuits ขนาดใหญ่ได้เหมาะสำหรับ circuits ขนาดใหญ่มาก (หลายร้อย qubits)
ผลลัพธ์รันไทม์ปานกลางสำหรับการทดสอบเฉพาะ QPUรันไทม์สั้นกว่าสำหรับการ simulation หลายประเภทเร็วมาก เหมาะสำหรับ stabilizer circuits
กรณีการใช้งานทดสอบพฤติกรรมของ Transpiler และ QPU เฉพาะการพัฒนาทั่วไป, noise model แบบกำหนดเองLarge stabilizer circuits, error correction
หมายเหตุ

สำหรับผู้ใช้ส่วนใหญ่ AerSimulator เป็นตัวเลือกที่ดีเนื่องจากความยืดหยุ่นและประสิทธิภาพ อย่างไรก็ตาม หากงานของมุ่งเป้าไปที่ QPU เฉพาะ fake backend อาจเป็นตัวเลือกที่ดีกว่า

Fake backends

fake backends จำลองพฤติกรรมของ IBM QPUs โดยใช้ snapshots ซึ่ง snapshots มีข้อมูลสำคัญเกี่ยวกับ QPU เช่น coupling map, basis gates, และคุณสมบัติของ Qubit ที่มีประโยชน์สำหรับการทดสอบ Transpiler และการ simulate QPU แบบมี noise โดย noise model จาก snapshot จะถูกใช้งานโดยอัตโนมัติระหว่างการ simulation

ตัวอย่าง:

from qiskit.circuit.library import RealAmplitudes
from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.quantum_info import SparsePauliOp
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
from qiskit_ibm_runtime import SamplerV2 as Sampler, QiskitRuntimeService

service = QiskitRuntimeService()

# Bell Circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()

# Run the sampler job locally using FakeManilaV2
fake_manila = FakeManilaV2()
pm = generate_preset_pass_manager(backend=fake_manila, optimization_level=1)
isa_qc = pm.run(qc)

# You can use a fixed seed to get fixed results.
options = {"simulator": {"seed_simulator": 42}}
sampler = Sampler(mode=fake_manila, options=options)

result = sampler.run([isa_qc]).result()

AerSimulator

สามารถใช้ local testing mode กับ simulators จาก Qiskit Aer ซึ่งให้การ simulation ประสิทธิภาพสูงที่รองรับ circuits ขนาดใหญ่และ custom noise models ยังรองรับ Clifford simulation mode ที่ simulate Clifford circuits ที่มี qubits จำนวนมากได้อย่างมีประสิทธิภาพ

ตัวอย่างกับ sessions โดยไม่มี noise:

ข้อควรระวัง

โค้ดบล็อกต่อไปนี้จะคืนค่า error สำหรับผู้ใช้แผน Open Plan เพราะใช้ sessions workloads บนแผน Open Plan รันได้เฉพาะใน job mode หรือ batch mode เท่านั้น

from qiskit_aer import AerSimulator
from qiskit.circuit.library import RealAmplitudes
from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.quantum_info import SparsePauliOp
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime import Session, SamplerV2 as Sampler, QiskitRuntimeService

service = QiskitRuntimeService()

# Bell Circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()

# Run the sampler job locally using AerSimulator.
# Session syntax is supported but ignored because local mode doesn't support sessions.
aer_sim = AerSimulator()
pm = generate_preset_pass_manager(backend=aer_sim, optimization_level=1)
isa_qc = pm.run(qc)
with Session(backend=aer_sim) as session:
sampler = Sampler()
result = sampler.run([isa_qc]).result()

ในการ simulate แบบมี noise ให้ระบุ QPU (ฮาร์ดแวร์ควอนตัม) และส่งไปยัง Aer Aer จะสร้าง noise model จากข้อมูล calibration ของ QPU นั้นและสร้าง Aer Backend พร้อม model นั้น หากต้องการ สามารถ สร้าง noise model เองได้

ตัวอย่างแบบมี noise:

from qiskit_aer import AerSimulator
from qiskit.circuit.library import RealAmplitudes
from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.quantum_info import SparsePauliOp
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2 as Sampler

service = QiskitRuntimeService()

# Bell Circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()

# Specify a QPU to use for the noise model
real_backend = service.backend("ibm_brisbane")
aer = AerSimulator.from_backend(real_backend)

# Run the sampler job locally using AerSimulator.
pm = generate_preset_pass_manager(backend=aer, optimization_level=1)
isa_qc = pm.run(qc)
sampler = Sampler(mode=aer)
result = sampler.run([isa_qc]).result()

Clifford simulation

เนื่องจาก Clifford circuits สามารถ simulate ได้อย่างมีประสิทธิภาพพร้อมผลลัพธ์ที่ยืนยันได้ Clifford simulation จึงเป็นเครื่องมือที่มีประโยชน์มาก สำหรับตัวอย่างเชิงลึก ดู Efficient simulation of stabilizer circuits with Qiskit Aer primitives

ตัวอย่าง:

import numpy as np
from qiskit.circuit.library import EfficientSU2
from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2 as Sampler

service = QiskitRuntimeService()

n_qubits = 500 # <---- note this uses 500 qubits!
circuit = EfficientSU2(n_qubits)
circuit.measure_all()

rng = np.random.default_rng(1234)
params = rng.choice(
[0, np.pi / 2, np.pi, 3 * np.pi / 2],
size=circuit.num_parameters,
)

# Tell Aer to use the stabilizer (clifford) simulation method
aer_sim = AerSimulator(method="stabilizer")

pm = generate_preset_pass_manager(backend=aer_sim, optimization_level=1)
isa_circuit = pm.run(circuit)
sampler = Sampler(mode=aer_sim)
result = sampler.run([(isa_circuit, params)]).result()
Source: IBM Quantum docs — updated 27 เม.ย. 2569
English version on doQumentation — updated 7 พ.ค. 2569
This translation based on the English version of 11 มี.ค. 2569