-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add support for BackendV2 and Target to transpiler #7113
Comments
I'm changing the target here to 0.20.0, because while the first piece of adding the target to the |
This commit makes the GatesInBasis transpiler pass target aware. It adds a new kwarg, target, which optionally takes a Target object. If it's specified the basis_gates required field will be ignored and the pass will check that the gates and their qargs are valid in the target. Part of Qiskit#7113
So for this issue I think we should concentrate just on passes that are either basis aware or noise aware. These are places where the target provides a more rich set of information and to do a thorough job compiling for a target based backend we need the full set of information instead of just the global backwards compatibility shims. For example, things like layout and routing passes don't really gain much by using the target as they operate on a global coupling graph and rely on later passes to adjust things for basis gates, etc (the exception being noise aware versions of these passes). Once we've migrated the passes where there is a functional need I feel like we can close this issue. After this we should look at expanding the functionality in the transpiler based on the extra information in the target. The big use case is updating things to leverage over complete basis gates (i.e. have the transpiler pick the best gate if there are multiple choices available) or to work with fixed angle tuned variants of arbitrary rotation gates. I've made a list of these passes here:
(I only grepped for keywords and I might have missed some, so feel free to expand the list) |
This commit updates the VF2Layout pass to be target aware. It adds a new kwarg for specifying a target and if it's specified that target object is used to define the parameters for finding the isomorphic mapping used for the layout. However, with this commit the extra information contained in the target isn't really leveraged yet and just the global coupling graph and measurement error rates are pulled from the target just as in the BackendV1 case. This commit is mostly to facilitate future expansion where we will improve the layout scoring heuristic used and having the full set of data available in the target will be useful. Part of Qiskit#7113
I can help you with some of these transpiler passes |
This commit updates the dense layout pass target aware so that at its instantiation a Target object can be specified to define the target device for compilation. When specified this target will be used for all device aware operations in the pass. When a target is specified the error matrix used is the average of all 1q and 2q operations while before the matrix was composed of just cx and readout error rates. Part of Qiskit#7113
This commit updates the consolidate blocks pass target aware so that at its instantiation a Target object can be specified to define the target device for compilation. When specified this target will be used for all device aware operations in the pass. When a target is specified the consolidate blocks pass will only consolidate blocks with instructions outside the target (both operation and qubits). Part of Qiskit#7113
* Make ConsolidateBlocks transpiler pass target aware This commit updates the consolidate blocks pass target aware so that at its instantiation a Target object can be specified to define the target device for compilation. When specified this target will be used for all device aware operations in the pass. When a target is specified the consolidate blocks pass will only consolidate blocks with instructions outside the target (both operation and qubits). Part of #7113 * Fix typo * Add release note * Add tests for target instruction_supported() method * Add Target tests for consolidate block * Apply suggestions from code review Co-authored-by: Jake Lishman <[email protected]> * Check number of arguments in ideal operation case This commit adds a check in the ideal operation case that the number of qargs is equal to the number of qubits the operation object supports. This way if you call instruction_supported() with a qargs parameter that has the wrong number of arguments even an ideally implemented gate will return false. For example, target.instruction_supported(cx, (0, 1, 2)) will return False since a CXGate object only supports 2 qubits. * Cast qargs to tuple to prevent issues with qarg list lookups * Deduplicate qubit index map creation Co-authored-by: Jake Lishman <[email protected]>
I've crossed |
* Make DenseLayout transpiler pass target aware This commit updates the dense layout pass target aware so that at its instantiation a Target object can be specified to define the target device for compilation. When specified this target will be used for all device aware operations in the pass. When a target is specified the error matrix used is the average of all 1q and 2q operations while before the matrix was composed of just cx and readout error rates. Part of #7113 * Adjust error heuristic for target case This commit adjusts the error heuristic used in dense layout. It now uses the max() error rate (so worst fidelity) operation on qubits instead of the average fidelity which was used in the previous commits. It also removes the weighting in the code based on the number of 1q ops and 2q ops. Previously the error rate for a layout was calculated as: ((sum(1q error for qubits in layout) / num_dag_qubits) * num_1q_ops - avg_1q_err) + ((sum(2q error for edges in layout subgraph) / num_dag_qubits) * num_2q_ops) however since we're considering all 2q and 1q ops now knowing exactly what's going to end up in the circuit is not exact so the weighing based on the number of ops is removed. So when a target is set the value of `num_1q_ops` and `num_2q_ops` is hard coded to 1. * Add comment explaining why we use max error rate * Make coupling_map kwarg optional * Expand DenseLayout tests * Apply suggestions from code review Co-authored-by: Kevin Hartman <[email protected]> Co-authored-by: Kevin Hartman <[email protected]>
* Make GatesInBasis transpiler pass Target aware This commit makes the GatesInBasis transpiler pass target aware. It adds a new kwarg, target, which optionally takes a Target object. If it's specified the basis_gates required field will be ignored and the pass will check that the gates and their qargs are valid in the target. Part of #7113 * Update qiskit/transpiler/passes/utils/gates_basis.py Co-authored-by: John Lapeyre <[email protected]> * No longer make basis_gates a required argument Now that we can specify a target or basis_gates it's probably best that we don't require basis_gates is always set, especially since a target will always take precedence over the basis_gates list. This commit makes basis_gates optional, but explicitly raises an error if neither basis_gates or target is set on the constructor. * Switch to op_nodes() for internal loop This commit tweaks the internal loop to be over dag.op_nodes() instead of dag.topological_op_nodes() which was used in earlier iterations. In local benchmarking dag.op_nodes() is on average 2x faster than dag.topological_op_nodes(). * Improve performance of basis_gates path This commit improves the performance of the basis_gates code path by combining the basis_gates set with the built-in directives and doing only one set lookup per iteration instead of two. Co-authored-by: John Lapeyre <[email protected]> * Fix support of ideal operations in target This commit fixes the handling of ideal operations in a target. If an operation is listed as ideal (where it applies on all qubits and doesn't have any error or duration information) in a target then the instruction properties inner dict is set to `{None: None}` to indicate this. For the gates in basis pass this just means it needs to check if the qubits for a particular instruction are None, and if it is we can treat it as a match. * Use target instruction_supported() method In #7778 a new target method, instruction_supported(), was added to simplify checking if an instruction (operation + qubits) is supported on a target object. This commit switches the GatesInBasis pass to use this internally instead of manually querying the target. Co-authored-by: John Lapeyre <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Make VF2Layout pass Target aware This commit updates the VF2Layout pass to be target aware. It adds a new kwarg for specifying a target and if it's specified that target object is used to define the parameters for finding the isomorphic mapping used for the layout. However, with this commit the extra information contained in the target isn't really leveraged yet and just the global coupling graph and measurement error rates are pulled from the target just as in the BackendV1 case. This commit is mostly to facilitate future expansion where we will improve the layout scoring heuristic used and having the full set of data available in the target will be useful. Part of #7113 * Don't raise in __init__ with no coupling map * Add release note * Apply suggestions from code review Co-authored-by: Jake Lishman <[email protected]> * Fix test to make it clear it's using target graph and not the coupling map * Handle edge case where target doesn't have measurement defined This commit fixes an edge case in the heurstic scoring where if a target is present but doesn't have measurement defined we always return a score of 0. In the case measure ment doesn't have measurement defined this will fall back to looking at the degree of the qubit instead of trying to use the readout error rate. * Update qiskit/transpiler/passes/layout/vf2_layout.py Co-authored-by: Luciano Bello <[email protected]> * Simplify heuristic scoring logic Co-authored-by: Luciano Bello <[email protected]> * Fix lint Co-authored-by: Jake Lishman <[email protected]> Co-authored-by: Luciano Bello <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit adds two new constructor arguments to the Unroll3qOrMore transpiler pass, target and basis_gates, which are used to specify a backend target and basis gate list respectively. If these are specified the pass will not decompose any multiqubit operations present in the circuit if they are in the target or basis_gates list. Fixes Qiskit#5518 Related to Qiskit#7812 Part of Qiskit#7113
* Support target and basis gates in Unroll3qOrMore transpiler pass This commit adds two new constructor arguments to the Unroll3qOrMore transpiler pass, target and basis_gates, which are used to specify a backend target and basis gate list respectively. If these are specified the pass will not decompose any multiqubit operations present in the circuit if they are in the target or basis_gates list. Fixes #5518 Related to #7812 Part of #7113 * Update releasenotes/notes/unroll3q-target-bf57cc4365808862.yaml Co-authored-by: Naoki Kanazawa <[email protected]> * Fix lint * Fix release-note typo Co-authored-by: Naoki Kanazawa <[email protected]> Co-authored-by: Jake Lishman <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit makes the UnrollCustomDefinitions transpiler pass target aware. A new kwarg, target is added to the pass constructor and if specified the Target object passed in is used to check if the target backend supports the gates in the circuit instead of the basis_gates list. Part of Qiskit#7113
* Make UnrollCustomDefinitions pass target aware This commit makes the UnrollCustomDefinitions transpiler pass target aware. A new kwarg, target is added to the pass constructor and if specified the Target object passed in is used to check if the target backend supports the gates in the circuit instead of the basis_gates list. Part of #7113 * Apply suggested doc fixes from code review Co-authored-by: Kevin Hartman <[email protected]> * Simplify custom gate detection logic in pass This commit simplifies and deduplicates the logic for the pass around detecting whether a particular instruciton is supported. Co-authored-by: Kevin Hartman <[email protected]> Co-authored-by: Kevin Hartman <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
With #9263 recently merging this is finally complete |
What is the expected enhancement?
With the BackendV2/Target interface being added in #5885 we have more data available to the transpiler to inform the passes on the characteristics and constraints of a backend. However as of right now none of the passes in the transpiler know how to take advantage of this extra information. We need to update the
transpile()
/PassManagerConfig
/preset pass manager constructors to deal with passing aTarget
object around and then update some passes to leverage the extra information.Primarily for 0.19.0 we probably will need to update the
BasisTranslator
to respect the qargs of an instruction,CheckGateDirection
/GateDirection
to work with Target instead of a coupling map, and optionallyUnitarySynthesis
to get noise parameters from a Target. While pretty much every other pass will need to be updated too those can happen over time the first 2 should be enough sotranspile()
will respect a heterogeneous gate set which is our goal for 0.19.0.The text was updated successfully, but these errors were encountered: