quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.28k stars 1.02k forks source link

optimize clifford benchmark circuit creation for a total 94.5% speedup #6401

Closed NoureldinYosri closed 10 months ago

NoureldinYosri commented 10 months ago

This is a followup to #6392 and reduces circuit creation time (for 1000 cliffords and 50 qubits) to 0.213s from the original 3.886s (94.5% speedup) and the 2.148s (90% speedup) following #6392

In [3]: import cirq.experiments.qubit_characterizations as ceq
   ...: import cirq
   ...: import time
   ...: import numpy as np
   ...: 
   ...: num_cliffords = 1000
   ...: qubits = cirq.LineQubit.range(50)
   ...: 
   ...: cliffords = ceq._single_qubit_cliffords()
   ...: c1 = cliffords.c1_in_xy
   ...: t1 = time.time()
   ...: seq = ceq._create_parallel_rb_circuit(qubits, num_cliffords, c1)
   ...: t2 = time.time()
   ...: print(f'{t2-t1} s')
0.2055680751800537 s
codecov[bot] commented 10 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (d33b1a7) 97.81% compared to head (0458700) 97.81%. Report is 2 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #6401 +/- ## ======================================= Coverage 97.81% 97.81% ======================================= Files 1111 1111 Lines 97054 97088 +34 ======================================= + Hits 94931 94965 +34 Misses 2123 2123 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

dabacon commented 10 months ago

Nice work!