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

Speeds up RouteCQC by encoding qubits as integers #5872

Merged
merged 16 commits into from
Sep 19, 2022
Merged

Conversation

tanujkhattar
Copy link
Collaborator

@tanujkhattar tanujkhattar commented Sep 9, 2022

Fixes #5860

The speedup is ~2x - 3x compared to the original implementation. Output from benchmarks using asv run --quick is as follows:

[ 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        30.9±0ms        41.8±0ms        56.6±0ms         97.5±0ms         182±0ms           335±0ms     
                 25        39.5±0ms        118±0ms         212±0ms          477±0ms          1.02±0s           1.85±0s     
                 50        94.8±0ms        562±0ms         1.16±0s          2.84±0s          5.95±0s           11.9±0s     
                 75        201±0ms         1.79±0s         3.53±0s          9.03±0s          19.0±0s           38.1±0s     
                100        851±0ms         5.18±0s         11.0±0s          26.1±0s          51.2±0s           1.71±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.04            4.17            4.068            4.092             4.003      
                 50          6.3             6.62            7.04            6.788             6.76              6.78      
                 75          6.4             8.86            9.13            9.164             9.31             9.111      
                100          10.9           12.12           11.84            11.612           11.846            11.901     
              ======== =============== =============== ================ ================ ================ =================

cc @ammareltigani

This PR also removed _value_equality_values_ implementation from the routing class since a transformer doesn't need to support value equality / be hashable and supporting value equality increases the memory footprint of the transformer by storing unnecessary additional objects like the entire device graph instead of only the induced subgraph on integers etc.

@tanujkhattar tanujkhattar requested review from a team, vtomole and cduck as code owners September 9, 2022 23:19
@CirqBot CirqBot added the size: L 250< lines changed <1000 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! Thanks so much for making this great optimization.

Copy link
Collaborator

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

Couple of concerns on a quick read-through. Performance improvements look great!

ammareltigani and others added 6 commits September 16, 2022 17:43
* added circuit visualization code

* made print gate private and added more tests

* removed unused import and added gate to private list

* addressed comments

* added safeguard for wrong use of RoutingSwapTag

* addressed nits

* added return type for

* added _SwapPrintGate again to  and fixed type issue
It is sufficient to have the pattern once in the top .gitignore.
@tanujkhattar tanujkhattar added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Sep 19, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Sep 19, 2022
@CirqBot
Copy link
Collaborator

CirqBot commented Sep 19, 2022

Automerge cancelled: A status check is failing.

@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Sep 19, 2022
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/performance size: L 250< lines changed <1000
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Routing] Encode qubits into integers to replace dictionary lookups with array indexing.
6 participants