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

Increase documentation of built-in transpiler plugins #13620

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jakelishman
Copy link
Member

Summary

This overhauls how the qiskit.transpiler documentation talks about the transpiler plugins. All of the built-in plugins now have a decent amount of overview documentation, and the requirements and expectations for each stage of the preset pipelines is explained in more detail.

This form of the documentation makes the distinction between "a compilation routine in general" and "Qiskit's specific choice of default pipeline" clearer, to avoid confusion for advanced users.

Much of the guide-level explanations of the different preset pipeline stages moved to https://docs.quantum.ibm.com some time ago, so this PR removes those, in favour of focussing on the actual API, and inserts links to learn more about the principles elsewhere.

The guide-level explanation of scheduling is left in-place for now, because the content on the other parts of the IBM documentation isn't as complete for that.

Details and comments

I've attempted to draw a good line between explaining what Qiskit actually does, so users know, and maintaining that we reserve the right to modify specifics of things (especially default plugins) between minor versions.

This isn't a full rewrite of everything - I feel like we could probably do with revisiting the documentation of a lot of individual transpiler passes' classes - but I was writing my own plugin over the last month or so, and this is documentation I personally wanted to see.

This overhauls how the `qiskit.transpiler` documentation talks about the
transpiler plugins.  All of the built-in plugins now have a decent
amount of overview documentation, and the requirements and expectations
for each stage of the preset pipelines is explained in more detail.

This form of the documentation makes the distinction between "a
compilation routine in general" and "Qiskit's specific choice of default
pipeline" clearer, to avoid confusion for advanced users.

Much of the guide-level explanations of the different preset pipeline
stages moved to https://docs.quantum.ibm.com some time ago, so this PR
removes those, in favour of focussing on the actual API, and inserts
links to learn more about the principles elsewhere.

The guide-level explanation of scheduling is left in-place for now,
because the content on the other parts of the IBM documentation isn't as
complete for that.
@jakelishman jakelishman added documentation Something is not clear or an error documentation stable backport potential The bug might be minimal and/or import enough to be port to stable labels Jan 7, 2025
@jakelishman jakelishman requested a review from a team as a code owner January 7, 2025 17:53
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@jakelishman
Copy link
Member Author

Docs team: as of right now, we don't necessarily need to bother copy-editing - first I need to get sign-off from the rest of the compiler team that this is the appropriate level of detail for us to document, and doesn't over-tie our hands with respect to the stability policy. If you guys have any comments about the high-level content, that's very welcome immediately.

@jakelishman jakelishman added the Changelog: None Do not include in changelog label Jan 7, 2025
@coveralls
Copy link

coveralls commented Jan 7, 2025

Pull Request Test Coverage Report for Build 12657127421

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 6 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.002%) to 88.95%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 93.18%
crates/qasm2/src/expr.rs 1 94.02%
crates/qasm2/src/lex.rs 4 92.48%
Totals Coverage Status
Change from base Build 12655273978: 0.002%
Covered Lines: 79456
Relevant Lines: 89327

💛 - Coveralls

Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

Thanks Jake! I have taken a look to the introduction up to the init stage details and left a few comments. I will try to finish the review later today :)

:class:`.StagedPassManager`, which allows greater configuration of the individual stages of a
tranpsilation.

A preset pass manager has up to six named stages. These are summarized, in order of execution,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also briefly mention the ability to add pre_ and post_ stages, maybe as a note at the end of this section? The pre_layout stage is used later in an example but I didn't find it being introduced anywhere in the text.

Copy link
Member Author

Choose a reason for hiding this comment

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

Shall I put that documentation into the bit about StagedPassManager further down the page?

Imo the preset pass managers shouldn't use the pre_ and post_ sections themselves at all, since that defeats their purpose for configuration; if we use them, we've de facto made that its own stage. But I think we need to re-jig the construction a little bit to make that true; at the moment, we do use them.

optimizations; only transformations needed to make the circuit runnable at all will be present. On
the other end, level 3 enables a full barrage of optimization techniques, some of which can be very
expensive in compilation time. Similar to classical compilers, optimization level 3 is not always
guaranteed to produce the best results. Qiskit defaults to optimization level 2.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we explicitly argue why we chose level 2? I am thinking something like:

Suggested change
guaranteed to produce the best results. Qiskit defaults to optimization level 2.
guaranteed to produce the best results. Qiskit defaults to optimization level 2,
which offers a balanced tradeoff between compilation time and the expected level of circuit optimization.

I understand that the wording here can be tricky, so no need to apply the suggestion.

backend = QiskitRuntimeService().backend("some-backend")

# Create the pass manager for the transpilation ...
pm = generate_preset_pass_manager(backend=backend)
Copy link
Contributor

Choose a reason for hiding this comment

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

We have had a few back and forths over the use of backend vs target as the "main" transpilation input, the original text said "target backend" so the terms where kind of interchangeable in the docs. Now, the code examples sometimes use backend, sometimes target, but the text mostly refers to the target. I don't think it's difficult to understand, but I wonder if we'd like to explain this nuance a bit better to users (maybe the answer is no).

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't have a strong preference with the state of Qiskit right this second, but I think Ian and I might be beginning to argue for an expansion of the meaning of Backend for a hypothetical BackendV3 that will make it preferable to use backend as the default user-facing bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog documentation Something is not clear or an error documentation stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants