Deploy และรัน template สำหรับการจำลองโครงสร้างอิเ ล็กทรอนิกส์ด้วยโมเดล implicit solvent
Template นี้ พัฒนาขึ้นร่วมกับ Cleveland Clinic ประกอบด้วย workflow สำหรับคำนวณพลังงาน ground state และ solvation free energy ของโมเลกุลใน implicit solvent [1] การจำลองเหล่านี้อิงตามวิธี sample-based quantum diagonalization (SQD) [2-6] และโมเดล integral equation formalism polarizable continuum model (IEF-PCM) ของ solvent [7]
คู่มือนี้ใช้ template กับโมเลกุล methanol เป็น solute ซึ่งโครงสร้างอิเล็กทรอนิกส์ถูกจำลองอย่างชัดเจน และน้ำเป็น solvent ที่ประมาณเป็น continuous dielectric medium เพื่อคำนึงถึง electron correlation effects ใน methanol ในขณะที่รักษาสมดุลระหว่างต้นทุนการคำนวณและความแม่นยำ เราจะรวมเฉพาะออร์บิทัล , และ lone pair ใน active space ที่จำลองด้วย SQD IEF-PCM การเลือกออร์บิทัลนี้ทำด้วย atomic valence active space (AVAS) method โดยใช้ส่วนประกอบ atomic orbital C[2s,2p], O[2s,2p] และ H[1s] ซึ่งให้ผล active space 14 อิเล็กตรอนและ 12 ออร์บิทัล (14e,12o) ออร์บิทัลอ้างอิงคำนวณด้วย closed-shell Hartree Fock โดยใช้ basis set cc-pvdz
บทนำ Workflow
คู่มือแบบโต้ตอบนี้แสดงวิธีอัปโหลด function template นี้ไปยัง Qiskit Serverless และรัน workload ตัวอย่าง template มีโครงสร้างเป็น Qiskit pattern สี่ขั้นตอน:
1. รวบรวม input และ map ปัญหา
ขั้นตอนนี้รับ geometry ของโมเลกุล, active space ที่เลือก, โมเดล solvation, LUCJ options และ SQD options เป็น input จากนั้นสร้างไฟล์ PySCF Checkpoint ซึ่งประกอบด้วยข้อมูล Hartree-Fock (HF) IEF-PCM ข้อมูลนี้จะถูกใช้ในส่วน SQD ของ workflow สำหรับส่วน LUCJ ของ workflow ส่วน input ยังสร้างข้อมูล HF gas-phase ซึ่งเก็บไว้ภายในในรูปแบบ PySCF FCIDUMP
ข้อมูลจากการจำลอง HF gas-phase และนิยามของ active space ถูกนำมาใช้เป็น input สิ่งสำคัญคือ ยังใช้ข้อมูลที่ผู้ใช้กำหนดจากส่วน input เกี่ยวกับการ error suppression, จำนวน shots, ระดับการ optimize ของ Circuit Transpiler และ qubit layout
ขั้นตอนนี้สร้าง one-electron และ two-electron integrals ภายใน active space ที่กำหนด จากนั้น integrals เหล่านี้จะถูกใช้ในการคำนวณ CCSD แบบ classical ซึ่งคืนค่า t2 amplitudes ที่เราใ ช้ในการ parametrize LUCJ Circuit
2. Optimize Circuit
จากนั้น LUCJ Circuit จะถูก transpile เป็น ISA circuit สำหรับ hardware เป้าหมาย จากนั้น Sampler primitive จะถูก instantiate พร้อม error mitigation options ชุดเริ่มต้นเพื่อจัดการการรัน
3. รัน Circuit
การคำนวณ LUCJ คืน bitstrings สำหรับการวัดแต่ละครั้ง ซึ่ง bitstrings เหล่านี้สอดคล้องกับ electron configurations ของระบบที่ศึกษา จากนั้น bitstrings จะถูกใช้เป็น input สำหรับ post-processing
4. Post-process ด้วย SQD
ขั้นตอนสุดท้ายนี้รับไฟล์ PySCF Checkpoint ที่ประกอบด้วยข้อมูล HF IEF-PCM, bitstrings ที่แสดง electron configurations ที่ LUCJ ทำนาย และ SQD options ที่ผู้ใช้กำหนดในส่วน input เป็น input ผลลัพธ์คือ SQD IEF-PCM total energy ของ batch ที่มีพลังงานต่ำสุดและ solvation free energy ที่สอดคล้องกัน
Options
สำหรับ template นี้ คุณต้องระบุ options สำหรับการสร้าง LUCJ Circuit และ SQD run parameters
LUCJ options
เมื่อ LUCJ quantum Circuit รัน จะสร้างชุด samples ที่แสดง computational basis states จาก probability distribution ของระบบโมเลกุล เพื่อสร้างสมดุลระหว่างความลึกของ LUCJ Circuit และการแสดงออก qubits ที่สอดคล้องกับ spin orbitals ที่มี spin ตรงข้ามจะมี two-qubit gates ที่ถูก apply ระหว่างพวกมันเมื่อ qubits เหล่านี้เป็นเพื่อนบ้านผ่าน ancilla qubit เดียว เพื่อ implement แนวทางนี้บน IBM hardware ที่มี heavy-hex topology, qubits ที่แสดง spin orbitals ที่มี spin เหมือนกันจะเชื่อมต่อผ่าน line topology ที่แต่ละ line มีรูปร่าง zig-zag เนื่องจาก heavy-hex connectivity ของ hardware เป้าหมาย ในขณะที่ qubits ที่แสดง spin orbitals ที่มี spin ตรงข้ามมีการเชื่อมต่อเฉพาะทุก ๆ สี่ qubit
คลิกเพื่อดูรายละเอียดเพิ่มเติมเกี่ยวกับ options ที่จำเป็น:
ผู้ใช้ต้องระบุ array initial_layout ที่สอดคล้องกับ qubits ที่เป็นไปตาม zig-zag pattern ในส่วน lucj_options ของฟังก์ชัน SQD IEF-PCM ในกรณีของการจำลอง SQD IEF-PCM (14e,12o)/cc-pvdz ของ methanol เราเลือก initial qubit layout ที่สอดคล้องกับ main diagonal ของ Eagle R3 QPU โดยที่ 12 องค์ประกอบแรกของ array initial_layout คือ [0, 14, 18, 19, 20, 33, 39, 40, 41, 53, 60, 61, ...] สอดคล้องกับ alpha spin orbitals และ 12 องค์ประกอบสุดท้าย [... 2, 3, 4, 15, 22, 23, 24, 34, 43, 44, 45, 54] สอดคล้องกับ beta spin orbitals
สิ่งสำคัญคือ ผู้ใช้ต้องกำหนด number_of_shots ซึ่งสอดคล้องกับจำนวนการวัดใน LUCJ Circuit จำนวน shots ต้องมากพอเพราะขั้นตอนแรกของ S-CORE procedure อาศัย samples ใน particle sector ที่ถูกต้องเพื่ อรับค่าประมาณเริ่มต้นของ ground-state occupation number distribution
จำนวน shots ขึ้นอยู่กับระบบและ hardware มาก แต่การศึกษา SQD แบบ non-covalent, fragment-based และ implicit solvent แสดงให้เห็นว่าสามารถบรรลุความแม่นยำทางเคมีได้โดยทำตามแนวทางเหล่านี้:
- 20,000 - 200,000 shots สำหรับระบบที่มี molecular orbitals น้อยกว่า 16 (32 spin orbitals)
- 200,000 shots สำหรับระบบที่มี 16 - 18 molecular orbitals
- 200,000 - 2,000,000 shots สำหรับระบบที่มี molecular orbitals มากกว่า 18
จำนวน shots ที่ต้องการได้รับผลกระทบจากจำนวน spin orbitals ในระบบที่ศึกษาและขนาดของ Hilbert space ที่สอดคล้องกับ active space ที่เลือกภายในระบบที่ศึกษา โดยทั่วไป instances ที่มี Hilbert space ขนาดเล็กกว่าต้องการ shots น้อยกว่า LUCJ options อื่น ๆ ที่มีให้ได้แก่ circuit transpiler optimization level และ error suppression options โปรดทราบว่า options เหล่านี้ยังส่งผลต่อจำนวน shots ที่ต้องการและความแม่นยำของผลลัพธ์
SQD options
Options สำคัญในการจำลอง SQD ได้แก่ sqd_iterations, number_of_batches และ samples_per_batch โดยทั่วไป จำนวน samples per batch ที่น้อยลงสามารถชดเชยได้ด้วย batches มากขึ้น (number_of_batches) และ iterations ของ S-CORE มากขึ้น (sqd_iterations) ด้วย batches มากขึ้น เราสามารถ sample variations ของ configurational subspaces ได้มากขึ้น เนื่องจาก batch ที่มีพลังงานต่ำสุดถูกนำมาเป็นผลลัพธ์สำหรับ ground state energy ของระบบ batches มากขึ้นสามารถปรับปรุงผลลัพธ์ผ่านสถิติที่ดีขึ้น iterations เพิ่มเติมของ S-CORE ช่วยให้สามารถ recover configurations เพิ่มเติมจาก LUCJ distribution เดิมได้หาก samples จำนวนน้อยอยู่ใน particle sector ที่ถูกต้อง ซึ่งช่วยลดจำนวน samples per batch ได้
คลิกเพื่อดูข้อมูลเพิ่มเติมเกี่ยวกับการกำหนดค่า SQD options:
กลยุทธ์อีกทางหนึ่งคือการใช้ samples per batch มากขึ้น ซึ่งทำให้มั่นใจว่า LUCJ samples ส่วนใหญ่ใน particle space ที่ถูกต้องถูกใช้ในระหว่าง S-CORE procedure และ subspaces แต่ละอันครอบคลุม electron configurations ที่หลากหลายเพียงพอ ซึ่งช่วยลดจำนวน S-CORE steps ที่ต้องการ โดยต้องการ iterations ของ SQD เพียงสองหรือสามครั้งหาก samples per batch มากพอ อย่างไรก็ตาม samples per batch มากขึ้นส่งผลให้ต้นทุนการคำนวณของแต่ละขั้นตอน diagonalization สูงขึ้น ดังนั้น ความสมดุลระหว่างความแม่นยำและต้นทุนการคำนวณในการจำลอง SQD สามารถทำได้โดยเลือก sqd_iterations, number_of_batches และ samples_per_batch อย่างเหมาะสมที่สุด
การศึกษา SQD IEF-PCM แสดงให้เห็นว่าเมื่อใช้ S-CORE สาม iterations สามารถบรรลุความแม่นยำทางเคมีได้โดยทำตามแนวทางเหล่านี้:
- 600 samples per batch ใ นการจำลอง methanol SQD IEF-PCM (14e,12o)
- 1500 samples per batch ในการจำลอง methylamine SQD IEF-PCM (14e,13o)
- 6000 samples per batch ในการจำลอง water SQD IEF-PCM (8e,23o)
- 16000 samples per batch ในการจำลอง ethanol SQD IEF-PCM (20e,18o)
เช่นเดียวกับจำนวน shots ที่ต้องการใน LUCJ จำนวน samples per batch ที่ต้องการใช้ใน S-CORE procedure ขึ้นอยู่กับระบบและ hardware มาก ตัวอย่างข้างต้นสามารถใช้เพื่อประมาณจุดเริ่มต้นสำหรับ benchmark ของจำนวน samples per batch ที่ต้องการ บทแนะนำเกี่ยวกับ systematic benchmark ของจำนวน samples per batch ที่ต้องการสามารถดูได้ ที่นี่
Deploy และรัน template SQD IEF-PCM function
# Added by doQumentation — required packages for this notebook
!pip install -q ffsim numpy pyscf qiskit qiskit-addon-sqd qiskit-ibm-catalog qiskit-ibm-runtime qiskit-serverless solve-solvent
Authentication
ใช้ qiskit-ibm-catalog เพื่อ authenticate ไ ปยัง QiskitServerless ด้วย API key (token) ของคุณ ซึ่งสามารถหาได้บน dashboard ของ IBM Quantum Platform ซึ่งช่วยให้สามารถ instantiate serverless client เพื่ออัปโหลดหรือรัน function ที่เลือก:
from qiskit_ibm_catalog import QiskitServerless
serverless = QiskitServerless(
channel="ibm_quantum_platform",
instance="INSTANCE_CRN",
token="YOUR_API_KEY" # Use the 44-character API_KEY you created and saved from the IBM Quantum Platform Home dashboard
)
หรือจะใช้ save_account() เพื่อบันทึก credentials ของคุณในสภาพแวดล้อม local (ดูคู่มือการตั้งค่า IBM Cloud account) โปรดทราบว่านี่จะเขียน credentials ของคุณลงใน ไฟล์เดียวกับ QiskitRuntimeService.save_account():
QiskitServerless.save_account(token="YOUR_API_KEY", channel="ibm_quantum_platform", instance="INSTANCE_CRN")
ถ้าบัญชีถูกบันทึกไว้แล้ว ไม่จำเป็นต้องระบ ุ token เพื่อ authenticate:
from qiskit_ibm_catalog import QiskitServerless
serverless = QiskitServerless()
อัปโหลด template
เพื่ออัปโหลด Qiskit Function แบบ custom คุณต้อง instantiate object QiskitFunction ที่กำหนด source code ของ function ก่อน title จะช่วยให้คุณระบุ function ได้เมื่ออยู่ใน remote cluster จุดเข้าหลักคือไฟล์ที่ประกอบด้วย if __name__ == "__main__" ถ้า workflow ของคุณต้องการไฟล์ source เพิ่มเติม คุณสามารถกำหนด working directory ที่จะถูกอัปโหลดพร้อมกับ entry point
from qiskit_ibm_catalog import QiskitFunction
template = QiskitFunction(
title="sqd_pcm_template",
entrypoint="sqd_pcm_entrypoint.py",
working_dir="./source_files/", # all files in this directory will be uploaded
dependencies=[
"ffsim==0.0.54",
"pyscf==2.9.0",
"qiskit_addon_sqd==0.10.0",
],
)
print(template)
QiskitFunction(sqd_pcm_template)
เมื่อ instance พร้อมแล้ว ให้อัปโหลดไปยัง serverless:
serverless.upload(template)
QiskitFunction(sqd_pcm_template)
เพื่อตรวจสอบว่า program อัปโหลดสำเร็จหรือไม่ ให้ใช้ serverless.list():
serverless.list()
[QiskitFunction(sqd_pcm_template),
QiskitFunction(hamiltonian_simulation_template)]