Die Seite is noch nich übersetzt. Se kieken die englische Originalversion.
Deploy and run a template for electronic structure simulation with an implicit solvent model
This template, developed in collaboration with the Cleveland Clinic, consists of a workflow to calculate the ground state energy and solvation free energy of a molecule in an implicit solvent [1]. These simulations are based on the sample-based quantum diagonalization (SQD) method [2-6] and the integral equation formalism polarizable continuum model (IEF-PCM) of solvent [7].
This guide utilizes the template with a methanol molecule as the solute, the electronic structure of which is simulated explicitly, and water as the solvent, approximated as a continuous dielectric medium. To account for the electron correlation effects in methanol, while maintaining the balance between the computational cost and accuracy, we only include the , , and lone pair orbitals in the active space simulated with SQD IEF-PCM. This orbital selection is done with atomic valence active space (AVAS) method using the C[2s,2p], O[2s,2p], and H[1s] atomic orbital components, which results in the active space of 14 electrons and 12 orbitals (14e,12o). The reference orbitals are calculated with closed-shell Hartree Fock using the cc-pvdz basis set.
Workflow introduction
This interactive guide shows how to upload this function template to Qiskit Serverless and run an example workload. The template is structured as a Qiskit pattern with four steps:
1. Collect input and map the problem
This step takes the geometry of the molecule, selected active space, solvation model, LUCJ options, and SQD options as an input. It then produces the PySCF Checkpoint file, which contains the Hartree-Fock (HF) IEF-PCM data. This data will be used in the SQD portion of the workflow. For the LUCJ portion of the workflow, the input section also generates the gas-phase HF data, which is stored internally in PySCF FCIDUMP format.
The information from the HF gas-phase simulation and the definition of the active space are taken as input. Importantly, it also uses the user-defined information from the input section concerning the error suppression, number of shots, circuit transpiler optimization level, and the qubit layout.
It generates one-electron and two-electron integrals within the defined active space. The integrals are then used to perform classical CCSD calculations, which return t2 amplitudes that we use to parametrize the LUCJ circuit.
2. Optimize the circuit
The LUCJ circuit is then transpiled into an ISA circuit for the target hardware. A Sampler primitive is then instantiated with a default set of error mitigation options to manage the execution.
3. Execute the circuit
The LUCJ calculations return the bitstrings for each measurement, where these bitstrings correspond to electron configurations of the studied system. The bitstrings are then used as input for post-processing.
4. Post-process by using SQD
This final step takes the PySCF Checkpoint file containing the HF IEF-PCM information, the bitstrings representing the electron configurations predicted by LUCJ, and the user-defined SQD options selected in the input section as input. As output, it produces the SQD IEF-PCM total energy of the lowest energy batch and the corresponding solvation free energy.
Options
For this template you must specify options for generating the LUCJ circuit, and SQD run parameters.
LUCJ options
When the LUCJ quantum circuit is executed, a set of samples that represent the computational basis states from the probability distribution of the molecular system are produced. To balance the depth of the LUCJ circuit and its expressibility, the qubits corresponding to the spin orbitals with the opposite spin have the two-qubit gates applied between them when these qubits are neighbors through a single ancilla qubit. To implement this approach on IBM hardware with a heavy-hex topology, qubits that represent the spin orbitals with the same spin are connected through a line topology where each line takes a zig-zag shape due to the heavy-hex connectivity of the target hardware, while the qubits that represent the spin orbitals with the opposite spin only have a connection at every fourth qubit.
Click for more details on the required options:
The user has to provide the initial_layout array corresponding to the qubits that satisfy this zig-zag pattern in the lucj_options section of the SQD IEF-PCM function. In case of SQD IEF-PCM (14e,12o)/cc-pvdz simulations of methanol, we chose the initial qubit layout corresponding to the main diagonal of the Eagle R3 QPU. Here, the first 12 elements of the initial_layout array [0, 14, 18, 19, 20, 33, 39, 40, 41, 53, 60, 61, ...] correspond to the alpha spin orbitals. The last 12 elements [... 2, 3, 4, 15, 22, 23, 24, 34, 43, 44, 45, 54] correspond to beta spin orbitals.
Importantly, the user has to determine the number_of_shots, which corresponds to the number of measurements in the LUCJ circuit. The number of shots needs to be sufficiently large because the first step of S-CORE procedure relies on the samples in the right particle sector to obtain the initial approximation to the ground-state occupation number distribution.
The number of shots is highly system- and hardware-dependent, but non-covalent, fragment-based, and implicit solvent SQD studies suggest that one can reach the chemical accuracy by following these guidelines:
- 20,000 - 200,000 shots for systems with fewer than 16 molecular orbitals (32 spin orbitals)
- 200,000 shots for systems with 16 - 18 molecular orbitals
- 200,000 - 2,000,000 shots for systems with more than 18 molecular orbitals
The required number of shots is affected by the number of spin orbitals in the studied system and by the size of the Hilbert space corresponding to the selected active space within the studied system. Generally, instances with smaller Hilbert spaces require fewer shots. Other available LUCJ options are circuit transpiler optimization level and error suppression options. Note that these options also affect the required number of shots and the resulting accuracy.
SQD options
Important options in SQD simulations include the sqd_iterations, number_of_batches, and samples_per_batch. Generally, the lower number of samples per batch can be counteracted with more batches (number_of_batches) and more iterations of S-CORE (sqd_iterations). With more batches we can sample more variations of the configurational subspaces. Since the lowest-energy batch is taken as the solution for the ground state energy of the system, more batches can improve the results through better statistics. Additional iterations of S-CORE allow more configurations to be recovered from the original LUCJ distribution if the number of samples in the correct particle sector is low. This can allow the number of samples per batch to be reduced.
Click for more information about configuring the SQD options:
An alternative strategy is to use more samples per batch, which ensures that most of the initial LUCJ samples in right particle space are used during the S-CORE procedure, and individual subspaces encapsulate a sufficient variety of electron configurations. In turn, this reduces the number of required S-CORE steps, where only two or three iterations of SQD are needed if the number of samples per batch is large enough. However, more samples per batch results in a higher computational cost of each diagonalization step. Hence, the balance between the accuracy and computational cost in SQD simulations can be achieved by choosing sqd_iterations, number_of_batches, and samples_per_batch optimally.
The SQD IEF-PCM study shows that when three iterations of S-CORE are used, the chemical accuracy can be reached by following these guidelines:
- 600 samples per batch in methanol SQD IEF-PCM (14e,12o) simulations
- 1500 samples per batch in methylamine SQD IEF-PCM (14e,13o) simulations
- 6000 samples per batch in water SQD IEF-PCM (8e,23o) simulations
- 16000 samples per batch in ethanol SQD IEF-PCM (20e,18o) simulations
Just like the required number of shots in LUCJ, the required number of samples per batch used in S-CORE procedure is highly system- and hardware-dependent. The examples above can be used to estimate the initial point for the benchmark of required number of samples per batch. The tutorial on systematic benchmark of the required number of samples per batch can be found here.
Deploy and execute the 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
Use qiskit-ibm-catalog to authenticate to QiskitServerless with your API key (token), which can be found on the IBM Quantum Platform dashboard. This allows for the instantiation of the serverless client to upload or run the selected 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
)
Optionally, use save_account() to save your credentials in a local environment (see the Set up your IBM Cloud account guide). Note that this writes your credentials to the same file as QiskitRuntimeService.save_account():
QiskitServerless.save_account(token="YOUR_API_KEY", channel="ibm_quantum_platform", instance="INSTANCE_CRN")
If the account is saved, there is no need to provide the token to authenticate:
from qiskit_ibm_catalog import QiskitServerless
serverless = QiskitServerless()