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 single qubit randomized benchmarking #5866

Merged
merged 10 commits into from
Sep 21, 2022

Conversation

tanujkhattar
Copy link
Collaborator

Adds circuit construction benchmarks for single qubit randomized benchmarking for 100 qubits and upto depth 1000.

Part of #3840
cc https://github.com/qh-lab/pyle/issues/29309

The output of the benchmarks is:

[ 25.00%] ··· randomized_benchmarking.SingleQubitRandomizedBenchmarking.time_rb_circuit_construction                                                                                                                                                                                    ok
[ 25.00%] ··· ======= ==========
              --      num_qubits / num_circuits
              ------- ----------
               depth   100 / 20 
              ======= ==========
                 1     119±0ms  
                 10    236±0ms  
                 50    776±0ms  
                100    1.41±0s  
                250    3.43±0s  
                500    6.64±0s  
                1000   12.9±0s  
              ======= ==========

[ 50.00%] ··· randomized_benchmarking.SingleQubitRandomizedBenchmarking.time_rb_op_grid_generation                                                                                                                                                                                      ok
[ 50.00%] ··· ======= ==========
              --      num_qubits / num_circuits
              ------- ----------
               depth   100 / 20 
              ======= ==========
                 1     96.8±0ms 
                 10    162±0ms  
                 50    427±0ms  
                100    762±0ms  
                250    1.74±0s  
                500    3.29±0s  
                1000   6.28±0s  
              ======= ==========

@tanujkhattar tanujkhattar requested review from a team, vtomole and cduck as code owners September 8, 2022 02:59
@CirqBot CirqBot added the size: M 50< lines changed <250 label Sep 8, 2022
@tanujkhattar tanujkhattar changed the title Add performance benchmarks for single qubit rendomized benchmarking Add performance benchmarks for single qubit randomized benchmarking Sep 8, 2022
@tanujkhattar
Copy link
Collaborator Author

@zchen088 @dabacon @maffoo Can someone please take a look?

Copy link
Collaborator

@zchen088 zchen088 left a comment

Choose a reason for hiding this comment

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

LGTM

@tanujkhattar tanujkhattar added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Sep 20, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Sep 20, 2022
@CirqBot
Copy link
Collaborator

CirqBot commented Sep 20, 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 20, 2022
@tanujkhattar tanujkhattar added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Sep 20, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Sep 20, 2022
@CirqBot
Copy link
Collaborator

CirqBot commented Sep 20, 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 20, 2022
@tanujkhattar tanujkhattar added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Sep 20, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Sep 20, 2022
benchmarks/randomized_benchmarking.py Show resolved Hide resolved
benchmarks/randomized_benchmarking.py Show resolved Hide resolved
benchmarks/randomized_benchmarking.py Show resolved Hide resolved
benchmarks/randomized_benchmarking.py Outdated Show resolved Hide resolved
@tanujkhattar
Copy link
Collaborator Author

@dstrain115 Addressed your comments. PTAL.

@pavoljuhas pavoljuhas removed the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Sep 21, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Sep 21, 2022
Copy link
Contributor

@maffoo maffoo left a comment

Choose a reason for hiding this comment

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

minor comments, then LGTM


def setup(self, *_):
self.sq_xz_matrices = np.array(
[dot(*[cirq.unitary(c) for c in group]) for group in _single_qubit_cliffords().c1_in_xz]
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to multiply matrices in the reverse order of how the gates appear in "circuit order".

Suggested change
[dot(*[cirq.unitary(c) for c in group]) for group in _single_qubit_cliffords().c1_in_xz]
[dot(*(cirq.unitary(c) for c in reversed(group))) for group in _single_qubit_cliffords().c1_in_xz]

def _get_op_grid(self, qubits: List[cirq.Qid], depth: int) -> List[List[cirq.Operation]]:
op_grid: List[List[cirq.Operation]] = []
for q in qubits:
gate_ids = list(np.random.choice(len(self.sq_xz_cliffords), depth))
Copy link
Contributor

Choose a reason for hiding this comment

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

why convert to list here? Can this be left as a numpy array?

op_grid: List[List[cirq.Operation]] = []
for q in qubits:
gate_ids = list(np.random.choice(len(self.sq_xz_cliffords), depth))
idx = _find_inv_matrix(dot(*self.sq_xz_matrices[gate_ids]), self.sq_xz_matrices)
Copy link
Contributor

Choose a reason for hiding this comment

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

here, too, need to multiply matrices in verse order compared to gates in the circuit.

@CirqBot CirqBot merged commit 279702f into master Sep 21, 2022
@CirqBot CirqBot deleted the sq_rb_benchmark branch September 21, 2022 04:21
@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 21, 2022
@tanujkhattar
Copy link
Collaborator Author

@maffoo Sorry, the automerge label was assigned before the LGTM so it got merged before I had a chance to address the nits.

I've addressed the nits here in a follow-up PR: #5885

rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…uantumlib#5866)

Adds circuit construction benchmarks for single qubit randomized benchmarking for 100 qubits and upto depth 1000. 

Part of quantumlib#3840
cc https://github.com/qh-lab/pyle/issues/29309

The output of the benchmarks is:
```
[ 25.00%] ··· randomized_benchmarking.SingleQubitRandomizedBenchmarking.time_rb_circuit_construction                                                                                                                                                                                    ok
[ 25.00%] ··· ======= ==========
              --      num_qubits / num_circuits
              ------- ----------
               depth   100 / 20 
              ======= ==========
                 1     119±0ms  
                 10    236±0ms  
                 50    776±0ms  
                100    1.41±0s  
                250    3.43±0s  
                500    6.64±0s  
                1000   12.9±0s  
              ======= ==========

[ 50.00%] ··· randomized_benchmarking.SingleQubitRandomizedBenchmarking.time_rb_op_grid_generation                                                                                                                                                                                      ok
[ 50.00%] ··· ======= ==========
              --      num_qubits / num_circuits
              ------- ----------
               depth   100 / 20 
              ======= ==========
                 1     96.8±0ms 
                 10    162±0ms  
                 50    427±0ms  
                100    762±0ms  
                250    1.74±0s  
                500    3.29±0s  
                1000   6.28±0s  
              ======= ==========

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

Successfully merging this pull request may close these issues.

7 participants