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

New Applications + New Features DEV -> Main #70

Merged
merged 81 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
da31ff0
QCD Application 1 Notebook (#56)
JonhasSC Oct 12, 2024
aa76c23
Modified to include pyLIQTR's most recent release. Modified README.md…
JonhasSC Oct 14, 2024
30ff3b1
hotfix patch to fix generating couplings for qcd notebook
JonhasSC Oct 17, 2024
051f12f
patch to fix hamiltonian representation
JonhasSC Oct 18, 2024
65a9c9a
Added extra flags to EstimateMetaData object
Oct 25, 2024
78a1e1c
Integrated the is_extrapolated and other flags with the DickieModel.p…
Oct 25, 2024
c70fc74
Resolved hardcoding dependencies in estimate_trotter
Oct 31, 2024
09ec42e
Resolved hardcoding dependencies in gsee_resource_estimation()
Oct 31, 2024
b34e7ae
Resolved hardcoding dependenct in estimate_qsp(), also refactored arg…
Oct 31, 2024
3ccc8a4
Implemented Implementation specific MetaData classes that inherit fro…
Oct 31, 2024
c479317
Fixed bug where I couldn't set default values in the EstimateMetaData…
Oct 31, 2024
a92f6ff
Integrated the new implementation-specific data classed with their re…
Oct 31, 2024
a542f9b
Integrated the new GSEEMetaData object with the DickeModel script
Oct 31, 2024
e789e1a
Integrated the new GSEEMetaData objects into the FermiHubbard scripts
Oct 31, 2024
28ebadc
Fixed a bug where I didn't pass is_extrapolated into gsee_resource_es…
Oct 31, 2024
4034414
Integrated the new GSEEMetaData objects into the TavisCummings script
Oct 31, 2024
87843e7
Removed unnecessary trotter_order parameter from QSPMetaData object
Oct 31, 2024
482e069
Integrated the TrotterizationMetaData and QSPMetaData objects into Ru…
Nov 1, 2024
3f2f51e
Made the naming for the number of trotter steps more consistent betwe…
Nov 1, 2024
9137290
Set default value for nsteps in TrotterizationMetaData
Nov 1, 2024
1fa62e5
reverting commit da31ff0 as its still need to be worked on
JonhasSC Nov 4, 2024
4e6f711
Merge pull request #59 from lanl-ansi/revert_dev_commit
gsgrattan Nov 5, 2024
ea86984
Integrated new MetaData dataclass objects into python notebooks
gsgrattan Nov 5, 2024
ff75ff3
implemented saving a calculated number of trotter steps to the Trotte…
gsgrattan Nov 5, 2024
0d68f75
Updated pylint badge
github-actions[bot] Nov 5, 2024
a78f946
Merge branch 'dev' of https://github.com/lanl-ansi/qc-applications in…
gsgrattan Nov 7, 2024
4f9dfc5
Merged dev into metadata-flags
gsgrattan Nov 7, 2024
c69c316
Updated pylint badge
github-actions[bot] Nov 7, 2024
629ca0a
removed 'implementation' flag from metadata objects and their impleme…
gsgrattan Nov 8, 2024
799a3fd
Resolved issue with misunderstanding the usage of circuit_extimate, a…
gsgrattan Nov 8, 2024
a2a4da8
Renamed TrotterizationMetaData -> TrotterMetaData
gsgrattan Nov 8, 2024
6560c79
Resolved Hardcoding issue
gsgrattan Nov 13, 2024
a390642
Fixed bug where directory storing the pathway datafiles was not speci…
gsgrattan Nov 13, 2024
53ba80c
mend
gsgrattan Nov 13, 2024
11c0bfe
removed TODO, functionality needs to be implemented in another PR
gsgrattan Nov 13, 2024
5c0c7b9
Merge branch 'metadata-flags' of https://github.com/lanl-ansi/qc-appl…
gsgrattan Nov 13, 2024
39d238e
Updated pylint badge
github-actions[bot] Nov 13, 2024
0e8f986
Made suggested changes to utils.py
gsgrattan Nov 15, 2024
4e763a1
made suggested changes to algo_utils.py
gsgrattan Nov 15, 2024
eab7411
Quantum Chromodynamics Notebook (#62)
JonhasSC Nov 15, 2024
08c1b1f
implemented gate_synth_accuracy into the EstimateMetaData class and p…
gsgrattan Nov 15, 2024
df863c0
made changes to python notebooks
gsgrattan Nov 15, 2024
b2b6df8
Formatting changes to scripts
gsgrattan Nov 15, 2024
94fc9bb
merged with dev
gsgrattan Nov 15, 2024
2b04a8f
Removed depreciated passing of gate_synth_accuracy of gate_synth_accu…
gsgrattan Nov 15, 2024
c6d2ec1
Updated pylint badge
github-actions[bot] Nov 15, 2024
febef19
Made final changes per Johnas' comments
gsgrattan Nov 19, 2024
efce102
Merge branch 'metadata-flags' of https://github.com/lanl-ansi/qc-appl…
gsgrattan Nov 19, 2024
b04c3ba
Updated pylint badge
github-actions[bot] Nov 19, 2024
c6d6cfd
Changes made per Zane's comments
gsgrattan Nov 20, 2024
ab7dadc
Merge branch 'metadata-flags' of https://github.com/lanl-ansi/qc-appl…
gsgrattan Nov 20, 2024
aaf0058
Merge pull request #61 from lanl-ansi/metadata-flags
gsgrattan Nov 20, 2024
73d254e
Code cleanup + Bugfix (#63)
JonhasSC Dec 13, 2024
d0d1fbe
Improved Complete Circuit Decomposition (#66)
JonhasSC Dec 19, 2024
e1019ff
RuCl application 2-GSEE (#64)
zain2864 Jan 3, 2025
42a1a9b
Double Factorization Block Encoding Support (#65)
JonhasSC Jan 6, 2025
01494b0
added value_per_t_gate to the resource estimate
gsgrattan Jan 7, 2025
e19dcdd
Updated pylint badge
github-actions[bot] Jan 7, 2025
644abcb
Added check to see if metadata exists and corrected the calculation o…
gsgrattan Jan 8, 2025
3078f4a
Updated pylint badge
github-actions[bot] Jan 8, 2025
06a7702
Added check to see if metadata exists and corrected the calculation o…
gsgrattan Jan 8, 2025
b5f54fb
Merge branch 'feature/value_per_t_gate' of https://github.com/lanl-an…
gsgrattan Jan 8, 2025
5ff4984
Merge branch 'feature/value_per_t_gate' of https://github.com/lanl-an…
gsgrattan Jan 8, 2025
e12b2fc
Merge branch 'feature/value_per_t_gate' of https://github.com/lanl-an…
gsgrattan Jan 8, 2025
44f19fd
Merge branch 'feature/value_per_t_gate' of https://github.com/lanl-an…
gsgrattan Jan 8, 2025
2610b50
Merge branch 'feature/value_per_t_gate' of https://github.com/lanl-an…
gsgrattan Jan 8, 2025
55f5db1
Updated pylint badge
github-actions[bot] Jan 8, 2025
bce39fe
removed errors
gsgrattan Jan 8, 2025
4a9a1f8
Updated pylint badge
github-actions[bot] Jan 8, 2025
470b534
set default value for value_per_t_gate in the case where metadata exi…
gsgrattan Jan 8, 2025
0a51b58
Merge branch 'feature/value_per_t_gate' of https://github.com/lanl-an…
gsgrattan Jan 8, 2025
b71a332
Updated pylint badge
github-actions[bot] Jan 8, 2025
d182ae5
Merge pull request #68 from lanl-ansi/feature/value_per_t_gate
gsgrattan Jan 8, 2025
cc16f71
Hot Fix: RuCl Application 2: GSEE (#67)
zain2864 Jan 10, 2025
8eacdd7
Cleanup PR (#69)
JonhasSC Jan 21, 2025
7d0fc50
fixed cli args for qchem script and cleaned up
JonhasSC Jan 28, 2025
bdd2b34
fixed utility default arguments for dicke model
JonhasSC Jan 28, 2025
3c86979
capitalized some cli arguments for qcd script
JonhasSC Jan 28, 2025
0b30f66
Fixed cli args for exotic phases
JonhasSC Jan 28, 2025
90915b3
Reran import cells to get rid of warning
gsgrattan Jan 28, 2025
078d656
HOTFIX: Removed \label usages from markdown files, unrecognized contr…
gsgrattan Jan 28, 2025
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ __pycache__/
# C extensions
*.so

# Mac attribute files
.DS_Store
.DS_Store?

# Distribution / packaging
.Python
build/
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
![pylint](https://img.shields.io/badge/PyLint-9.42-yellow?logo=python&logoColor=white)
![pylint](https://img.shields.io/badge/PyLint-9.01-yellow?logo=python&logoColor=white)

# Quantum Computing Application Specifications

This projct focuses on the documentation of applications for Quantum Computers. Currently, we have four notebooks exploring four different applications, which can be found in
the notebooks/ directory. For taking a look at notebooks that are going through ongoing development, one can take a look at the `notebook/exotic-phases-nb` and `notebook/dicke-model-nb`
branches.
This projct focuses on the documentation of applications for Quantum Computers.

# Citation

Expand Down
20 changes: 20 additions & 0 deletions data/RuCl_test_input.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
reference,method,J1,K1,Gam1,Gam_prime1,J2,K2,J3,K3
"Winter et al. PRB","Ab initio (DFT + exact diag.)",-1.7,-6.7,6.6,-0.9,0,0,2.7,0
"Winter et al. NC","Ab initio-inspired (INS fit)",-0.5,-5.0,2.5,0,0,0,0.5,0
"Wu et al.","THz spectroscopy fit",-0.35,-2.8, 2.4,0,0,0,0.34,0
"Cookmeyer and Moore","Magnon thermal Hall (sign)",-0.5,-5.0,2.5,0,0,0,0.1125,0
"Kim and Kee","DFT + t=U expansion",-1.53,-6.55,5.25,-0.95,0,0,0,0
"Suzuki and Suga","Magnetic specific heat",-1.53,-24.4,5.25,-0.95,0,0,0,0
"Yadav et al.","Quantum chemistry (MRCI)",1.2,-5.6,1.2,-0.7,0.25,0,0.25,0
"Ran et al.","Spin wave fit to INS gap",0,-6.8,9.5,0,0,0,0,0
"Hou et al.","Constrained DFT + U",-1.87,-10.7,3.8,0,0,0,1.27,0.63
"Wang et al.","DFT + t=U expansion",-0.3,-10.9,6.1,0,0,0,0.03,0
"Eichstaedt et al.","Fully ab initio (DFT + cRPA + t=U)",-1.4,-14.3,9.8,-2.23,0,-0.63,1.0,0.03
"Eichstaedt et al.","Neglecting non-local Coulomb",-0.2,-4.5,3.0,-0.73,0,-0.33,0.7,0.1
"Eichstaedt et al.","Neglecting non-local SOC",-1.3,-13.3,9.4,-2.3,0,-0.67,1.0,0.1
"Banerjee et al.","Spin wave fit",-4.6,7.0,0,0,0,0,0,0
"Kim et al.","DFT + t=U expansion",-12,17.0,12.0,0,0,0,0,0
"Kim and Kee","DFT + t=U expansion",-3.5,4.6,6.42,-0.04,0,0,0,0
"Winter et al.","Ab initio (DFT + exact diag.)",-5.5,7.6,8.4,0.2,0,0,2.3,0
"Ozel et al.","Spin wave fit/THz spectroscopy",-0.95,1.15,3.8,0,0,0,0,0
"Ozel et al.","Spin wave fit/THz spectroscopy",0.46,-3.5,2.35,0,0,0,0,0
182 changes: 93 additions & 89 deletions notebooks/DickeModelExample.ipynb

Large diffs are not rendered by default.

Binary file added notebooks/EmbeddedFigures/gate_count_total.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added notebooks/EmbeddedFigures/t_count_total.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
162 changes: 81 additions & 81 deletions notebooks/ExoticPhasesExample.ipynb

Large diffs are not rendered by default.

201 changes: 110 additions & 91 deletions notebooks/HighTemperatureSuperConductorExample.ipynb

Large diffs are not rendered by default.

336 changes: 181 additions & 155 deletions notebooks/MagneticLattices.ipynb

Large diffs are not rendered by default.

790 changes: 436 additions & 354 deletions notebooks/PhotosynthesisExample.ipynb

Large diffs are not rendered by default.

443 changes: 443 additions & 0 deletions notebooks/QuantumChromoDynamicsExample.ipynb

Large diffs are not rendered by default.

466 changes: 308 additions & 158 deletions notebooks/RuClExample.ipynb

Large diffs are not rendered by default.

Binary file modified notebooks/pdfs/RuClExample.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "qca"
version = "0.1.0"
version = "0.2.0"
dynamic = ["dependencies"]
requires-python = ">=3.9, <=3.12"
description = "Documentation of Applications for Quantum Computers"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pyLIQTR == 1.2.1
pyLIQTR == 1.3.4
matplotlib
networkx
numpy
Expand Down
307 changes: 224 additions & 83 deletions scripts/AP-RE.py
Original file line number Diff line number Diff line change
@@ -1,111 +1,252 @@
import os
from dataclasses import dataclass
from argparse import ArgumentParser, Namespace
from concurrent.futures import ThreadPoolExecutor, as_completed, ProcessPoolExecutor
from qca.utils.chemistry_utils import load_pathway, generate_electronic_hamiltonians, gsee_molecular_hamiltonian
from qca.utils.chemistry_utils import load_pathway, gsee_molecular_hamiltonian, generate_molecular_hamiltonian, gen_df_qpe

from openfermion.ops.representations import InteractionOperator
@dataclass
class pathway_info:
pathway: list[int]
fname: str

def grab_arguments() -> Namespace:
parser = ArgumentParser('Perform a sweep over different pathways of varying active spaces')
parser.add_argument(
'-DF',
'--use_df',
JonhasSC marked this conversation as resolved.
Show resolved Hide resolved
action='store_true',
help='Flag to double Factorize encode your hamiltonian'
)
parser.add_argument(
'-A',
'--active_space_reduction',
type=int,
help='Factor to reduce the active space',
default=10
default=1
)
parser.add_argument(
'-F',
'--fname',
type=str,
help='absolute filepath pointing to xyz file for extracting molecular hamiltonian along a reaction pathway',
required=True
)
parser.add_argument(
'-B',
'--basis',
type=str,
help='basis working in',
default='sto-3g'
)
parser.add_argument(
'-T',
'--evolution_time',
type=float,
help='Float representing total evolution time if approximating exp^{iHt} for phase estimation',
default=1
)
parser.add_argument(
'-O',
'--trotter_order',
type=int,
help='specify trotter order if using a trotter subprocess for phase estimation',
default=2
)
parser.add_argument(
'-S',
'--trotter_steps',
type=int,
help='Number of trotter steps if using a trotter subprocess for phase estimation',
default=1
)
parser.add_argument(
'-P',
'--pathway',
metavar='N',
type=int,
nargs='*',
help='reaction pathway of interest'
)
parser.add_argument(
'-RE',
'--re_dir',
type=str,
default=f'{os.path.dirname(os.path.realpath(__file__))}/',
help='directory to store generated resource estimates')
parser.add_argument(
'-BP',
'--bits_prec',
type=int,
default=10,
help='Number of bits to estimate phase to'
)
parser.add_argument(
'-GP',
'--gate_synth',
type=float,
help='Accuracy used when decomposing circuits',
default=1e-10
)
parser.add_argument(
'-BR',
'--bits_rot',
type=int,
help='The number of precision bits to use for the rotation angles output by the QROM',
default=7
)
parser.add_argument(
'-DFE',
'--df_error',
type=float,
help='The threshold used to throw out factors from the double factorization.',
default=1e-3
)
parser.add_argument(
'-SFE',
'--sf_error',
type=float,
help='The threshold used to throw out factors from the first eigendecomposition',
default=1e-8
)
parser.add_argument(
'-EE',
'--energy_error',
type=float,
help='The allowable error in phase estimation energy',
default=1e-3
)
args = parser.parse_args()
return args

def generate_ap_re(
catalyst_name:str,
num_processes:int,
hamiltonians: list,
gsee_args:dict,
trotter_steps:int,
bits_precision: int
):
results = []
with ProcessPoolExecutor(max_workers=num_processes) as executor:
for idx, hamiltonian in enumerate(hamiltonians):
future = executor.submit(
gsee_molecular_hamiltonian,
f'pathway({idx})_{catalyst_name}',
gsee_args,
trotter_steps,
bits_precision,
hamiltonian
)
results.append(future)
for future in as_completed(results):
print(f'completed')
def gen_mol_hams(
fname: str,
basis:str,
pathway: list[int],
active_space_reduc: float | None,
):
coords_pathways = load_pathway(fname, pathway)
hams = []
for coords in coords_pathways:
_, charge, multi = [int(coords[0][j]) for j in range(3)]
geometry = []
for coord in coords[1:]:
atom = (coord[0], tuple(coord[1]))
geometry.append(atom)
mol_ham = generate_molecular_hamiltonian(
basis=basis,
geometry=geometry,
multiplicity=multi,
charge=charge,
active_space_frac=active_space_reduc
)
hams.append(mol_ham)
return hams

def grab_molecular_hamiltonians_pool(
active_space_reduc:float,
num_processes:int,
pathways: list,
basis:str
) -> list:
hamiltonians = []
results = []
with ThreadPoolExecutor(max_workers=num_processes) as executor:
for coords in pathways:
future = executor.submit(
generate_electronic_hamiltonians,
basis, active_space_reduc, coords, 1
)
results.append(future)
for future in as_completed(results):
hamiltonians.append(future.result())
return hamiltonians
def df_subprocess(
outdir: str,
circuit_name: str,
mol_hams: list[InteractionOperator],
bits_rot:int,
df_error_threshold:float,
sf_error_threshold:float,
energy_error:float,
df_prec:float | None,
eps: float | None,
gate_precision:float | None,
use_analytical: bool = True
):
for idx, ham in enumerate(mol_hams):
new_name = f'{circuit_name}_{idx}'
# is_extrapolated is false as the circuit is already constructed w/ respect to the number of bits precision
gen_df_qpe(
mol_ham=ham,
use_analytical=use_analytical,
outdir=outdir,
fname=new_name,
bits_rot=bits_rot,
df_error_threshold=df_error_threshold,
sf_error_threshold=sf_error_threshold,
energy_error=energy_error,
df_prec=df_prec,
eps=eps,
gate_precision=gate_precision,
is_extrapolated=False
)

def trotter_subprocess(
outdir:str,
circuit_name:str,
mol_hams: list[InteractionOperator],
ev_time:float,
trotter_order:int,
trotter_steps:int,
bits_precision:int
):
gsee_args = {
'trotterize' : True,
'ev_time' : ev_time,
'trot_ord' : trotter_order,
'trot_num' : trotter_steps
}
gsee_molecular_hamiltonian(
outdir=outdir,
catalyst_name=circuit_name,
gse_args=gsee_args,
trotter_steps=trotter_steps,
bits_precision=bits_precision,
molecular_hamiltonians=mol_hams
)


if __name__ == '__main__':
pid = os.getpid()
args = grab_arguments()
pathway = args.pathway
if not pathway:
raise ValueError('Pathway not specified')
is_single_instance:bool = pathway is None

outdir = args.re_dir
if not os.path.exists(outdir):
os.makedirs(outdir)
fname = args.fname
use_df = args.use_df
bits_precision = args.bits_prec
active_space_reduc = args.active_space_reduction
pathways = [
pathway_info(
pathway=[27, 1, 14, 15, 16, 24, 25, 26],
fname='water_oxidation_Co2O9H12.xyz'
),
pathway_info(
pathway=[3, 1, 14, 15, 16, 20, 21, 22, 23],
fname='water_oxidation_Co2O9H12.xyz'
),
pathway_info(
pathway=[2, 1, 14, 15, 16, 17, 18, 19],
fname='water_oxidation_Co2O9H12.xyz'
),
pathway_info(
pathway=[5, 10, 28, 29, 30, 31, 32, 33],
fname='water_oxidation_Co2O9H12.xyz'
basis = args.basis
evolution_time = args.evolution_time
trotter_order = args.trotter_order
trotter_steps = args.trotter_steps

bits_rot = args.bits_rot
sf_error = args.sf_error
df_error = args.df_error
energy_error = args.energy_error
gate_synth_accuracy = args.gate_synth
fname = os.path.abspath(fname)
mol_hams = gen_mol_hams(fname, basis, pathway, active_space_reduc)
circuit_name = os.path.basename(fname).split('.xyz')[0]

if not use_df:
trotter_subprocess(
outdir=outdir,
circuit_name=circuit_name,
mol_hams=mol_hams,
ev_time=evolution_time,
trotter_order=trotter_order,
trotter_steps=trotter_steps,
bits_precision=bits_precision
)
else:
df_subprocess(
outdir=outdir,
circuit_name=circuit_name,
mol_hams=mol_hams,
bits_rot=bits_rot,
df_error_threshold=df_error,
sf_error_threshold=sf_error,
energy_error=energy_error,
df_prec=bits_precision,
gate_precision=gate_synth_accuracy,
eps=None
)
]
coords_pathways = [
load_pathway(pathway.fname, pathway.pathway) for pathway in pathways
]
molecular_hamiltonians = grab_molecular_hamiltonians_pool(
active_space_reduc=active_space_reduc,
num_processes=len(pathways),
pathways=coords_pathways,
basis='sto-3g'
)
gsee_args = {
'trotterize' : True,
'ev_time' : 1,
'trot_ord' : 2,
'trot_num' : 1
}
generate_ap_re(
catalyst_name='Co2O9H12',
num_processes=len(pathways),
hamiltonians=molecular_hamiltonians,
gsee_args=gsee_args,
trotter_steps=1,
bits_precision=10
)
Loading
Loading