แนะนำ Fractional Gates
ประมาณการใช้งาน: ไม่เกิน 30 วินาทีบนโปรเซสเซอร์ Heron r2 (หมายเหตุ: นี่เป็นการประมาณการเท่านั้น ระยะเวลาจริงอาจแตกต่างกัน)
พื้นหลัง
Fractional Gates บน IBM QPUs
Fractional gates คือ quantum gates แบบมีพารามิเตอร์ที่ช่วยให้สามารถรันการหมุนมุมอิสระได้โดยตรง (ภายในขอบเขตที่กำหนด) โดยไม่จำเป็นต้องแตกย่อยเป็น basis gates หลายตัว ด้วยการใช้ประโยชน์จากปฏิสัมพันธ์ของ physical qubits ผู้ใช้สามารถนำ unitary บางตัวไปใช้บนฮาร์ดแวร์ได้อย่างมีประสิทธิภาพมากขึ้น
IBM Quantum® Heron QPUs รองรับ fractional gates ดังต่อไปนี้:
- สำหรับ
- สำหรับค่าจริง ใดก็ได้
Gates เหล่านี้สามารถลดทั้งความลึกและระยะเวลาของ quantum circuits ได้อย่างมีนัยสำคัญ มีประโยชน์เป็นพิเศษในแอปพลิเคชันที่ใช้ และ อย่างหนัก เช่น Hamiltonian simulation, Quantum Approximate Optimization Algorithm (QAOA) และ quantum kernel methods ในบทแนะนำนี้ เราจะเน้นที่ quantum kernel เป็นตัวอย่างเชิงปฏิบัติ
ข้อจำกัด
Fractional gates เป็นฟีเจอร์ทดลองในปัจจุบัน และมีข้อจำกัดบางประการ:
- จำกัดมุมในช่วง
- การใช้ fractional gates ไม่รองรับสำหรับ dynamic circuits, Pauli twirling, probabilistic error cancellation (PEC) และ zero-noise extrapolation (ZNE) (โดยใช้ probabilistic error amplification (PEA))
Fractional gates ต้องใช้ workflow ที่แตกต่างจากวิธีมาตรฐาน บทแนะนำนี้จะอธิบายวิธีทำงานกับ fractional gates ผ่านแอปพลิเคชันจริง
ดูรายละเอียดเพิ่มเติมเกี่ยวกับ fractional gates ได้ที่:
ภาพรวม
Workflow สำหรับการใช้ fractional gates โดยทั่วไปจะเป็นไปตาม Qiskit patterns workflow ความแตกต่างสำคัญคือมุม RZZ ทั้งหมดต้องเป็นไปตามข้อจำกัด มีสองวิธีเพื่อให้แน่ใจว่าเงื่อนไขนี้เป็นไปตามที่กำหนด บทแนะนำนี้จะเน้นและแนะนำวิธีที่สอง
# Added by doQumentation — required packages for this notebook
!pip install -q matplotlib numpy qiskit qiskit-basis-constructor qiskit-ibm-runtime
1. สร้างค่าพารามิเตอร์ที่เป็นไปตามข้อจำกัดมุม RZZ
ถ้าคุณมั่นใจว่ามุม RZZ ทั้งหมดอยู่ในช่วงที่ถูกต้อง คุณสามารถทำตาม standard Qiskit patterns workflow ได้ ในกรณีนี้ คุณเพียงแค่ส่งค่าพารามิเตอร์เป็นส่วนหนึ่งของ PUB โดย workflow จะดำเนินการดังนี้
pm = generate_preset_pass_manager(backend=backend, ...)
t_circuit = pm.run(circuit)
t_observable = observable.apply_layout(t_circuit.layout)
sampler.run([(t_circuit, parameter_values)])
estimator.run([(t_circuit, t_observable, parameter_values)])
ถ้าคุณพยายามส่ง PUB ที่มี RZZ gate ที่มีมุมอยู่นอกช่วงที่ถูกต้อง คุณจะพบข้อความแสดงข้อผิดพลาดเช่น:
'The instruction rzz is supported only for angles in the range [0, pi/2], but an angle (20.0) outside of this range has been requested; via parameter value(s) γ[0]=10.0, substituted in parameter expression 2.0*γ[0].'
เพื่อหลีกเลี่ยงข้อผิดพลาดนี้ ควรพิจารณาใช้วิธีที่สองที่อธิบายด้านล่าง
2. กำหนดค่าพารามิเตอร์ให้ Circuit ก่อนการ Transpile
แพ็กเกจ qiskit-ibm-runtime มี transpiler pass พิเศษที่เรียกว่า FoldRzzAngle
pass นี้จะแปลง quantum circuits เพื่อให้มุม RZZ ทั้งหมดเป็นไปตามข้อจำกัดมุม RZZ
ถ้าคุณระบุ backend ให้กับ generate_preset_pass_manager หรือ transpile Qiskit จะนำ FoldRzzAngle ไปใช้กับ quantum circuits โดยอัตโนมัติ
วิธีนี้ทำให้คุณต้องกำหนดค่าพารามิเตอร์ให้กับ quantum circuits ก่อนการ transpile
โดย workflow จะดำเนินการดังนี้
pm = generate_preset_pass_manager(backend=backend, ...)
b_circuit = circuit.assign_parameters(parameter_values)
t_circuit = pm.run(b_circuit)
t_observable = observable.apply_layout(t_circuit.layout)
sampler.run([(t_circuit,)])
estimator.run([(t_circuit, t_observable)])
โปรดทราบว่า workflow นี้มีต้นทุนการคำนวณสูงกว่าวิธีแรก เนื่องจากต้องกำหนดค่าพารามิเตอร์ให้กับ quantum circuits และเก็บ circuit ที่ผูกพารามิเตอร์ไว้ในเครื่อง นอกจากนี้ยังมีปัญหาที่ทราบแล้วใน Qiskit ที่การแปลง RZZ gates อาจล้มเหลวในบางสถานการณ์ สำหรับวิธีแก้ปัญหา โปรดดูที่ส่วน Troubleshooting บทแนะนำนี้จะสาธิตวิธีใช้ fractional gates ผ่านวิธีที่สองโดยใช้ตัวอย่างที่ได้รับแรงบันดาลใจจาก quantum kernel method เพื่อทำความเข้าใจว่า quantum kernels มีแนวโน้มจะมีประโยชน์ที่ใด แนะนำให้อ่าน Liu, Arunachalam & Temme (2021).
คุณสามารถศึกษาเพิ่มเติมได้จากบทแนะนำ Quantum kernel training และบทเรียน Quantum kernels ในคอร์ส Quantum machine learning บน IBM Quantum Learning
ข้อกำหนด
ก่อนเริ่มบทแนะนำนี้ ตรวจสอบให้แน่ใจว่าคุณได้ติดตั้งสิ่งต่อไปนี้แล้ว:
- Qiskit SDK v2.0 หรือใหม่กว่า พร้อมการรองรับ visualization
- Qiskit Runtime v0.37 หรือใหม่กว่า (
pip install qiskit-ibm-runtime) - Qiskit Basis Constructor (
pip install qiskit_basis_constructor)
การตั้งค่า
import matplotlib.pyplot as plt
import numpy as np
from qiskit import QuantumCircuit, generate_preset_pass_manager
from qiskit.circuit import ParameterVector
from qiskit.circuit.library import unitary_overlap
from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2
เปิดใช้งาน Fractional Gates และตรวจสอบ Basis Gates
ในการใช้ fractional gates คุณสามารถรับ backend ที่รองรับได้โดยตั้งค่า option use_fractional_gates=True
ถ้า backend รองรับ fractional gates คุณจะเห็น rzz และ rx อยู่ใน basis gates ของมัน
service = QiskitRuntimeService()
backend = service.least_busy(
operational=True, simulator=False, min_num_qubits=133
) # backend should be a heron device or later
backend_name = backend.name
backend_c = service.backend(backend_name) # w/o fractional gates
backend_f = service.backend(
backend_name, use_fractional_gates=True
) # w/ fractional gates
print(f"Backend: {backend_name}")
print(f"No fractional gates: {backend_c.basis_gates}")
print(f"With fractional gates: {backend_f.basis_gates}")
if "rzz" not in backend_f.basis_gates:
print(f"Backend {backend_name} does not support fractional gates")
Backend: ibm_fez
No fractional gates: ['cz', 'id', 'rz', 'sx', 'x']
With fractional gates: ['cz', 'id', 'rx', 'rz', 'rzz', 'sx', 'x']
Workflow กับ Fractional Gates
ขั้นตอนที่ 1: แมปข้อมูล Classical ไปยังปัญหา Quantum
Quantum Kernel Circuit
ในส่วนนี้ เราจะสำรวจ quantum kernel circuit ที่ใช้ RZZ gates เพื่อแนะนำ workflow สำหรับ fractional gates
เราเริ่มด้วยการสร้าง quantum circuit เพื่อคำนวณรายการแต่ละตัวของ kernel matrix โดยการรวม ZZ feature map circuits กับ unitary overlap ฟังก์ชัน kernel รับเวกเตอร์ในพื้นที่ feature-mapped และส่งคืนผลคูณภายในของพวกมันเป็นรายการของ kernel matrix: โดยที่ แทน quantum state ที่ถูก feature-mapped
เราสร้าง ZZ feature map circuit ด้วยตนเองโดยใช้ RZZ gates
แม้ว่า Qiskit จะมี zz_feature_map ในตัว แต่ปัจจุบันยังไม่รองรับ RZZ gates ใน Qiskit v2.0.2 (ดู issue)
ต่อมา เราคำนวณฟังก์ชัน kernel สำหรับ input ที่เหมือนกัน — ตัวอย่างเช่น บน quantum computers ที่มีสัญญาณรบกวน ค่านี้อาจน้อยกว่า 1 เนื่องจากสัญญาณรบกวน ผลลัพธ์ที่ใกล้ 1 บ่งชี้ว่ามีสัญญาณรบกวนน้อยกว่าในการรัน ในบทแนะนำนี้ เราเรียกค่านี้ว่า fidelity ซึ่งนิยามว่า
optimization_level = 2
shots = 2000
reps = 3
rng = np.random.default_rng(seed=123)
def my_zz_feature_map(num_qubits: int, reps: int = 1) -> QuantumCircuit:
x = ParameterVector("x", num_qubits * reps)
qc = QuantumCircuit(num_qubits)
qc.h(range(num_qubits))
for k in range(reps):
K = k * num_qubits
for i in range(num_qubits):
qc.rz(x[i + K], i)
pairs = [(i, i + 1) for i in range(num_qubits - 1)]
for i, j in pairs[0::2] + pairs[1::2]:
qc.rzz((np.pi - x[i + K]) * (np.pi - x[j + K]), i, j)
return qc
def quantum_kernel(num_qubits: int, reps: int = 1) -> QuantumCircuit:
qc = my_zz_feature_map(num_qubits, reps=reps)
inner_product = unitary_overlap(qc, qc, "x", "y", insert_barrier=True)
inner_product.measure_all()
return inner_product
def random_parameters(inner_product: QuantumCircuit) -> np.ndarray:
return np.tile(rng.random(inner_product.num_parameters // 2), 2)
def fidelity(result) -> float:
ba = result.data.meas
return ba.get_int_counts().get(0, 0) / ba.num_shots
Quantum kernel circuits และค่าพารามิเตอร์ที่สอดคล้องกันถูกสร้างขึ้นสำหรับระบบที่มี 4 ถึง 40 qubits และ fidelity ของพวกมันจะถูกประเมินในภายหลัง
qubits = list(range(4, 44, 4))
circuits = [quantum_kernel(i, reps=reps) for i in qubits]
params = [random_parameters(circ) for circ in circuits]
Circuit สี่ Qubit แสดงให้เห็นด้านล่าง
circuits[0].draw("mpl", fold=-1)

ใน standard Qiskit patterns workflow ค่าพารามิเตอร์โดยทั่วไปจะถูกส่งไปยัง Sampler หรือ Estimator primitive เป็นส่วนหนึ่งของ PUB อย่างไรก็ตาม เมื่อใช้ backend ที่รองรับ fractional gates ค่าพารามิเตอร์เหล่านี้จะต้องถูกกำหนดให้กับ quantum circuit อย่างชัดเจนก่อนการ transpile
b_qc = [
circ.assign_parameters(param) for circ, param in zip(circuits, params)
]
b_qc[0].draw("mpl", fold=-1)

ขั้นตอนที่ 2: ปรับปัญหาให้เหมาะสมสำหรับการรันบน Quantum Hardware
จากนั้นเรา transpile circuit โดยใช้ pass manager ตาม standard Qiskit pattern
การระบุ backend ที่รองรับ fractional gates ให้กับ generate_preset_pass_manager จะทำให้ pass พิเศษที่ชื่อ FoldRzzAngle ถูกรวมไว้โดยอัตโนมัติ
pass นี้จะแก้ไข circuit ให้เป็นไปตามข้อจำกัดมุม RZZ
ผลลัพธ์คือ RZZ gates ที่มีค่าลบในรูปก่อนหน้าจะถูกแปลงเป็นค่าบวก และ X gates บางตัวจะถูกเพิ่มเข้ามา
backend_f = service.backend(name=backend_name, use_fractional_gates=True)
# pm_f includes `FoldRzzAngle` pass
pm_f = generate_preset_pass_manager(
optimization_level=optimization_level, backend=backend_f
)
t_qc_f = pm_f.run(b_qc)
print(t_qc_f[0].count_ops())
t_qc_f[0].draw("mpl", fold=-1)
OrderedDict([('rz', 35), ('rzz', 18), ('x', 13), ('rx', 9), ('measure', 4), ('barrier', 2)])

เพื่อประเมินผลกระทบของ fractional gates เราวัดจำนวน non-local gates (CZ และ RZZ สำหรับ backend นี้) พร้อมกับความลึกและระยะเวลาของ circuit และเปรียบเทียบตัวชี้วัดเหล่านี้กับ workflow มาตรฐานในภายหลัง
nnl_f = [qc.num_nonlocal_gates() for qc in t_qc_f]
depth_f = [qc.depth() for qc in t_qc_f]
duration_f = [
qc.estimate_duration(backend_f.target, unit="u") for qc in t_qc_f
]
ขั้นตอนที่ 3: รันโดยใช้ Qiskit Primitives
เรารัน transpiled circuit กับ backend ที่รองรับ fractional gates
sampler_f = SamplerV2(mode=backend_f)
sampler_f.options.dynamical_decoupling.enable = True
sampler_f.options.dynamical_decoupling.sequence_type = "XY4"
sampler_f.options.dynamical_decoupling.skip_reset_qubits = True
job = sampler_f.run(t_qc_f, shots=shots)
print(job.job_id())
d4bninsi51bc738j97eg
ขั้นตอนที่ 4: ประมวลผลหลังการรันและคืนผลในรูปแบบ Classical ที่ต้องการ
คุณสามารถรับค่าฟังก์ชัน kernel ได้โดยการวัดความน่าจะเป็นของ all-zero bitstring 00...00 ในผลลัพธ์
# job = service.job("d1obougt0npc73flhiag")
result = job.result()
fidelity_f = [fidelity(result=res) for res in result]
print(fidelity_f)
usage_f = job.usage()
[0.9005, 0.647, 0.3345, 0.355, 0.3315, 0.174, 0.1875, 0.149, 0.1175, 0.085]
การเปรียบเทียบ Workflow และ Circuit โดยไม่มี Fractional Gates
ในส่วนนี้ เราจะนำเสนอ standard Qiskit patterns workflow โดยใช้ backend ที่ไม่รองรับ fractional gates การเปรียบเทียบ transpiled circuits จะทำให้เห็นว่า circuit ที่ใช้ fractional gates (จากส่วนก่อนหน้า) กระชับกว่า circuit ที่ไม่ใช้
# step 1: map classical inputs to quantum problem
# `circuits` and `params` from the previous section are reused here
# step 2: optimize circuits
backend_c = service.backend(backend_name) # w/o fractional gates
pm_c = generate_preset_pass_manager(
optimization_level=optimization_level, backend=backend_c
)
t_qc_c = pm_c.run(circuits)
print(t_qc_c[0].count_ops())
t_qc_c[0].draw("mpl", fold=-1)
OrderedDict([('rz', 130), ('sx', 80), ('cz', 36), ('measure', 4), ('barrier', 2)])

nnl_c = [qc.num_nonlocal_gates() for qc in t_qc_c]
depth_c = [qc.depth() for qc in t_qc_c]
duration_c = [
qc.estimate_duration(backend_c.target, unit="u") for qc in t_qc_c
]
# step 3: execute
sampler_c = SamplerV2(backend_c)
sampler_c.options.dynamical_decoupling.enable = True
sampler_c.options.dynamical_decoupling.sequence_type = "XY4"
sampler_c.options.dynamical_decoupling.skip_reset_qubits = True
job = sampler_c.run(pubs=zip(t_qc_c, params), shots=shots)
print(job.job_id())
d4bnirvnmdfs73ae3a2g
# step 4: post-processing
# job = service.job("d1obp8j3rr0s73bg4810")
result = job.result()
fidelity_c = [fidelity(res) for res in result]
print(fidelity_c)
usage_c = job.usage()
[0.6675, 0.5725, 0.098, 0.102, 0.065, 0.0235, 0.006, 0.0015, 0.0015, 0.002]
การเปรียบเทียบความลึกและ Fidelity
ในส่วนนี้ เราเปรียบเทียบจำนวน non-local gates และ fidelity ระหว่าง circuit ที่มีและไม่มี fractional gates ซึ่งแสดงให้เห็นถึงประโยชน์ที่อาจได้รับจากการใช้ fractional gates ในแง่ของประสิทธิภาพและคุณภาพการรัน
plt.plot(qubits, depth_c, "-o", label="no fractional gates")
plt.plot(qubits, depth_f, "-o", label="with fractional gates")
plt.xlabel("number of qubits")
plt.ylabel("depth")
plt.title("Comparison of depths")
plt.grid()
plt.legend()
<matplotlib.legend.Legend at 0x12bcaac50>
plt.plot(qubits, duration_c, "-o", label="no fractional gates")
plt.plot(qubits, duration_f, "-o", label="with fractional gates")
plt.xlabel("number of qubits")
plt.ylabel("duration (µs)")
plt.title("Comparison of durations")
plt.grid()
plt.legend()
<matplotlib.legend.Legend at 0x12bdef310>
plt.plot(qubits, nnl_c, "-o", label="no fractional gates")
plt.plot(qubits, nnl_f, "-o", label="with fractional gates")
plt.xlabel("number of qubits")
plt.ylabel("number of non-local gates")
plt.title("Comparison of numbers of non-local gates")
plt.grid()
plt.legend()
<matplotlib.legend.Legend at 0x12be8ac90>
plt.plot(qubits, fidelity_c, "-o", label="no fractional gates")
plt.plot(qubits, fidelity_f, "-o", label="with fractional gates")
plt.xlabel("number of qubits")
plt.ylabel("fidelity")
plt.title("Comparison of fidelities")
plt.grid()
plt.legend()
<matplotlib.legend.Legend at 0x12bea8290>
เราเปรียบเทียบเวลาการใช้งาน QPU ทั้งที่มีและไม่มี fractional gates ผลลัพธ์ในเซลล์ต่อไปนี้แสดงให้เห็นว่าเวลาการใช้งาน QPU แทบจะเหมือนกัน
print(f"no fractional gates: {usage_c} seconds")
print(f"fractional gates: {usage_f} seconds")
no fractional gates: 7 seconds
fractional gates: 7 seconds
หัวข้อขั้นสูง: ใช้เฉพาะ fractional RX gates
ความจำเป็นในการปรับเปลี่ยนขั้นตอนการทำงานเมื่อใช้ fractional gates ส่วนใหญ่เกิดจากข้อจำกัดเรื่องมุมของ RZZ gate อย่างไรก็ตาม ถ้าใช้เฉพาะ fractional RX gates และไม่รวม fractional RZZ gates คุณสามารถทำตามขั้นตอน Qiskit patterns แบบมาตรฐานได้ต่อไป แนวทางนี้ยังให้ประโยชน์ที่มีนัยสำคัญ โดยเฉพาะกับ Circuit ที่มี RX gates และ U gates จำนวนมาก เพราะช่วยลดจำนวน gate โดยรวมและอาจปรับปรุงประสิทธิภาพได้ ในส่วนนี้ จะแสดงวิธีเพิ่มประสิทธิภาพ Circuit โดยใช้เฉพาะ fractional RX gates และละเว้น RZZ gates
เพื่อรองรับสิ่งนี้ เราจัดเตรียมฟังก์ชันอรรถประโยชน์ที่ให้คุณปิดใช้งาน basis gate เฉพาะในออบเจ็กต์ Target ได้ ที่นี่ เราใช้มันเพื่อปิดใช้งาน RZZ gates
from qiskit.circuit.library import n_local
from qiskit.transpiler import Target
def remove_instruction_from_target(target: Target, gate_name: str) -> Target:
new_target = Target(
description=target.description,
num_qubits=target.num_qubits,
dt=target.dt,
granularity=target.granularity,
min_length=target.min_length,
pulse_alignment=target.pulse_alignment,
acquire_alignment=target.acquire_alignment,
qubit_properties=target.qubit_properties,
concurrent_measurements=target.concurrent_measurements,
)
for name, qarg_map in target.items():
if name == gate_name:
continue
instruction = target.operation_from_name(name)
if qarg_map == {None: None}:
qarg_map = None
new_target.add_instruction(instruction, qarg_map, name=name)
return new_target
เราใช้ Circuit ที่ประกอบด้วย U, CZ, และ RZZ gates เป็นตัวอย่าง
qc = n_local(3, "u", "cz", "linear", reps=1)
qc.rzz(1.1, 0, 1)
qc.draw("mpl")
เราทำการ transpile Circuit สำหรับ Backend ที่ไม่รองรับ fractional gates ก่อน
pm_c = generate_preset_pass_manager(
optimization_level=optimization_level, backend=backend_c
)
t_qc = pm_c.run(qc)
print(t_qc.count_ops())
t_qc.draw("mpl")
OrderedDict([('rz', 23), ('sx', 16), ('cz', 4)])

จากนั้น เราทำการ transpile Circuit เดิมโดยใช้ fractional RX gates แต่ไม่รวม RZZ gates ผลลัพธ์คือจำนวน gate โดยรวมลดลงเล็กน้อย ด้วยการใช้งาน RX gates ที่มีประสิทธิภาพมากขึ้น
backend_f = service.backend(backend_name, use_fractional_gates=True)
target = remove_instruction_from_target(backend_f.target, "rzz")
pm_f = generate_preset_pass_manager(
optimization_level=optimization_level,
target=target,
)
t_qc = pm_f.run(qc)
print(t_qc.count_ops())
t_qc.draw("mpl")
OrderedDict([('rz', 22), ('sx', 14), ('cz', 4), ('rx', 1)])

เพิ่มประสิทธิภาพ U gates ด้วย fractional RX gates
ในส่วนนี้ จะแสดงวิธีเพิ่มประสิทธิภาพ U gates โดยใช้ fractional RX gates ต่อจาก Circuit เดียวกับที่แนะนำในส่วนก่อนหน้า
คุณต้องติดตั้งแพ็กเกจ qiskit-basis-constructor package สำหรับส่วนนี้
นี่คือเวอร์ชัน beta ของ transpilation plugin ใหม่สำหรับ Qiskit ซึ่งอาจถูกรวมเข้าใน Qiskit ในอนาคต
# %pip install qiskit-basis-constructor
from qiskit.circuit.library import UGate
from qiskit_basis_constructor import DEFAULT_EQUIVALENCE_LIBRARY
เราทำการ transpile Circuit โดยใช้เฉพาะ fractional RX gates ไม่รวม RZZ gates ด้วยการแนะนำกฎการ decomposition แบบกำหนดเอง ดังที่แสดงด้านล่าง เราสามารถลดจำนวน single-qubit gates ที่จำเป็นสำหรับการ implement U gate ได้
ฟีเจอร์นี้กำลังอยู่ระหว่างการหารือใน GitHub issue นี้
# special decomposition rule for UGate
x = ParameterVector("x", 3)
zxz = QuantumCircuit(1)
zxz.rz(x[2] - np.pi / 2, 0)
zxz.rx(x[0], 0)
zxz.rz(x[1] + np.pi / 2, 0)
DEFAULT_EQUIVALENCE_LIBRARY.add_equivalence(UGate(x[0], x[1], x[2]), zxz)
ต่อไป เราใช้ Transpiler โดยใช้การแปล constructor-beta ที่ให้มาจากแพ็กเกจ qiskit-basis-constructor
ผลลัพธ์คือจำนวน gate โดยรวมลดลงเมื่อเทียบกับการ transpile ครั้งก่อน
pm_f = generate_preset_pass_manager(
optimization_level=optimization_level,
target=target,
translation_method="constructor-beta",
)
t_qc = pm_f.run(qc)
print(t_qc.count_ops())
t_qc.draw("mpl")
OrderedDict([('rz', 16), ('rx', 9), ('cz', 4)])
การแก้ไขปัญหา
ปัญหา: มุม RZZ ที่ไม่ถูกต้องอาจยังคงอยู่หลังการ transpile
ณ Qiskit v2.0.3 มีปัญหาที่ทราบกันดีที่ RZZ gates ที่มีมุมไม่ถูกต้องอาจยังคงอยู่ใน Circuit แม้หลังการ transpile แล้ว ปัญหานี้มักเกิดขึ้นภายใต้เงื่อนไขต่อไปนี้
ความล้มเหลวเมื่อใช้ตัวเลือก target กับ generate_preset_pass_manager หรือ transpiler
เมื่อใช้ตัวเลือก target กับ generate_preset_pass_manager หรือ transpiler transpiler pass เฉพาะ FoldRzzAngle จะไม่ถูกเรียกใช้
เพื่อให้มั่นใจว่า RZZ angles ถูกจัดการอย่างถูกต้องสำหรับ fractional gates เราแนะนำให้ใช้ตัวเลือก backend เสมอแทน
ดู issue นี้ สำหรับรายละเอียดเพิ่มเติม
ความล้มเหลวเมื่อ Circuit มี gates บางตัว
ถ้า Circuit ของคุณมี gates บางตัว เช่น XXPlusYYGate Qiskit Transpiler อาจสร้าง RZZ gates ที่มีมุมไม่ถูกต้อง
ถ้าคุณพบปัญหานี้ ดู GitHub issue นี้สำหรับวิธีแก้ปัญหา
แบบสำรวจ tutorial
Note: This survey is provided by IBM Quantum and relates to the original English content. To give feedback on doQumentation's website, translations, or code execution, please open a GitHub issue.
กรุณาทำแบบสำรวจสั้นๆ นี้เพื่อให้ข้อเสนอแนะเกี่ยวกับ tutorial นี้ ข้อมูลเชิงลึกของคุณจะช่วยให้เราปรับปรุงเนื้อหาและประสบการณ์ผู้ใช้