- Target.instruction_supported(operation_name=None, qargs=None, operation_class=None, parameters=None)[source]¶
Return whether the instruction (operation + qubits) is supported by the target
operation_name (str) -- The name of the operation for the instruction. Either this or
operation_classmust be specified, if both are specified
operation_classwill take priority and this argument will be ignored.
qargs (tuple) -- The tuple of qubit indices for the instruction. If this is not specified then this method will return
Trueif the specified operation is supported on any qubits. The typical application will always have this set (otherwise it's the same as just checking if the target contains the operation). Normally you would not set this argument if you wanted to check more generally that the target supports an operation with the
parameterson any qubits.
operation_class (qiskit.circuit.Instruction) -- The operation class to check whether the target supports a particular operation by class rather than by name. This lookup is more expensive as it needs to iterate over all operations in the target instead of just a single lookup. If this is specified it will supersede the
operation_nameargument. The typical use case for this operation is to check whether a specific variant of an operation is supported on the backend. For example, if you wanted to check whether a
RXGatewas supported on a specific qubit with a fixed angle. That fixed angle variant will typically have a name different than the object's
"rx") in the target. This can be used to check if any instances of the class are available in such a case.
parameters (list) --
A list of parameters to check if the target supports them on the specified qubits. If the instruction supports the parameter values specified in the list on the operation and qargs specified this will return
Truebut if the parameters are not supported on the specified instruction it will return
False. If this argument is not specified this method will return
Trueif the instruction is supported independent of the instruction parameters. If specified with any
Parameterobjects in the list, that entry will be treated as supporting any value, however parameter names will not be checked (for example if an operation in the target is listed as parameterized with
"phi"is passed into this function that will return
True). For example, if called with:
parameters = [Parameter("theta")] target.instruction_supported("rx", (0,), parameters=parameters)
RXGateis suporrted on qubit 0 that will accept any parameter. If you need to check for a fixed numeric value parameter this argument is typically paired with the
operation_classargument. For example:
target.instruction_supported("rx", (0,), RXGate, parameters=[pi / 4])
Trueif an RXGate(pi/4) exists on qubit 0.
Trueif the instruction is supported and
Falseif it isn't.
- Return type