-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
base: main
Are you sure you want to change the base?
Conversation
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.
One or more of the following people are relevant to this code:
|
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. |
Pull Request Test Coverage Report for Build 12915883307Warning: 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
💛 - Coveralls |
There was a problem hiding this 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 :)
backend = QiskitRuntimeService().backend("some-backend") | ||
|
||
# Create the pass manager for the transpilation ... | ||
pm = generate_preset_pass_manager(backend=backend) |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left this as-is for now, but feel free to argue.
Co-authored-by: Elena Peña Tapia <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some copy-editing suggestions and otherwise reads great!!
Co-authored-by: abbycross <[email protected]>
Thanks! Should all be applied now. I get the logic in changing "1- and 2-qubit" (etc) to "one- and two-qubit", it just feels a bit weird to write that because the numerals are easier to read to me. But this is all prose anyway, so better to have it consistent. |
I hear that. The general rule to apply is if the number is under 10, we spell it out (unless it is attached to a unit, like 5 mm for example). I personally prefer "single- and two-qubit" but didn't change the "one" to "single" since I didn't want to wreck the line lengths :) and also, one-qubit is just as clear as single-qubit -- I just think it sounds nicer :) |
Yeah, this I know, I guess it's just because I usually write "1q gates" (and so on). I'm so used to reading the numerals in this specific case that the words feel funny to me, even though I don't use numerals in other small-number situations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great - thanks, Jake!
The final layout permutation is caused by :class:`~.SwapGate` insertion during | ||
the :ref:`routing_stage`. This class provides an interface to reason about these | ||
permutations using a variety of helper methods. | ||
the :ref:`transpiler-preset-stage-routing`. This class provides an interface to reason about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the :ref:`transpiler-preset-stage-routing`. This class provides an interface to reason about | |
the :ref:`transpiler-preset-stage-routing`. This class provides an interface to understand |
Currently, there are 6 stages in the preset pass managers, all of which actively | ||
load external plugins via corresponding entry points. | ||
Currently, there are six stages in the preset pass managers, all of which actively | ||
load external plugins using corresponding entry points. The following table gives a quick summary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
load external plugins using corresponding entry points. The following table gives a quick summary | |
load external plugins using corresponding entry points. The following table summarizes |
load external plugins via corresponding entry points. | ||
Currently, there are six stages in the preset pass managers, all of which actively | ||
load external plugins using corresponding entry points. The following table gives a quick summary | ||
of each stage. For more details on the description and expectations of each stage, follow the link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of each stage. For more details on the description and expectations of each stage, follow the link | |
each stage. For more details on the description and expectations of each stage, follow the link |
@@ -35,66 +37,55 @@ | |||
Plugin Stages | |||
============= | |||
|
|||
Currently, there are 6 stages in the preset pass managers, all of which actively | |||
load external plugins via corresponding entry points. | |||
Currently, there are six stages in the preset pass managers, all of which actively |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, there are six stages in the preset pass managers, all of which actively | |
There are six stages in the preset pass managers, all of which actively |
pipeline is a :class:`.PassManager` object, whose :meth:`.PassManager.run` method takes in a | ||
:class:`.QuantumCircuit` and converts it to a :class:`.DAGCircuit`, then subjects the IR to a sequence | ||
of *passes*, finally returning a :class:`.QuantumCircuit` back. A pass is either an | ||
:class:`.AnalysisPass`, whose purpose is to calculate and store properties about the circuit in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:class:`.AnalysisPass`, whose purpose is to calculate and store properties about the circuit in the | |
:class:`.AnalysisPass`, which calculates and stores properties about the circuit in the |
At optimization level 0, the stage is empty. | ||
|
||
At optimization level 1, the stage does matrix-based resynthesis of runs of 1q gates, and very | ||
simply symbolic inverse cancellation of two-qubit gates, if they appear consecutively. This runs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simply symbolic inverse cancellation of two-qubit gates, if they appear consecutively. This runs | |
simple symbolic inverse cancellation of two-qubit gates, if they appear consecutively. This runs |
|
||
The scheduling stage, if requested, is responsible for inserting explicit :class:`~.circuit.Delay` | ||
instructions to make idle periods of qubits explicit. Plugins may optionally choose to do | ||
walltime-sensitive transformations, such as inserting dynamical decoupling sequences. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
walltime-sensitive transformations, such as inserting dynamical decoupling sequences. | |
wall clock time-sensitive transformations, such as inserting dynamical decoupling sequences. |
- Attempt to satisfy timing alignment constraints without otherwise scheduling. | ||
|
||
* - :ref:`alap <transpiler-preset-stage-scheduling-alap>` | ||
- Schedule the circuit preferring operations to be as late as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Schedule the circuit preferring operations to be as late as possible. | |
- Schedule the circuit, preferring operations to be as late as possible. |
- Schedule the circuit preferring operations to be as late as possible. | ||
|
||
* - :ref:`asap <transpiler-preset-stage-scheduling-asap>` | ||
- Schedule the circuit preferring operations to be as soon as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Schedule the circuit preferring operations to be as soon as possible. | |
- Schedule the circuit, preferring operations to be as soon as possible. |
|
||
Do nothing, unless the circuit already contains instructions with explicit timings. If there are | ||
explicitly timed operations in the circuit, insert additional padding to ensure that these timings | ||
satisfy the alignment and other constraints of the hardware. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
satisfy the alignment and other constraints of the hardware. | |
satisfy the alignment and other hardware constraints. |
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.