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

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

Merged
merged 11 commits into from
Apr 19, 2024

Conversation

garrison
Copy link
Member

@garrison garrison commented Apr 16, 2024

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

@garrison garrison added documentation Improvements or additions to documentation cutting QPD-based circuit cutting code labels Apr 16, 2024
@garrison garrison added this to the 0.7.0 milestone Apr 16, 2024
@garrison garrison self-assigned this Apr 16, 2024
@coveralls
Copy link

coveralls commented Apr 16, 2024

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

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.438%

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

💛 - Coveralls

but now it executes very slowly
@garrison
Copy link
Member Author

garrison commented Apr 16, 2024

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.

Now the execution time is reasonable.
It appears there is no 0.14.0 release on pypi
@garrison
Copy link
Member Author

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::

@garrison garrison marked this pull request as ready for review April 17, 2024 21:22
@garrison garrison changed the title Migrate tutorials to v2 primitives Migrate tutorials and a how-to to v2 primitives Apr 18, 2024
@garrison garrison requested a review from caleb-johnson April 18, 2024 00:23
@garrison garrison changed the title Migrate tutorials and a how-to to v2 primitives Migrate tutorials and a how-to guide to v2 primitives Apr 18, 2024
@ibrahim-shehzad ibrahim-shehzad mentioned this pull request Apr 18, 2024
15 tasks
Copy link
Member Author

Choose a reason for hiding this comment

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

Just a note: there are much fewer single-qubit gates in transpiled_qc after moving to FakeManilaV2. The zoom level of that circuit ends up changing as a result, which can be noticed from the rich diff on github.

@caleb-johnson
Copy link
Collaborator

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
Copy link
Collaborator

caleb-johnson commented Apr 19, 2024

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
Copy link
Member Author

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).

Copy link
Collaborator

@caleb-johnson caleb-johnson left a comment

Choose a reason for hiding this comment

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

This looks great, thanks for putting this together

I don't think the slowdown when trying to use FakeBackends with more qubits is something we can control.

@garrison garrison merged commit 6cc05a4 into main Apr 19, 2024
11 checks passed
@garrison garrison deleted the runtime-samplerv2-docs branch April 19, 2024 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cutting QPD-based circuit cutting code documentation Improvements or additions to documentation
Projects
None yet
3 participants