Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding preliminary QRE for mn_mono #8

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions examples/get_problem_lqre.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
################################################################################
# © Copyright 2024 Zapata Computing Inc.
################################################################################
"""This script will generate logical resource estimates using PyLIQTR for the mn_mono
benchmark instance. It will save the results to a JSON file.

The algorithm performance model is similar to that described in arXiv:2406.06335v1, but
with a few simplifying assumptions. First, the ground-state overlap is assumed to be
0.8. Second, the double-factorized truncation threshold is assumed to be 1e-3 Ha.

In order to run this script to work, you must have credentials with read access the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small grammar edit:
In order to run this script to work,

L3Harris SFTP server. QB performers can obtain the PPK file with credentials from the
basecamp thread linked below. The `ppk_path` variable should be set to the path of the
PPK file.

https://3.basecamp.com/3613864/buckets/26823103/messages/7222735635
"""

import json
import time
from typing import Any

import requests
from pyLIQTR.utils.resource_analysis import estimate_resources

from qb_gsee_benchmark.qre import get_df_qpe_circuit
from qb_gsee_benchmark.utils import retrieve_fcidump_from_sftp

ppk_path = "/Users/maxradin/.ssh/darpa-qb-key.ppk"
username = "darpa-qb"


url = "https://raw.githubusercontent.com/jp7745/qb-gsee-problem-instances/main/problem_instances/problem_instance.mn_mono.cb40f3f7-ffe8-40e8-4544-f26aad5a8bd8.json"
response = requests.get(url)
if response.status_code != 200:
raise RuntimeError(f"Failed to retrieve {url}. Status code: {response.status_code}")

problem_instance = response.json()

solution_data: list[dict[str, Any]] = []

results = {}
for instance in problem_instance["instance_data"]:
print(
f"Getting logical resource estimates for {instance['instance_data_object_uuid']}..."
)
fci = retrieve_fcidump_from_sftp(
instance["instance_data_object_url"], username=username, ppk_path=ppk_path
)

start = time.time()
circuit, num_shots, hardware_failure_tolerance_per_shot = get_df_qpe_circuit(
fci=fci,
error_tolerance=1.6e-3,
failure_tolerance=1e-2,
square_overlap=0.8**2,
df_threshold=1e-3,
)
preprocessing_time = time.time() - start
print(f"Initialized circuit in {preprocessing_time} seconds.")
print(f"Estimating logical resources...")
logical_resources = estimate_resources(circuit.circuit)

results[instance["instance_data_object_uuid"]] = {
"num_logical_qubits": logical_resources["LogicalQubits"],
"num_t": logical_resources["T"],
"preprocessing_time": preprocessing_time,
"num_shots": num_shots,
"hardware_failure_tolerance_per_shot": hardware_failure_tolerance_per_shot,
}

with open(f"lqre-{problem_instance['problem_instance_uuid']}.json", "w") as f:
json.dump(results, f)
49 changes: 49 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools_scm>=6.0"]

# Including this section is same as 'use_scm_version=True' in setup.py
# See https://github.com/pypa/setuptools_scm for guidance
[tool.setuptools_scm]

[tool.isort]
profile = "black"

[tool.mypy]
# Without this we would have to add an empty __init__.py file for every package.
namespace_packages = true
# Without this mypy complains about the same module being imported under different
# names. Note that this also requires setting `mypy_path`.
explicit_package_bases = true
# We usually keep our source code under `src/<namespace>/<library>/...`.
# This option tells mypy to look under that directory path.
# If your repo has a different layout you can add the appropriate paths
# by setting MYPYPATH env variable.
mypy_path = "src"

[[tool.mypy.overrides]]
module = [
'scipy.*',
'sympy.*',
'rapidjson',
]
ignore_missing_imports = true

[tool.coverage.run]
omit = ["*/__init__.py"]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"def __str__",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
]

[tool.pytest.ini_options]
log_level="INFO"

[tool.flake8]
ignore = ['E203', 'E266', 'F401', 'W605']
max-line-length = 88
40 changes: 40 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[metadata]
name = qb-gsee-benchmark
description = "DARPA QB GSEE Benchmark"
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8
url = https://github.com/zapatacomputing/qb-gsee-benchmark
author = Zapata Computing Inc.
author_email = [email protected],
license = <INSERT LICENSE APPROPRIATE LICENSE HERE>
license_file = LICENSE
classifiers =
Programming Language :: Python :: 3
Operating System :: OS Independent
License :: OSI Approved :: Apache Software License
Topic :: Scientific/Engineering


[options]
zip_safe = False
include_package_data = True
package_dir =
= src
packages = find_namespace:
python_requires = >=3.8

install_requires =
pyLIQTR>=1.2.0
pyscf
openfermion
openfermionpyscf
numpy
paramiko


[options.packages.find]
where = src

