[WIP] support for fixed angle gates in target conversion #1750
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Qiskit Target supports gate definition for multiple discrete angles. However our
convert_to_target
converter doesn't nicely support this mechanism. This PR overhaul the converter to support this feature.Details and comments
Transpiler (translation) requires gate definition (e.g. matrix), which is directly attached to the Qiskit
Gate
object in the standard library. On the other hand,GateConfig
in the V1 configuration model doesn't have this definition. The definition is obtained by the name matching, and thusGateConfig.name
must be defined in the dictionary returned from theget_standard_gate_name_mapping
function, e.g. sx, x, rx, ...However, when we define new operation in the Qiskit
Target
via the.add_instruction
method, one must specify the uniquename
argument when the entry is defined for a specific gate angle. This indicatesGateConfig
must also define unique label for fixed gate angle entries. Since original Qiskit model is not flexible, this PR redefines the similar model with.label
field in the qiskit-ibm-runtime (to avoid version mismatch issue).Alternatively, we can still use the Qiskit model with custom name with regex, e.g.
rx_30
, but we need to mange this regex pattern both on client and server side. Also this pattern becomes complicated when the gate has more than one parameters; gate with two parameters and only one parameter is fixed,u2_1.23_p1
->U2(1.23, Parameter("P1"))
. In my opinion this approach is easy to implement but hard to maintain.I prefer using the custom model with new
label
field, because this approach allows the client software (qiskit-ibm-runtime) to be agnostic to the gate naming convention in IBM Quantum systems.I also introduced new backend configuration implementation with pydantic since this is already required package and much more performant and robust compared with the Qiskit implementation (I needed to update configuration to use new
GateConfig
model).