Add symengine only mode to qpy #10705
Labels
mod: qpy
Related to QPY serialization
performance
priority: high
type: feature request
New feature or request
Milestone
What should we add?
Right now QPY solely uses sympy to represent
ParameterExpression
objects in a circuit being serialized. This is done because our preferred library for representing symbolic expressions, symengine doesn't support all the platforms that Qiskit does, so we can not always rely on symengine being available when a qpy payload is deserialized. Sympy being our fallback (and significantly slower) option is always available so it is the logical choice to serialize the expression and then if symengine is available we convert from sympy objects to symengine objects. However, while this maximizes compatibility it comes with a real runtime cost, especially for circuits with lots of unbound parameter expressions. To address this we should expose an option toqiskit.qpy.dump
to assert that symengine will always be available. This would use symengine native serialization which won't have the same runtime issues. If the deserialization side doesn't have symengine installedqiskit.qpy.load
should error saying the payload only supports installations with symengine.The text was updated successfully, but these errors were encountered: