You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Combine Python types in PackedInstructions (Qiskit#15277)
* Combine Python types in PackedInstructions
This commit migrates the 3 python variants in PackedOperation to be a
single variant. The 3 types PyGate, PyInstruction, and PyOperation are
very similar and are only separate for typing reasons. This commit moves
to only having a single struct and adding the typing information as an
enum that wraps that struct representation. This is then propogated to
the PackedInstruction type and move us from 3 separate fields in the
struct to just a single one. This frees up more space for other
operation types in the future. OperationRef keeps the distinct variants
for Gate, Instruction, and Operation. This simplifies the required
changes as most places interact with OperationRef instead of the owned
types.
The other motivation for this is as an early step towards fixing Qiskit#14240.
This commit simplifies and consolidates the places that explicitly wrap
python usage in the circuit crate. This will make it easier to
conditionally compile things when we start to do that.
The other option considered was also moving to a single struct and setting
a `py_op_type` field inside the struct that was an enum to differentiate
the Python type. However, doing this inside the struct would require
significant changes to the usage of Python types in a circuit. Instead of
matching on the type off of OperationRef it would need to be a double
mapping first on OperationRef then on `py_op_type` field. Using the
outer enum prevents this and makes it a bit easier to match in places.
* Add missing alignment on PyOperationTypes
As we insert PyOperationTypes in the PackedInstruction we need to ensure
the alignment so that there are free bits to put the discriminant of the
PackedOperation in the u64. This was overlooked in earlier versions of
this PR branch and would have caused issues on other platforms
potentially.
* Fix typo in rebase
0 commit comments