ipython_cell_input.py 506 B

123456789101112131415161718192021222324
  1. def bench_qcgpu(n, depth):
  2. state = qcgpu.State(n)
  3. h = qcgpu.gate.h()
  4. x = qcgpu.gate.x()
  5. sqrt_x = qcgpu.gate.sqrt_x()
  6. print('started')
  7. start = time.time()
  8. for level in range(depth):
  9. for q in range(n):
  10. state.apply_gate(h, q)
  11. state.apply_gate(sqrt_x, q)
  12. if q != 0:
  13. state.apply_controlled_gate(x, q, 0)
  14. runtime = time.time() - start
  15. print('ended: ', runtime)
  16. return runtime
  17. bench_qcgpu(26,5)