qiskit/test/python/qpy
Matthew Treinish 9e455f2f0d
Handle an optional symengine and sympy in qpy (#13917)
* Document that symengine is optional for qpy.load

This commit changes the API for qpy.load() to make it explicit that
symengine may not be installed in the future but is a requirement for
deserializing certain payloads that were generated using symengine.
We're expecting to drop symengine as a requirement with #13278 which
should improve Qiskit's installation story and also will facilitate
adding a C api for circuits. But the qpy v10, v11, and v13 have a hard
requirement on symengine (specifically 0.11.0 and 0.13.0) to be able to
deserialize `ParameterExpression` if the symbolic encoding was set to
use it. Since the function needs to support being able to deserialize
these payloads symengine will need to be installed. This commit adds the
document and release note to indicate this change in behavior.

* Raise QPY compatibility version to remove symengine and sympy dependency

This commit raises the qpy compatibility version to QPY format version
13. As the larger PR is planning for a world without symengine installed
by default this becomes a problem for the generation side too. This
becomes a blocker for using QPY < 13 in the future so this commit opts
to just raise the minimum verison to get ahead of any potential issues.

* Add HAS_SYMENGINE check on load function

* Correct logic for ucr*_dg gates name changing

* Add feature string to optional decorator

* Prepare for an optional sympy

In addition to making symengine optional #13278 should also enable us to
make sympy optional. It would only be potentially needed for loading QPY
payloads that were generated using sympy encoding, but also some
visualization functions. This commit lays the groundwork for removing it
as a dependency by outlining the API changes for the functions that will
optionally depend on sympy and raise an exception if it's not installed.
It won't be possible to trigger the exception with sympy in the
requirements list, but when we do remove it the API is prepared for it.

* Fix release note categorization

* Add missing optional on template substitution
2025-03-05 19:00:46 +00:00
..
__init__.py QPY schedule serialization (#7300) 2022-06-23 00:25:30 +00:00
test_circuit_load_from_qpy.py Handle an optional symengine and sympy in qpy (#13917) 2025-03-05 19:00:46 +00:00
test_serialize_value_objects.py Fix qpy serialization of substitution of type `ParameterExpression` (#13890) 2025-03-02 00:11:41 +00:00