Qiskit-Extensions / circuit-knitting-toolbox

Tools for knitting quantum circuits with Qiskit
https://qiskit-extensions.github.io/circuit-knitting-toolbox/
Apache License 2.0
70 stars 24 forks source link

Migrate tutorials and a how-to guide to v2 primitives #552

Closed garrison closed 2 months ago

garrison commented 2 months ago

This builds on #513 and follows https://docs.quantum.ibm.com/api/migration-guides/local-simulators.

I've added this to the 0.7.0 milestone, but it need not block the release because this portion can be moved to the 0.7.1 milestone and backported once it is ready.

Remaining action items

coveralls commented 2 months ago

Pull Request Test Coverage Report for Build 8741355357

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details


Totals Coverage Status
Change from base Build 8726584501: 0.0%
Covered Lines: 3452
Relevant Lines: 3617

💛 - Coveralls
garrison commented 2 months ago

With the change to a fake backend, the first tutorial notebook now takes over 15 minutes to execute on my laptop. :sob:

EDIT: I changed to a 5-qubit fake backend, and now it runs within a reasonable time.

garrison commented 2 months ago

With this change, the tutorials are a bit slower, but I think it is acceptable. It's just so nice to use Qiskit Runtime with fake backends everywhere. If a user wants to use a real backend, they need only modify the backend.

Before

============================= slowest 10 durations =============================
30.34s call     docs/circuit_cutting/tutorials/02_gate_cutting_to_reduce_circuit_depth.ipynb::
7.10s call     docs/circuit_cutting/tutorials/01_gate_cutting_to_reduce_circuit_width.ipynb::
7.03s call     docs/circuit_cutting/cutqc/tutorials/tutorial_1_automatic_cut_finding.ipynb::
6.43s call     docs/circuit_cutting/tutorials/03_wire_cutting_via_move_instruction.ipynb::
6.23s call     docs/circuit_cutting/cutqc/tutorials/tutorial_2_manual_cutting.ipynb::
5.32s call     docs/circuit_cutting/how-tos/how_to_specify_cut_wires.ipynb::
3.70s call     docs/circuit_cutting/tutorials/04_automatic_cut_finding.ipynb::
3.57s call     docs/circuit_cutting/how-tos/how_to_generate_exact_sampling_coefficients.ipynb::
1.46s call     docs/circuit_cutting/how-tos/how_to_generate_exact_quasi_dists_from_sampler.ipynb::

After

============================= slowest 10 durations =============================
40.44s call     docs/circuit_cutting/tutorials/02_gate_cutting_to_reduce_circuit_depth.ipynb::
17.30s call     docs/circuit_cutting/tutorials/01_gate_cutting_to_reduce_circuit_width.ipynb::
16.22s call     docs/circuit_cutting/tutorials/03_wire_cutting_via_move_instruction.ipynb::
7.09s call     docs/circuit_cutting/cutqc/tutorials/tutorial_2_manual_cutting.ipynb::
7.01s call     docs/circuit_cutting/cutqc/tutorials/tutorial_1_automatic_cut_finding.ipynb::
6.93s call     docs/circuit_cutting/how-tos/how_to_specify_cut_wires.ipynb::
3.94s call     docs/circuit_cutting/tutorials/04_automatic_cut_finding.ipynb::
2.91s call     docs/circuit_cutting/how-tos/how_to_generate_exact_sampling_coefficients.ipynb::
1.34s call     docs/circuit_cutting/how-tos/how_to_generate_exact_quasi_dists_from_sampler.ipynb::
caleb-johnson commented 2 months ago

With this change, the tutorials are a bit slower, but I think it is acceptable. It's just so nice to use Qiskit Runtime with fake backends everywhere. If a user wants to use a real backend, they need only modify the backend.

Before

============================= slowest 10 durations =============================
30.34s call     docs/circuit_cutting/tutorials/02_gate_cutting_to_reduce_circuit_depth.ipynb::
7.10s call     docs/circuit_cutting/tutorials/01_gate_cutting_to_reduce_circuit_width.ipynb::
7.03s call     docs/circuit_cutting/cutqc/tutorials/tutorial_1_automatic_cut_finding.ipynb::
6.43s call     docs/circuit_cutting/tutorials/03_wire_cutting_via_move_instruction.ipynb::
6.23s call     docs/circuit_cutting/cutqc/tutorials/tutorial_2_manual_cutting.ipynb::
5.32s call     docs/circuit_cutting/how-tos/how_to_specify_cut_wires.ipynb::
3.70s call     docs/circuit_cutting/tutorials/04_automatic_cut_finding.ipynb::
3.57s call     docs/circuit_cutting/how-tos/how_to_generate_exact_sampling_coefficients.ipynb::
1.46s call     docs/circuit_cutting/how-tos/how_to_generate_exact_quasi_dists_from_sampler.ipynb::

After

============================= slowest 10 durations =============================
40.44s call     docs/circuit_cutting/tutorials/02_gate_cutting_to_reduce_circuit_depth.ipynb::
17.30s call     docs/circuit_cutting/tutorials/01_gate_cutting_to_reduce_circuit_width.ipynb::
16.22s call     docs/circuit_cutting/tutorials/03_wire_cutting_via_move_instruction.ipynb::
7.09s call     docs/circuit_cutting/cutqc/tutorials/tutorial_2_manual_cutting.ipynb::
7.01s call     docs/circuit_cutting/cutqc/tutorials/tutorial_1_automatic_cut_finding.ipynb::
6.93s call     docs/circuit_cutting/how-tos/how_to_specify_cut_wires.ipynb::
3.94s call     docs/circuit_cutting/tutorials/04_automatic_cut_finding.ipynb::
2.91s call     docs/circuit_cutting/how-tos/how_to_generate_exact_sampling_coefficients.ipynb::
1.34s call     docs/circuit_cutting/how-tos/how_to_generate_exact_quasi_dists_from_sampler.ipynb::

Agree with this. I really like the FakeBackends for demos for that same reason

caleb-johnson commented 2 months ago

With the change to a fake backend, the first tutorial notebook now takes over 15 minutes to execute on my laptop. 😭

EDIT: I changed to a 5-qubit fake backend, and now it runs within a reasonable time.

I'm seeing the same behavior on my end. I wonder if we should run some quick numbers and report this up. Maybe this is expected, but it seems like a massive slowdown over V1

EDIT: Only about 3 minutes on my end, but still much slower

garrison commented 2 months ago

I wonder if we should run some quick numbers and report this up.

It is all a bit opaque to me, but here is what I suspect is happening: When we use a 5-qubit fake backend, the code simulates all 5 qubits, even when only 2 or 4 are in use, which can be a couple times slower. Plus, there might be some additional slowdown due to applying the noise model from the chosen fake backend. So in that sense it may not be surprising that it is slower to use a fake backend than a noiseless AerSimulator. Also, my hunch is consistent with the massive slowdown I saw when using the same code with FakeTorino (133 qubits). On that many qubits, it's essentially forced to use the MPS simulator if it doesn't know just to ignore the unused qubits (and perhaps one cannot model the noise "correctly" without including unused qubits in the simulation -- I don't know).