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

Merged
merged 15 commits into from
Feb 5, 2025

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 13160133967

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

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 365 unchanged lines in 25 files lost coverage.
  • Overall coverage decreased (-0.2%) to 88.659%

Files with Coverage Reduction New Missed Lines %
crates/circuit/src/dag_circuit.rs 1 89.36%
crates/accelerate/src/unitary_synthesis.rs 1 92.97%
qiskit/providers/fake_provider/fake_backend.py 1 85.51%
crates/qasm2/src/expr.rs 1 94.23%
qiskit/providers/basic_provider/basic_provider_tools.py 1 83.33%
crates/circuit/src/operations.rs 1 89.61%
qiskit/pulse/transforms/canonicalization.py 1 93.44%
qiskit/pulse/transforms/base_transforms.py 2 86.96%
qiskit/pulse/schedule.py 3 88.6%
qiskit/result/result.py 3 83.74%
Totals Coverage Status
Change from base Build 13118695608: -0.2%
Covered Lines: 79024
Relevant Lines: 89133

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

qiskit/transpiler/__init__.py Show resolved Hide resolved
qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved
qiskit/transpiler/__init__.py Show resolved Hide resolved
@jakelishman
Copy link
Member Author

The general rule to apply is if the number is under 10, we spell it out

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.

Copy link
Collaborator

@beckykd beckykd left a 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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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

Copy link
Member Author

Choose a reason for hiding this comment

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

"reason about" here I think is meaning more about the idea of using programmatic logic on the output, rather than a user sitting and thinking - "understand" isn't quite right, but "reason about" is something we say

qiskit/transpiler/preset_passmanagers/plugin.py Outdated Show resolved Hide resolved
qiskit/transpiler/preset_passmanagers/plugin.py Outdated Show resolved Hide resolved
qiskit/transpiler/preset_passmanagers/plugin.py Outdated Show resolved Hide resolved
qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved
qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved

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

Choose a reason for hiding this comment

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

Suggested change
walltime-sensitive transformations, such as inserting dynamical decoupling sequences.
wall clock time-sensitive transformations, such as inserting dynamical decoupling sequences.

Copy link
Member Author

Choose a reason for hiding this comment

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

"walltime" is an equally common spelling of this, and I think we'd end up with "wall-clock-time-sensitive" if we did that, which seems a bit verbose

qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved
qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved
qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved
@jakelishman jakelishman added stable backport potential The bug might be minimal and/or import enough to be port to stable and removed stable backport potential The bug might be minimal and/or import enough to be port to stable labels Feb 4, 2025
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 a lot Jake, this is a great improvement on the previous docs. I managed to finally finish reading it and suggested a few minor changes, other than that LGTM.

qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved
qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved
qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved
qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved
Higher-level user-facing explanation of the layout stage in the IBM Quantum guide.

The layout stage is responsible for making an initial mapping between the virtual qubits of the
input circuit, and the hardware qubits of the target. This includes expanding the input circuit
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we could also introduce "physical qubits" here, or is this a term we prefer to avoid? (I never keep up with these trends)

Copy link
Member Author

Choose a reason for hiding this comment

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

In the qiskit.circuit documentation, we define "physical qubit" to be one type of "hardware qubit" (the other is a "logical qubit"). In those terms, the compiler deals in "hardware qubits", because it doesn't care if the Target was presented as a low-level Target (as it always is right now) or a logical-qubit Target (as it one day may be).

Comment on lines +344 to +345
If you write your own layout plugin, you might find :func:`.generate_embed_passmanager` useful for
automating the "embedding" stage of the layout application.
Copy link
Contributor

Choose a reason for hiding this comment

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

I just learned something new

Copy link
Member Author

Choose a reason for hiding this comment

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

ha yeah - I've seen too many people struggle with this, so I thought it was useful to call it out

qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved
qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved
qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved
Comment on lines +1177 to +1178
This section is still here because the content hasn't fully migrated to other places yet, unlike
other discussions of the components of quantum compilation.
Copy link
Contributor

Choose a reason for hiding this comment

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

I was just going to comment on this (I was looking at the rendered version), good clarification.

ElePT
ElePT previously approved these changes Feb 5, 2025
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.

