Skip to main content

HI-VQE Qiskit Function Utilities

This package is intended to provide some utilities to help users of Qunova's HI-VQE Qiskit Function.

Current Features

Helps licensed users submit their license token to the function with encryption.

The below example shows how this package can be used to wrap the HI-VQE Qiskit Function retrieved from the Qiskit IBM Catalog to properly submit your token:

import math
import h5py
from qiskit_ibm_catalog import QiskitFunctionsCatalog, QiskitServerless
from hivqe_qiskit_function_utils import FunctionWrapper


catalog = QiskitFunctionsCatalog(token="your_qiskit_functions_catalog_token", 
                                 channel="ibm_quantum_platform", 
                                 instance="your_ibm_instance")

serverless = QiskitServerless(token="your_qiskit_functions_catalog_token", 
                              channel="ibm_quantum_platform", 
                              instance="your_ibm_instance")

molecule_geometry = f"""
O 0 0 0;
H {-0.957*math.sin(math.radians(104.5)/2.0)} {0.957*math.cos(math.radians(104.5)/2.0)} 0;
H {0.957*math.sin(math.radians(104.5)/2.0)} {0.957*math.cos(math.radians(104.5)/2.0)} 0
"""

hivqe = FunctionWrapper(token="your_hivqe_license_token", 
                        function=catalog.load("qunova/hivqe-chemistry"))

job = hivqe.run(
    geometry=molecule_geometry,
    backend_name="ibm_torino",
    max_states=10000,
    max_expansion_states=1000,
    hivqe_options={"ansatz": "epa", "max_iter": 10},
)

result = job.result()

# Extract the results
energy = result["energy"]
results_file_name = result["results_file_name"]
energy_variance = result["energy_variance"]
total_energy_history = result["energy_history"]

# Download the h5 results file to the current directory
serverless.file_download(results_file_name, 
                         catalog.load("qunova/hivqe-chemistry"))

# Read all data from the results file
with h5py.File(results_file_name, "r") as f:
    states = f["states"][:]
    eigenvector = f["eigenvector"][:]
    energy_history = f["energy_history"][:]
    final_energy = f["final_energy"][0]
    final_energy_variance = f["final_energy_variance"][0]

# Check the logs
logs = job.logs()

Metadata

Release files for hivqe-qiskit-function-utils 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for hivqe-qiskit-function-utils 0.3.0
File Interpreter ABI Platform
hivqe_qiskit_function_utils-0.3.0-py3-none-any.whl Python 3 none any Details

Release files / hivqe_qiskit_function_utils-0.3.0-py3-none-any.whl

Download URL hivqe_qiskit_function_utils-0.3.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48c5b9174f02b2f72a60825dbcf5fdf856962350c411cec484f6e6ebd7f9387b
BLAKE2b-256 checksum
How to use checksums
14628263e92f6d3d8e8d294cdd695e478d0ea31ae83a9f5fcbb011e526c5348e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 release file

0.2.1

1 release file

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page