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

Metadata flags #61

Open
wants to merge 38 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
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
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
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
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
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![pylint](https://img.shields.io/badge/PyLint-9.29-yellow?logo=python&logoColor=white)
![pylint](https://img.shields.io/badge/PyLint-9.26-yellow?logo=python&logoColor=white)

# Quantum Computing Application Specifications

Expand Down
191 changes: 105 additions & 86 deletions notebooks/DickeModelExample.ipynb

Large diffs are not rendered by default.

169 changes: 89 additions & 80 deletions notebooks/ExoticPhasesExample.ipynb

Large diffs are not rendered by default.

212 changes: 127 additions & 85 deletions notebooks/HighTemperatureSuperConductorExample.ipynb
gsgrattan marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

330 changes: 182 additions & 148 deletions notebooks/MagneticLattices.ipynb
gsgrattan marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

316 changes: 163 additions & 153 deletions notebooks/PhotosynthesisExample.ipynb

Large diffs are not rendered by default.

96 changes: 59 additions & 37 deletions notebooks/RuClExample.ipynb
gsgrattan marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions scripts/AP-RE.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from concurrent.futures import ThreadPoolExecutor, as_completed, ProcessPoolExecutor
from qca.utils.chemistry_utils import load_pathway, generate_electronic_hamiltonians, gsee_molecular_hamiltonian

#TODO: Integrate the MetaData classes into this functionality

@dataclass
class pathway_info:
pathway: list[int]
Expand Down
21 changes: 16 additions & 5 deletions scripts/DickeModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pyLIQTR.PhaseEstimation.pe import PhaseEstimation
from networkx import path_graph, set_node_attributes, get_node_attributes, draw, draw_networkx_edge_labels
from qca.utils.algo_utils import gsee_resource_estimation
from qca.utils.utils import circuit_estimate, EstimateMetaData
from qca.utils.utils import circuit_estimate, GSEEMetaData
from qca.utils.hamiltonian_utils import (generate_two_orbital_nx, nx_to_two_orbital_hamiltonian,
dicke_model_qubit_hamiltonian)

Expand All @@ -30,6 +30,7 @@ def main(args):
value = args.value
repetitions = args.repetitions
circuit_write = args.circuit_write
is_extrapolated = args.extrapolate

ham_dicke = dicke_model_qubit_hamiltonian(n_s = n_s, n_b = n_b, omega_c = omega_c, omega_o = omega_o, lam = lam)

Expand All @@ -55,28 +56,37 @@ def main(args):
print('starting')
value_per_circuit = value/repetitions
value_per_circuit=6
dicke_metadata = EstimateMetaData(
#TODO: See if I need to refactor the size string to include the variable names
dicke_metadata = GSEEMetaData(
id=time.time_ns(),
name=name,
category='scientific',
size=f'{n_b} + 1 + {n_s}',
task='Ground State Energy Estimation',
implementations=f'GSEE, evolution_time={t_dicke}, bits_precision={bits_precision_dicke}, trotter_order={trotter_order_dicke}, n_s={n_s}, n_b={n_b}',
value_per_circuit=value_per_circuit,
repetitions_per_application=repetitions
repetitions_per_application=repetitions,


evolution_time=t_dicke,
trotter_order = trotter_order_dicke,
is_extrapolated=is_extrapolated,
bits_precision = bits_precision_dicke,
nsteps=trotter_steps_dicke,
implementation='GSEE'
)

print('Estimating Dicke')
t0 = time.perf_counter()
estimate = gsee_resource_estimation(
outdir=directory,
numsteps=trotter_steps_dicke,
nsteps=trotter_steps_dicke,
gsee_args=args_dicke,
init_state=init_state_dicke,
precision_order=1, #actual precision bits accounted as scaling factors in the resource estimate
phase_offset=dicke_phase_offset,
bits_precision=bits_precision_dicke,
circuit_name=name,
is_extrapolated = is_extrapolated,
metadata = dicke_metadata,
write_circuits=circuit_write
)
Expand Down Expand Up @@ -105,6 +115,7 @@ def parse_arguments():
parser.add_argument('-v', '--value', type=float, default=0, help='value of the total application')
parser.add_argument('-r', '--repetitions', type=int, default=1, help='repetitions needed to achieve value of computatation (not runs of this script)')
parser.add_argument('-c', '--circuit_write', default=False, action='store_true')
parser.add_argument('-x', '--extrapolate', default=False, action='store_true')
return parser

if __name__ == "__main__":
Expand Down
24 changes: 17 additions & 7 deletions scripts/HTSC-one-band-RE.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pyLIQTR.PhaseEstimation.pe import PhaseEstimation
from networkx import get_node_attributes, draw, draw_networkx_edge_labels
from qca.utils.algo_utils import gsee_resource_estimation
from qca.utils.utils import circuit_estimate, EstimateMetaData
from qca.utils.utils import circuit_estimate, GSEEMetaData
from qca.utils.hamiltonian_utils import generate_two_orbital_nx, nx_to_two_orbital_hamiltonian

def main(args):
Expand All @@ -25,9 +25,11 @@ def main(args):
value = args.value
repetitions = args.repetitions
circuit_write = args.circuit_write
is_extrapolated= args.extrapolate

ham = of.fermi_hubbard(lattice_size, lattice_size, tunneling=tunneling, coulomb=coulomb, periodic=False) #returns an aperiodic fermionic hamiltonian

#TODO: Fix this Hardcoding
trotter_order = 2
trotter_steps = 1 #Using one trotter step for a strict lower bound with this method

Expand All @@ -37,13 +39,13 @@ def main(args):
E_min = -len(ham.terms) * max(abs(tunneling), abs(coulomb))
E_max = 0
omega = E_max-E_min
t = 2*np.pi/omega
phase_offset = E_max*t
evolution_time = 2*np.pi/omega
phase_offset = E_max*evolution_time

gsee_args = {
'trotterize' : True,
'mol_ham' : ham,
'ev_time' : t,
'ev_time' : evolution_time,
'trot_ord' : trotter_order,
'trot_num' : 1 #handling adjustment in resource estimate to save time - scales circuit depth linearly.
}
Expand All @@ -52,29 +54,36 @@ def main(args):
init_state = [0] * lattice_size * lattice_size * 2 #TODO: use Fock state from Hartree-Fock as initial state

print('starting')
metadata = EstimateMetaData(
metadata = GSEEMetaData(
id=time.time_ns(),
name=name,
category='scientific',
size=f'{lattice_size}x{lattice_size}',
task='Ground State Energy Estimation',
value_per_circuit=value,
repetitions_per_application=repetitions,
implementations=f'GSEE, evolution_time={t}, bits_precision={bits_precision}, trotter_order={trotter_order}',

evolution_time=evolution_time,
trotter_order=trotter_order,
is_extrapolated=is_extrapolated,
bits_precision=bits_precision,
nsteps=trotter_steps,
implementation="GSEE"
)

print('Estimating one_band')
t0 = time.perf_counter()
estimate = gsee_resource_estimation(
outdir=directory,
numsteps=trotter_steps,
nsteps=trotter_steps,
gsee_args=gsee_args,
init_state=init_state,
precision_order=1,
phase_offset=phase_offset,
bits_precision=bits_precision,
circuit_name=name,
metadata=metadata,
is_extrapolated=is_extrapolated,
write_circuits=args.circuit_write)
t1 = time.perf_counter()
print(f'Time to estimate one_band: {t1-t0}')
Expand All @@ -96,6 +105,7 @@ def parse_arguments():
parser.add_argument('-v', '--value', type=float, default=0, help='value of the total application')
parser.add_argument('-r', '--repetitions', type=int, default=1, help='repetitions needed to achieve value of computatation (not runs of this script)')
parser.add_argument('-c', '--circuit_write', default=False, action='store_true')
parser.add_argument('-x', '--extrapolate', default=False, action='store_true')
return parser

if __name__ == "__main__":
Expand Down
23 changes: 16 additions & 7 deletions scripts/HTSC-three-band-RE.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pyLIQTR.PhaseEstimation.pe import PhaseEstimation
from networkx import get_node_attributes, draw, draw_networkx_edge_labels
from qca.utils.algo_utils import gsee_resource_estimation
from qca.utils.utils import circuit_estimate, EstimateMetaData
from qca.utils.utils import circuit_estimate, GSEEMetaData
from qca.utils.hamiltonian_utils import generate_three_orbital_nx, nx_to_three_orbital_hamiltonian

## Three band
Expand All @@ -35,6 +35,7 @@ def main(args):
repetitions = args.repetitions
directory = args.directory
name = args.name
is_extrapolated = args.extrapolate

bits_precision = estimate_bits_precision(args.error_precision)
g = generate_three_orbital_nx(lattice_size,lattice_size)
Expand All @@ -45,44 +46,51 @@ def main(args):
E_min = -len(ham.terms) * max(abs(t1), abs(t2), abs(t3), abs(t4), abs(mu))
E_max = 0
omega = E_max-E_min
t = 2*np.pi/omega
phase_offset = E_max*t
evolution_time = 2*np.pi/omega
phase_offset = E_max*evolution_time

init_state = [0] * n_qubits

gsee_args = {
'trotterize' : True,
'mol_ham' : ham,
'ev_time' : t,
'ev_time' : evolution_time,
'trot_ord' : trotter_order,
'trot_num' : 1 #Accounted for in a scaling argument later
}


print('starting')

metadata = EstimateMetaData(
metadata = GSEEMetaData(
id=time.time_ns(),
name=name,
category='scientific',
size=f'{lattice_size}x{lattice_size}',
task='Ground State Energy Estimation',
value_per_circuit=value,
repetitions_per_application=repetitions,
implementations=f'GSEE, evolution_time={t}, bits_precision={bits_precision}, trotter_order={trotter_order}',

evolution_time=evolution_time,
trotter_order=trotter_order,
is_extrapolated=is_extrapolated,
bits_precision=bits_precision,
nsteps=trotter_steps,
implementation="GSEE"
)

print('Estimating Circuit Resources')
t0 = time.perf_counter()
estimate = gsee_resource_estimation(
outdir=directory,
numsteps=trotter_steps,
nsteps=trotter_steps,
gsee_args=gsee_args,
init_state=init_state,
precision_order=1,
phase_offset=phase_offset,
bits_precision=bits_precision,
circuit_name=name,
is_extrapolated = is_extrapolated,
metadata=metadata,
write_circuits=args.circuit_write)
t1 = time.perf_counter()
Expand Down Expand Up @@ -114,6 +122,7 @@ def parse_arguments():
parser.add_argument('-v', '--value', type=float, default=0, help='value of the total application')
parser.add_argument('-r', '--repetitions', type=int, default=1, help='repetitions needed to achieve value of computatation (not runs of this script)')
parser.add_argument('-c', '--circuit_write', default=False, action='store_true')
parser.add_argument('-x', '--extrapolate', default=False, action='store_true')
return parser

if __name__ == "__main__":
Expand Down
23 changes: 16 additions & 7 deletions scripts/HTSC-two-band-RE.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pyLIQTR.PhaseEstimation.pe import PhaseEstimation
from networkx import get_node_attributes, draw, draw_networkx_edge_labels
from qca.utils.algo_utils import gsee_resource_estimation
from qca.utils.utils import circuit_estimate, EstimateMetaData
from qca.utils.utils import circuit_estimate, GSEEMetaData
from qca.utils.hamiltonian_utils import generate_two_orbital_nx, nx_to_two_orbital_hamiltonian

## Two band
Expand All @@ -30,6 +30,7 @@ def main(args):
repetitions = args.repetitions
directory = args.directory
name = args.name
is_extrapolated=args.extrapolate

bits_precision = estimate_bits_precision(args.error_precision)
g = generate_two_orbital_nx(lattice_size,lattice_size)
Expand All @@ -40,44 +41,51 @@ def main(args):
E_min = -len(ham.terms) * max(abs(t1), abs(t2), abs(t3), abs(t4), abs(mu))
E_max = 0
omega = E_max-E_min
t = 2*np.pi/omega
phase_offset = E_max*t
evolution_time = 2*np.pi/omega
phase_offset = E_max*evolution_time

init_state = [0] * n_qubits

gsee_args = {
'trotterize' : True,
'mol_ham' : ham,
'ev_time' : t,
'ev_time' : evolution_time,
'trot_ord' : trotter_order,
'trot_num' : 1 #Accounted for in a scaling argument later
}


print('starting')

metadata = EstimateMetaData(
metadata = GSEEMetaData(
id=time.time_ns(),
name=name,
category='scientific',
size=f'{lattice_size}x{lattice_size}',
task='Ground State Energy Estimation',
value_per_circuit=value,
repetitions_per_application=repetitions,
implementations=f'GSEE, evolution_time={t}, bits_precision={bits_precision}, trotter_order={trotter_order}',

evolution_time=evolution_time,
trotter_order=trotter_order,
is_extrapolated=is_extrapolated,
bits_precision=bits_precision,
nsteps=trotter_steps,
implementation="GSEE"
)

print('Estimating Circuit Resources')
t0 = time.perf_counter()
estimate = gsee_resource_estimation(
outdir=directory,
numsteps=trotter_steps,
nsteps=trotter_steps,
gsee_args=gsee_args,
init_state=init_state,
precision_order=1,
phase_offset=phase_offset,
bits_precision=bits_precision,
circuit_name=name,
is_extrapolated=is_extrapolated,
metadata=metadata,
write_circuits=args.circuit_write)
t1 = time.perf_counter()
Expand All @@ -104,6 +112,7 @@ def parse_arguments():
parser.add_argument('-v', '--value', type=float, default=0, help='value of the total application')
parser.add_argument('-r', '--repetitions', type=int, default=1, help='repetitions needed to achieve value of computatation (not runs of this script)')
parser.add_argument('-c', '--circuit_write', default=False, action='store_true')
parser.add_argument('-x', '--extrapolate', default=False, action='store_true')
return parser

if __name__ == "__main__":
Expand Down
Loading