LGTM! I will not add the PR to the queue yet in case @beckykd has any final comments, but I think it's good to merge.

mtreinish
mtreinish previously approved these changes Feb 5, 2025
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

Overall this LGTM too, I left a few small questions inline but nothing worth blocking over. If you don't feel there is anything to change related to my questions I think we can enqueue this for merging.

qiskit/transpiler/__init__.py Outdated Show resolved Hide resolved
qiskit/transpiler/__init__.py Show resolved Hide resolved

.. note::

In Qiskit 1.x, translation plugins need not output gates with the correct
Copy link
Member

Choose a reason for hiding this comment

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

This implies the intent to change this in Qiskit 2.0? Is there a tracking issue or PR for this? I worry if we're not tracking it < 1 month away from the feature freeze we'll lose the thread on this.

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'm planning on doing it - I've got it written on my todo list. I've opened a proper tracking issue at #13787.

@mtreinish mtreinish added this pull request to the merge queue Feb 5, 2025
Merged via the queue into Qiskit:main with commit 4d2265f Feb 5, 2025
17 checks passed
mergify bot pushed a commit that referenced this pull request Feb 5, 2025
* Increase documentation of built-in transpiler plugins

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.

* Fix cross references in release notes

* Include Elena's suggestions

Co-authored-by: Elena Peña Tapia <[email protected]>

* Apply copy-editing suggestions

Co-authored-by: abbycross <[email protected]>

* Add manual copy-editing suggestions

* Reflow text

* Copy edit

Co-authored-by: Rebecca Dimock <[email protected]>

* Add missed copy edit

Co-authored-by: Rebecca Dimock <[email protected]>

* Reflow line breaks

* Apply Elena's suggestions

Co-authored-by: Elena Peña Tapia <[email protected]>

* Apply Elena's suggestions that needed line wraps

* Correct layout description

* Mark stochastic plugin as deprecated

---------

Co-authored-by: Elena Peña Tapia <[email protected]>
Co-authored-by: abbycross <[email protected]>
Co-authored-by: Rebecca Dimock <[email protected]>
(cherry picked from commit 4d2265f)

# Conflicts:
#	qiskit/transpiler/__init__.py
jakelishman added a commit that referenced this pull request Feb 5, 2025
* Increase documentation of built-in transpiler plugins

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.

* Fix cross references in release notes

* Include Elena's suggestions

Co-authored-by: Elena Peña Tapia <[email protected]>

* Apply copy-editing suggestions

Co-authored-by: abbycross <[email protected]>

* Add manual copy-editing suggestions

* Reflow text

* Copy edit

Co-authored-by: Rebecca Dimock <[email protected]>

* Add missed copy edit

Co-authored-by: Rebecca Dimock <[email protected]>

* Reflow line breaks

* Apply Elena's suggestions

Co-authored-by: Elena Peña Tapia <[email protected]>

* Apply Elena's suggestions that needed line wraps

* Correct layout description

* Mark stochastic plugin as deprecated

---------

Co-authored-by: Elena Peña Tapia <[email protected]>
Co-authored-by: abbycross <[email protected]>
Co-authored-by: Rebecca Dimock <[email protected]>
(cherry picked from commit 4d2265f)
github-merge-queue bot pushed a commit that referenced this pull request Feb 6, 2025
* Increase documentation of built-in transpiler plugins

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.

* Fix cross references in release notes

* Include Elena's suggestions

Co-authored-by: Elena Peña Tapia <[email protected]>

* Apply copy-editing suggestions

Co-authored-by: abbycross <[email protected]>

* Add manual copy-editing suggestions

* Reflow text

* Copy edit

Co-authored-by: Rebecca Dimock <[email protected]>

* Add missed copy edit

Co-authored-by: Rebecca Dimock <[email protected]>

* Reflow line breaks

* Apply Elena's suggestions

Co-authored-by: Elena Peña Tapia <[email protected]>

* Apply Elena's suggestions that needed line wraps

* Correct layout description

* Mark stochastic plugin as deprecated

---------

Co-authored-by: Elena Peña Tapia <[email protected]>
Co-authored-by: abbycross <[email protected]>
Co-authored-by: Rebecca Dimock <[email protected]>
(cherry picked from commit 4d2265f)

Co-authored-by: Jake Lishman <[email protected]>
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.

7 participants