Skip to content

Commit

Permalink
Merge pull request #37 from isi-usc-edu/max-radin/overlaps
Browse files Browse the repository at this point in the history
Updating LRE script to allow for overlaps to be specified per task
  • Loading branch information
jp7745 authored Dec 4, 2024
2 parents d1f1260 + d5dd19d commit 92361ae
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ Contact the repository maintainers to get these.

The [`scripts/compute_all_LREs_script.py`](scripts/compute_all_LREs_script.py) script can be used to generate LQREs.
In order to run this script, first ensure that the qb-gsee-benchmark package is installed as described above.
Then, two additional files are required:
Then, several files are required:

* A PPK file containing a key to access the SFTP server that provides access to FCIDUMP files as described above.
* A configuration file similar to [`scripts/LRE_config.json`](scripts/LRE_config.json) which specifies algorithm parameters, solver UUID, and other information.
* A configuration file similar to [`scripts/LRE_config.json`](scripts/LRE_config.json) or [`scripts/LRE_config.json`](scripts/LRE_config_overlaps.json) which specifies algorithm parameters, solver UUID, and other information.
* If the `algorithm_parameters` object in the config file specifies a value for `overlap_csv`, then this CSV file must also be present. See for example [`scripts/overlaps.csv`](scripts/overlaps.csv)

The paths to these files must be passed as arguments to the script, for example:
```bash
Expand Down
1 change: 1 addition & 0 deletions scripts/LRE_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"df_threshold": 1e-3,
"max_orbitals": 32
},
"algorithm_description": "Double factorized QPE resource estimates based on methodology of arXiv:2406.06335. Note that the truncation error is not included in the error bounds and that the SCF compute time is not included in the preprocessing time. Also note that unlike arXiv:2406.06335, the ground-state overlaps are not computed from DMRG but instead set to a nominal value.",
"contact_info": [
{
"name": "Max Radin",
Expand Down
16 changes: 16 additions & 0 deletions scripts/LRE_config_overlaps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"solver_uuid": "f2d73e1f-3058-43c4-a634-b6c267c84ff1",
"algorithm_parameters": {
"overlap_csv": "overlaps.csv",
"df_threshold": 1e-3,
"max_orbitals": 32
},
"algorithm_description": "Double factorized QPE resource estimates based on methodology of arXiv:2406.06335. Note that the truncation error is not included in the error bounds and that the SCF compute time is not included in the preprocessing time. Ground-state overlap is taken to be that estimated for the dominant CSF as estimated by DMRG and that this DMRG runtime is not included in the classical compute costs.",
"contact_info": [
{
"name": "Max Radin",
"email": "[email protected]",
"institution": "L3Harris"
}
]
}
30 changes: 27 additions & 3 deletions scripts/compute_all_LREs_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
import math
import os
import sys
from collections import defaultdict
from importlib.metadata import version
from typing import Any
from urllib.parse import urlparse
from uuid import uuid4

import pandas as pd
from pyLIQTR.utils.resource_analysis import estimate_resources

from qb_gsee_benchmark.qre import get_df_qpe_circuit
Expand All @@ -53,10 +55,32 @@ def get_lqre(
num_hams = len(problem_instance["tasks"])
logging.info(f"contains {num_hams} associated Hamiltonians.")

if (
"overlap" in config["algorithm_parameters"]
and "overlap_csv" in config["algorithm_parameters"]
):
raise ValueError("Config cannot specify both 'overlap' and 'overlap_csv'.")

if config["algorithm_parameters"].get("overlap_csv"):
overlap_df = pd.read_csv(config["algorithm_parameters"]["overlap_csv"])
overlaps = {
row["task_uuid"]: row["overlap"] for index, row in overlap_df.iterrows()
}
else:
overlaps = defaultdict(lambda: config["algorithm_parameters"]["overlap"])

solution_data: list[dict[str, Any]] = []
results: dict[str, Any] = {}

for task in problem_instance["tasks"]:
if not overlaps.get(task["task_uuid"]):
logging.info(
f"Skipping task {task['task_uuid']} because no overlap was provided."
)
continue

logging.info(f"Analyzing task {task['task_uuid']}...")

num_supporting_files = len(task["supporting_files"])
logging.info(f"number of supporting files: {num_supporting_files}")

Expand Down Expand Up @@ -113,12 +137,12 @@ def get_lqre(
fci=fci,
error_tolerance=error_tolerance,
failure_tolerance=failure_tolerance,
square_overlap=config["algorithm_parameters"]["overlap"] ** 2,
square_overlap=overlaps[task["task_uuid"]] ** 2,
df_threshold=config["algorithm_parameters"]["df_threshold"],
)
circuit_generation_end_time = datetime.datetime.now()
logging.info(
f"Circuit initialization time: {(circuit_generation_end_time - circuit_generation_end_time).total_seconds()} seconds."
f"Circuit initialization time: {(circuit_generation_end_time - circuit_generation_start_time).total_seconds()} seconds."
)
logging.info(f"Estimating logical resources...")
resource_estimation_start_time = datetime.datetime.now()
Expand Down Expand Up @@ -170,7 +194,7 @@ def get_lqre(
"solver_short_name": "DF QPE",
"compute_hardware_type": "quantum_computer",
"algorithm_details": {
"algorithm_description": "Double factorized QPE resource estimates based on methodology of arXiv:2406.06335. Note that the truncation error is not included in the error bounds and that the SCF compute time is not included in the preprocessing time. Also note that unlike arXiv:2406.06335, the ground-state overlaps are not computed from DMRG but instead set to a nominal value.",
"algorithm_description": config["algorithm_description"],
"algorithm_parameters": config["algorithm_parameters"],
},
"software_details": [
Expand Down
4 changes: 4 additions & 0 deletions scripts/overlaps.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
task_uuid,overlap
be3812d3-5975-4736-8a23-96d64e50e66a,0.7085974535652702
472bbfb1-c081-4df6-b966-32ce1194ab8c,0.9774145158534091
a41a284c-7baa-438e-9323-532091c7a78f,0.9985372277228635
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ install_requires =
openfermionpyscf
numpy
paramiko
pandas


[options.packages.find]
Expand Down

0 comments on commit 92361ae

Please sign in to comment.