Skip to content

Add symengine only mode to qpy #10705

@mtreinish

Description

@mtreinish

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 to qiskit.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 installed qiskit.qpy.load should error saying the payload only supports installations with symengine.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions