Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.21k stars 2.36k forks source link

Factor quantum_info-dependent code out of `opflow.AbelianGrouper` #6624

Closed jlapeyre closed 1 year ago

jlapeyre commented 3 years ago

The code in abelian_grouper.py does not depend in an essential way on any part of opflow. It could be factored out and moved to quantum_info, or to some organized code whose only qiskit dependency is quantum_info. The opflow class could then call this factored-out code.

woodsp-ibm commented 3 years ago

Let me link this since it was about the grouping code Qiskit/retworkx#347 in that the groups being returned is not deterministic and under Aer, which uses the seed with RNG once per job, a change in ordering of groups, and hence the circuits that were executed to measure their expectations, led to different unit test outcomes.

mtreinish commented 3 years ago

While we working on the retworkx issue couldn't you just do sorted() on the output dict? The issue is the insertion order is undefined (because the underlying result object is a HashMap that doesn't define an order for iteration) so iteration order is different but the output should be deterministic, it's just a different insertion order. Either way I plan to have that issue resolved for at least the graph_greedy_color() function for the next release (which I'm targeting to have out before terra 0.19.0)

jlapeyre commented 3 years ago

@irajput will be working on this.

ikkoham commented 3 years ago

Thanks. Nice proposal. I think it is better after the internal data of SparsePauliOp is replaced by PauliList.

jlapeyre commented 3 years ago

I think it is better after the internal data of SparsePauliOp is replaced by PauliList

Yes. The first step would be to implement grouping for PauliList in quantum_info. This is independent of opflow.

jlapeyre commented 1 year ago

Since OpFlow is deprecated, reorganizing grouping of Paulis is better addressed elsewhere.

Note however that a part of this work that will continue to be useful was done in #6690