[options.extras_require]
dev =
orquestra-python-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
{
"$schema": "https://raw.githubusercontent.com/zapatacomputing/qb-gsee-benchmark/refs/heads/main/instances/schemas/solution.schema.0.0.1.json",
"solution_uuid": "30d863a7-ffde-40f9-8107-af771ec986b5",
"problem_instance_uuid": "cb40f3f7-ffe8-40e8-4544-f26aad5a8bd8",
"creation_timestamp": "2024-10-02T19:23:17.097271Z",
"short_name": "QPE",
"is_resource_estimate": true,
"contact_info": [
{
"name": "Max Radin",
"email": "[email protected]",
"institution": "Zapata AI"
}
],
"solution_data": [
{
"instance_data_object_uuid": "68af0b80-3d27-4aba-84f9-bcdd30a9255b",
"run_time": {
"overall_time": {
"seconds": 130648434.19662397
},
"preprocessing_time": {
"seconds": 92.24001598358154
},
"algorithm_run_time": {
"seconds": 130648341.95660798
},
"postprocessing_time": {
"seconds": 0
}
},
"error_bound": 0.001,
"confidence_level": 0.99
},
{
"instance_data_object_uuid": "28a7820f-63fe-4920-aeec-a7ffe7e55d83",
"run_time": {
"overall_time": {
"seconds": 1664073932.1223369
},
"preprocessing_time": {
"seconds": 127.2850890159607
},
"algorithm_run_time": {
"seconds": 1664073804.8372478
},
"postprocessing_time": {
"seconds": 0
}
},
"error_bound": 0.001,
"confidence_level": 0.99
},
{
"instance_data_object_uuid": "f738fcd6-7ddc-4d70-8ff9-4019e3718b04",
"run_time": {
"overall_time": {
"seconds": 133173800.78035574
},
"preprocessing_time": {
"seconds": 18.053699731826782
},
"algorithm_run_time": {
"seconds": 133173782.726656
},
"postprocessing_time": {
"seconds": 0
}
},
"error_bound": 0.001,
"confidence_level": 0.99
},
{
"instance_data_object_uuid": "6e2bf415-6a69-4b36-ba0f-780a11cb7c0b",
"run_time": {
"overall_time": {
"seconds": 1827250460.5177379
},
"preprocessing_time": {
"seconds": 110.68720984458923
},
"algorithm_run_time": {
"seconds": 1827250349.830528
},
"postprocessing_time": {
"seconds": 0
}
},
"error_bound": 0.001,
"confidence_level": 0.99
},
{
"instance_data_object_uuid": "027490ba-34f9-4340-89ab-27fd110d2821",
"run_time": {
"overall_time": {
"seconds": 133699950.46700683
},
"preprocessing_time": {
"seconds": 34.24659085273743
},
"algorithm_run_time": {
"seconds": 133699916.22041598
},
"postprocessing_time": {
"seconds": 0
}
},
"error_bound": 0.001,
"confidence_level": 0.99
},
{
"instance_data_object_uuid": "bae2da57-6a69-483e-95bc-b77f72ebfba8",
"run_time": {
"overall_time": {
"seconds": 1822049254.3327522
},
"preprocessing_time": {
"seconds": 109.89768028259277
},
"algorithm_run_time": {
"seconds": 1822049144.435072
},
"postprocessing_time": {
"seconds": 0
}
},
"error_bound": 0.001,
"confidence_level": 0.99
},
{
"instance_data_object_uuid": "72343006-774e-4192-b481-fa840ed25573",
"run_time": {
"overall_time": {
"seconds": 133068577.38371417
},
"preprocessing_time": {
"seconds": 21.355810165405273
},
"algorithm_run_time": {
"seconds": 133068556.027904
},
"postprocessing_time": {
"seconds": 0
}
},
"error_bound": 0.001,
"confidence_level": 0.99
},
{
"instance_data_object_uuid": "ea55abec-8253-445d-85fa-914948b5e5a5",
"run_time": {
"overall_time": {
"seconds": 1827701433.7916307
},
"preprocessing_time": {
"seconds": 112.39502286911011
},
"algorithm_run_time": {
"seconds": 1827701321.3966079
},
"postprocessing_time": {
"seconds": 0
}
},
"error_bound": 0.001,
"confidence_level": 0.99
}
],
"compute_hardware_type": "quantum_computer",
"compute_details": {
"description": "Double factorized QPE resource estimates based on methodology of arXiv:2406.06335. Uses PyLIQTR logical resource estimates with BenchQ footprint analysis. Ground-state overlap assumed to be 0.8 and double-factorized truncation threshold to be 1e-3 Ha. 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."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to capture the classical hardware used for the pre-processing. It's not needed at this point, but would be nice to have

},
"digital_signature": null
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to remove this?

Empty file.
Loading