qiskit icon indicating copy to clipboard operation
qiskit copied to clipboard

Add support for custom backend transpiler stages

Open mtreinish opened this issue 3 years ago • 3 comments

Summary

This commit adds initial support to the transpiler and backend interfaces for backends to specify custom transpiler stages. There are often specific hardware compilation requirements that a general purpose transpiler's preset pass manager can't account for. While we strive to provide interfaces to outline all the hardware constraints via the Target class and general purposes passes to fit and optimize an input circuit to the target backend there are some constraints that aren't easily addressed in a general purpose way. For such cases having an interface for a specific backend which has the necessary context of its own constraints to provide custom compilation steps to integrate into the pipeline is a necessary feature. The two initial examples of this are custom basis gate translation and custom scheduling. This commit adds two new hook point methods for BackendV2 objects, get_translation_stage_method() and get_scheduling_stage_method(). These allow for backends to specify custom default methods to use for these stages, typically via the plugin interface. This should enable backends with custom hardware specific requirements to influence the compilation process so that any required custom steps to ensure the output circuit is executable. In the future we may add additional hook points in a similar manner to enable backends to assert more hardware-specific compilation where the need arises.

Details and comments

Closes #8329

mtreinish avatar Aug 31 '22 15:08 mtreinish

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

qiskit-bot avatar Aug 31 '22 15:08 qiskit-bot

Pull Request Test Coverage Report for Build 3178304457

  • 11 of 12 (91.67%) changed or added relevant lines in 3 files are covered.
  • 77 unchanged lines in 6 files lost coverage.
  • Overall coverage decreased (-0.09%) to 84.611%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/transpiler/preset_passmanagers/level3.py 1 2 50.0%
<!-- Total: 11 12
Files with Coverage Reduction New Missed Lines %
qiskit/extensions/quantum_initializer/squ.py 2 79.78%
qiskit/pulse/library/waveform.py 3 91.49%
src/dense_layout.rs 4 91.89%
src/sabre_swap/neighbor_table.rs 7 69.23%
src/sampled_exp_val.rs 14 63.93%
src/results/marginalization.rs 47 61.49%
<!-- Total: 77
Totals Coverage Status
Change from base Build 3173846729: -0.09%
Covered Lines: 61595
Relevant Lines: 72798

💛 - Coveralls

coveralls avatar Aug 31 '22 16:08 coveralls

I pivoted the PR to have the hook point methods to return a method name string to be used as the default method when calling transpile on the backend in: https://github.com/Qiskit/qiskit-terra/pull/8648/commits/cf6a7ec90ab8b8b150abb92cce15a7935a0b6994

mtreinish avatar Sep 21 '22 22:09 mtreinish