Skip to content

loschmidt.tilted_square_lattice gen+run #259

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

Merged
merged 12 commits into from
Feb 16, 2022

Conversation

mpharrigan
Copy link
Collaborator

@mpharrigan mpharrigan commented Jan 14, 2022

Following #236 , add scripts for generating a QuantumExecutableGroup and a script for running on a simulated EngineProcessor.

This PR includes a very simple placeholder bash script for doing an "end-to-end" test that will be replaced with a more comprehensive solution when we have all the end-to-end parts committed.

This PR does not include the data analysis steps, which will follow.

This requires quantumlib/Cirq#4842

Change-Id: Ieb7aa8fd71bc3cfa1e5282eeca9ca30e2d7ff4cc
Change-Id: I309b28ec9804ce547ed8d73a44418c7c282d4ac5
Change-Id: I4101cdd4acfb8b0b707d9e65439598396929a641
Change-Id: Ibb8a404c61b1dc5527eae1b9f11dda17ff836fb2
@mpharrigan mpharrigan force-pushed the 2022-01-loschmidt-run branch from 43bda6d to fd92a06 Compare January 27, 2022 22:01
Change-Id: Ia04c61885725bd0124f5530a1c1d3bf360e58a98
Change-Id: I0cc080a84512ceebe262c2d611013be3dc8b3b15
@@ -83,6 +83,12 @@ class BenchmarkConfig:
spec_class=TiltedSquareLatticeLoschmidtSpec,
executable_generator_func=get_all_tilted_square_lattice_executables,
configs=[
BenchmarkConfig(
short_name='small-v1',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a good place to put a synopsis about what each benchmark is/does? Either as a line comment or as a structured field? Once we have a bunch of these, it's going to be more difficult to keep track of what each of them does.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good idea, added

i = 1
while True:
run_id = fmt.format(i=i, date=datetime.date.today().isoformat())
if not os.path.exists(f'{base_data_dir}/{run_id}'):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Optional: Not sure it matters much, but do you think it would be faster to list the directory and just check the results for each run rather than make O(n) separate os calls? (Not sure how many runs we expect to do, but maybe could be a lot of them?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this is good to keep in mind. I'm imagining users will be coming up with meaningful run_id or run_id templates (particularly using the {date} option) so that we won't spend much time searching.

I'll punt on this since I think it would be straightforward to transparently update if and when it becomes a problem.

@@ -0,0 +1,3 @@
python gen-small-v1.py
Copy link
Collaborator

Choose a reason for hiding this comment

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

Worth a comment to explain this file? Also, does this file need license info?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added.

Worth noting that I have much more robust plans for doing end-to-end (ie integration testing) once more of the benchmarks are in place; but I figured it wouldn't hurt to have this baby bash script for the time being.

@@ -0,0 +1,22 @@
import numpy as np
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add license info.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks

@@ -0,0 +1,24 @@
import cirq
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add license info.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks

FN = 'loschmidt.tilted_square_lattice.small-v1.json.gz'


def main():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should add module level docstring to explain what this is and what the valid args and/or example command are.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added (using verbiage from the new description field in the algorithmic_benchmarking_library card catalog)

from recirq.otoc.loschmidt.tilted_square_lattice import \
get_all_tilted_square_lattice_executables

FN = 'loschmidt.tilted_square_lattice.small-v1.json.gz'
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this? Avoid abbreviations, especially when ambiguous (filename vs function).
Suggest OUTPUT_FILENAME or similar?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed.

also I think at some point this filename should be fetched maybe from the algorithmic_benchmarking_library "card catalog" module but I haven't completely thought through how that would work.

macrocycle_depths=np.arange(0, 4 + 1, 1))
print(len(exes), 'executables')

cirq.to_json_gzip(exes, FN)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the output filename be a flag?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The current design is to have a 1:1 correspondence between these generation scripts and the serialized QuantumExecutableGroup. I consider this file to be a configuration file like a yaml or textproto file. I could just use a yaml file or something; but I find often times the schema of configuration files gets extensions bolted on to it to handle new ways of configuring things so here I'm just using a real scripting language from the start.

Remember: we need to carefully control the benchmarks we run for accurate comparison over time. If you want to run an ad-hoc benchmark with your own parameter choices, you should likely create a new script to do what you want.


assert TiltedSquareLatticeLoschmidtSpec, 'register deserializer'

FN = 'loschmidt.tilted_square_lattice.small-v1.json.gz'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comments about FN and docstrings in this file as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Change-Id: I6751482d16609c1fa1aa6ba9f5f039d8351926d8
Change-Id: I29c347d6d84a616f4f2937f70ef742d35c5457e9
Change-Id: I25c45fbfdb4889d2a3a991e96cbfc8225ab6a206
@mpharrigan
Copy link
Collaborator Author

thanks for the review @dstrain115, PTAL

@@ -48,6 +48,7 @@ class AlgorithmicBenchmark:
spec_class: Type['ExecutableSpec']
executable_generator_func: Callable[[Any], 'QuantumExecutableGroup']
configs: List['BenchmarkConfig']
description: Optional[str] = None

def as_strings(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not related, but noticed it was missing return type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Change-Id: I343d00ccbef48fab2667746858c8a256772bb942
Change-Id: Ie1e68b97379eeb9080e05aa9c56ba96b1b42eee3
@mpharrigan mpharrigan mentioned this pull request Feb 16, 2022
Change-Id: Iafdd325501ffe60a53828b369564a8512d245916
@mpharrigan mpharrigan merged commit 783452f into quantumlib:master Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants