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
Update libraries for cudaq::spin_op breaking changes (#134)
This PR includes the required CUDA-QX changes that must be applied once
NVIDIA/cuda-quantum#2710 (from CUDA-Q) lands.
For that PR, most of the breaking changes are in C++, but a few Python
tests needed to be updated as well. Python changes will likely be coming
in the near future.
Note that this change actually removes more code than it adds. This is
primarily due to updates in the test code.
Here is a summary of the changes in this PR.
1. Update CMakeLists.txt files to link against `cudaq-operator` instead
of `cudaq-spin` because `cuda-spin` was removed.
2. Make use of `cudaq::spin_op_term` (a product term) where appropriate.
I currently left all the public QEC API's to use `spin_op` (a sum term),
but we may choose to update them to simply `spin_op_term` in the near
future. That would be a CUDA-QX breaking change if we do.
3. Since the new operators no longer store degrees that had implicit
`I`'s in them, we must now clarify whether we want `I` in the terms. For
QEC, this means that we will sometimes use something like
`cudaq::spin_op_term identity(0, get_num_data_qubits())`, but for
Solvers, we have eliminated all implicit `I`'s.
4. Use `get_pauli_word()` instead of `to_string(false)`.
5. Use `evaluate_coefficient()` instead of `get_coefficient()`.
6. Use `.trim()` to remove 0-cofficient terms and `.canonicalize()` to
remove `I` operations from terms. (These new helper functions help
reduce boiler-plate code.)
7. For default-constructed `cudaq::spin_op` objects, clarify whether you
want them to be initialized to the neutral sum term (i.e. 0 =
`spin_op::empty()`) or the neutral product term (i.e. 1 =
`spin_op::identity()`).
8. Change `for_each_term()` to use iterators like `for (const auto &term
: hamiltonian)`.
9. As needed, update code to reflect that `get_qubit_count()` now only
returns the number of _actual_ degrees used in the operator rather than
the "highest degree + 1" that used to be returned. If needed, make use
of the new `min_degree()` and `max_degree()` methods instead.
10. For canned test data, update to use the new serialization format (as
retrieved by `get_data_representation()`).
11. For test data comparisons, be sure to call `canonicalize` on the
test data and/or truth data as necessary in order to ensure correct
comparisons.
12. Don't use `get_raw_data()` anymore.
---------
Signed-off-by: Ben Howe <[email protected]>
0 commit comments