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

Add performance benchmarks for CQC circuit routing #5869

Merged
merged 5 commits into from
Sep 9, 2022

Conversation

tanujkhattar
Copy link
Collaborator

@tanujkhattar tanujkhattar commented Sep 9, 2022

Part of #3840

Would be useful to track the improvements in runtime after #5860 is fixed.

Testing via asv run --quick locally gives the following output:

[ 25.00%] ··· transformers.routing.RouteCQC.time_circuit_routing                                                                                                                                                                                                                        ok
[ 25.00%] ··· ======== =============== =============== ================ ================ ================ =================
              --                                      depth / op_density / grid_device_size                                
              -------- ----------------------------------------------------------------------------------------------------
               qubits   10 / 0.5 / 10   50 / 0.5 / 10   100 / 0.5 / 10   250 / 0.5 / 10   500 / 0.5 / 10   1000 / 0.5 / 10 
              ======== =============== =============== ================ ================ ================ =================
                 10        33.2±0ms        50.0±0ms        66.5±0ms         114±0ms          213±0ms           395±0ms     
                 25        56.9±0ms        160±0ms         291±0ms          664±0ms          1.31±0s           2.56±0s     
                 50        248±0ms         960±0ms         1.84±0s          4.60±0s          9.01±0s           18.4±0s     
                 75        621±0ms         3.18±0s         6.50±0s          17.9±0s          33.2±0s           1.11±0m     
                100        2.11±0s         8.42±0s         18.9±0s          43.5±0s          1.43±0m           2.98±0m     
              ======== =============== =============== ================ ================ ================ =================

[ 50.00%] ··· transformers.routing.RouteCQC.track_routed_circuit_depth_ratio                                                                                                                                                                                                            ok
[ 50.00%] ··· ======== =============== =============== ================ ================ ================ =================
              --                                      depth / op_density / grid_device_size                                
              -------- ----------------------------------------------------------------------------------------------------
               qubits   10 / 0.5 / 10   50 / 0.5 / 10   100 / 0.5 / 10   250 / 0.5 / 10   500 / 0.5 / 10   1000 / 0.5 / 10 
              ======== =============== =============== ================ ================ ================ =================
                 10          2.0             2.4             2.16            2.064            2.218             2.167      
                 25          3.4             4.0             4.15            4.068             4.09             4.003      
                 50          6.2             6.56            6.73            6.648            6.758             6.763      
                 75          6.0             8.92            9.04             9.3              9.43             9.303      
                100          10.5           11.94           12.22            11.776           11.878            11.799     
              ======== =============== =============== ================ ================ ================ =================

cc @ammareltigani

@tanujkhattar tanujkhattar requested review from a team, vtomole and cduck as code owners September 9, 2022 01:37
@CirqBot CirqBot added the size: S 10< lines changed <50 label Sep 9, 2022
Copy link
Contributor

@ammareltigani ammareltigani left a comment

Choose a reason for hiding this comment

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

LGTM w/ remarks

class RouteCQC:
params = [[10, 25, 50, 75, 100], [10, 50, 100, 250, 500, 1000], [0.5], [10]]
param_names = ["qubits", "depth", "op_density", "grid_device_size"]
timeout = 120 # Increase timeout to 2 minutes instead of default 60 seconds.
Copy link
Contributor

Choose a reason for hiding this comment

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

The 100 / 1000 / 0.5 / 10 case is failing because of timeout. I ran it locally and it takes 258s (well above 2mins). So this test would have to be removed or the timeout should be increased to ~5 mins. However, maybe this can be ignored for now since the optimization would bring it down to ~90s.

def setup(self, qubits: int, depth: int, op_density: float, grid_device_size: int):
gate_domain = {cirq.CNOT: 2, cirq.X: 1}
self.circuit = cirq.testing.random_circuit(
qubits, depth, op_density, gate_domain=gate_domain, random_state=12345
Copy link
Contributor

Choose a reason for hiding this comment

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

For smaller circuits, should this be run on multiple seeds and averaged?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could create a separate benchmark for it if we see value in changing seeds. I think this benchmark provides a decent approximation of scaling with number of qubits and circuit depth and the numbers look pretty consistent to me.

Copy link
Collaborator

@pavoljuhas pavoljuhas left a comment

Choose a reason for hiding this comment

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

The table has "failed" values for the largest circuit, please decrease the maximum size.

The duration of asv run on my desktop is 45 minutes.
Do we have some limit for the maximum duration of the benchmarks run?

benchmarks/transformers/routing.py Show resolved Hide resolved
@tanujkhattar
Copy link
Collaborator Author

The table has "failed" values for the largest circuit, please decrease the maximum size.

I've increased the timeout to 3 minutes for now. We can also have failed values for some combinations of a parameterized benchmark and the stored results and plots work as expected (no data points appear for a failed benchmark)

The duration of asv run on my desktop is 45 minutes. Do we have some limit for the maximum duration of the benchmarks run?

This is expected for now since asv doesn't allow running benchmarks in parallel. Also, benchmarks are supposed to be executed on a cloud machine asynchronously and render plots of the form: https://cirq-infra.uc.r.appspot.com/

Copy link
Collaborator

@pavoljuhas pavoljuhas left a comment

Choose a reason for hiding this comment

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

LGTM, but please update the initial comment with a valid timing.

@tanujkhattar tanujkhattar merged commit 03808f4 into master Sep 9, 2022
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
* Add benchmarks for circuit routing

* Add more data points

* Increase timeout to 5 minutes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/performance size: S 10< lines changed <50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants