-
Notifications
You must be signed in to change notification settings - Fork 126
Algo Benchmark Library card catalog #235
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
Conversation
Change-Id: I4ca692cd92ddbee95d0d2aeed5a4027fcd0f2aa4
recirq/algo_benchmark_library.py
Outdated
|
||
|
||
@dataclass | ||
class AlgoBenchmark: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call this AlgorithmBenchmark? It is more verbose, but abbreviations are generally discouraged:
cirq-google/cirq_google/engine/engine_program.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 77e48f9
recirq/algo_benchmark_library.py
Outdated
@dataclass | ||
class AlgoBenchmark: | ||
domain: str | ||
"""The problem domain. Usually a high-level ReCirq module.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the proper way to document this class? I thought the usual way to document these was to have a docstring at the beginning of the class with an "Args" section that describes each parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 9481205
recirq/algo_benchmark_library.py
Outdated
data_class: Type | ||
"""The class which can contain ETL-ed data for this AlgoBenchmark.""" | ||
|
||
gen_func: Callable[[...], QuantumExecutableGroup] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also an abbreviation. Maybe generator would be a better name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 6f9224c
recirq/algo_benchmark_library.py
Outdated
|
||
|
||
@lru_cache() | ||
def get_all_algo_configs() -> List[Tuple[AlgoBenchmark, BenchmarkConfig]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 8f139ec
recirq/algo_benchmark_library.py
Outdated
|
||
|
||
def main(): | ||
df = pd.DataFrame([algo.as_strings() for algo in BENCHMARKS]).set_index('executable_family') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh. This is a funny way of printing out the benchmark names. You are using pandas just for text formatting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sortof forgot I left this in here. Changed the name of this function and removed the __main__
entry point 1514b20
The nice thing about pandas is you can use the same technique in a juypter noteook and get a nice html table that you can paste into sheets or a doc
recirq/algo_benchmark_library.py
Outdated
@dataclass | ||
class AlgoBenchmark: | ||
domain: str | ||
"""The problem domain. Usually a high-level ReCirq module.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Usually a high-level ReCirq module." This is actually enforced by the tests, so I would adjust the wording to make it mandatory and also make clear that it should include the "recirq." prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 7c7faa1
@pytest.mark.parametrize('algo', BENCHMARKS) | ||
def test_executable_family_is_formulaic(algo): | ||
# Check consistency in the AlgoBenchmark dataclass: | ||
assert algo.executable_family == algo.spec_class.executable_family |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are checking consistency for future benchmarks, it might be good to add messages to this assert and other asserts in this file so that developers of benchmarks know why their tests are failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 3308c5e
recirq/algo_benchmark_library.py
Outdated
"""A globally unique name for this config.""" | ||
|
||
gen_script: str | ||
"""The script filename that generates the QuantumExecutableGroup for this Config.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should include that the gen-script should begin with "gen-". Same for other test-enforced conventions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 69b6b65
Change-Id: Ic95e07f4690f4f10bf2634eda7a66ac81649774a
Change-Id: Ic1213396a235f6e40e46d2f3472d8380bb653719
Change-Id: I97e19c6544def983cadde8c959fbc83b5d9f867e
Change-Id: I7c23fa8eac6d0b04cc7a480ac6a81cf4cb29f308
Change-Id: I21a65e3e126c42bb227582d335d24a3fca287015
Change-Id: Ic393c5bb90b6df5b50b9a70ae0b3386d43a89e6f
Change-Id: I95696873269c5e66dcbffedce7814c4488ac6d47
Change-Id: I04cd53462b7190e071cd6ec680aaec37e08e7064
Change-Id: I7a78669ee18d47a4e909783663c2da210d1db699
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ptal
recirq/algo_benchmark_library.py
Outdated
|
||
|
||
@dataclass | ||
class AlgoBenchmark: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 77e48f9
recirq/algo_benchmark_library.py
Outdated
@dataclass | ||
class AlgoBenchmark: | ||
domain: str | ||
"""The problem domain. Usually a high-level ReCirq module.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 9481205
recirq/algo_benchmark_library.py
Outdated
@dataclass | ||
class AlgoBenchmark: | ||
domain: str | ||
"""The problem domain. Usually a high-level ReCirq module.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 7c7faa1
recirq/algo_benchmark_library.py
Outdated
data_class: Type | ||
"""The class which can contain ETL-ed data for this AlgoBenchmark.""" | ||
|
||
gen_func: Callable[[...], QuantumExecutableGroup] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 6f9224c
recirq/algo_benchmark_library.py
Outdated
"""A globally unique name for this config.""" | ||
|
||
gen_script: str | ||
"""The script filename that generates the QuantumExecutableGroup for this Config.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 69b6b65
recirq/algo_benchmark_library.py
Outdated
|
||
|
||
@lru_cache() | ||
def get_all_algo_configs() -> List[Tuple[AlgoBenchmark, BenchmarkConfig]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 8f139ec
recirq/algo_benchmark_library.py
Outdated
|
||
|
||
def main(): | ||
df = pd.DataFrame([algo.as_strings() for algo in BENCHMARKS]).set_index('executable_family') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sortof forgot I left this in here. Changed the name of this function and removed the __main__
entry point 1514b20
The nice thing about pandas is you can use the same technique in a juypter noteook and get a nice html table that you can paste into sheets or a doc
@pytest.mark.parametrize('algo', BENCHMARKS) | ||
def test_executable_family_is_formulaic(algo): | ||
# Check consistency in the AlgoBenchmark dataclass: | ||
assert algo.executable_family == algo.spec_class.executable_family |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 3308c5e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once the tests resolve.
|
||
import pandas as pd | ||
|
||
from cirq_google.workflow import ExecutableSpec, QuantumExecutableGroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the pytest:
ModuleNotFoundError: No module named 'cirq_google.workflow'
Is this waiting on another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and other forthcoming code relies on the currently-unreleased cirq_google.workflow
module. I'll have to figure out a way to make this work in the mean time.
- release openfermion that doesn't pin to a particular cirq version
- enable testing against multiple versions of cirq including prerelease in ReCirq CI
- put import guards and conditional testing so these tests only run if a recent enough cirq version is available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following #237 , this is now implemented. The tests get run on the current
and next
config. They were failing on cirq 0.12. Looks like the executable spec stuff got included in v0.13 but future functionality may only be tested on next
until the relevant cirq release is cut.
Change-Id: I1ae995491202c2b2f00c1614cb3c5623080ac685
Change-Id: I55a4e61783f337c7220f85b36fef61391138e0d9
Change-Id: I350ce16324e64d0c1e8d14d56737ea090b3fc039
This "card catalog" will be the centralized record of algorithmic benchmarks that are highly organized and use the new
cirq_google.workflow
cirqflow style of execution.This PR does not commit any benchmarks, but establishes (via the dataclasses and the tests) a set of conventions for organizing things.