Port PauliEvolutionGate to Rust - #16719
Conversation
Cryoris
left a comment
There was a problem hiding this comment.
Not sure whether you're already looking for reviews, but given that you opened this as draft PR here are some 🙂
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq)] |
There was a problem hiding this comment.
I would just use Param for the time parameter, that'll also give the compatibility with Python and C for free.
There was a problem hiding this comment.
Oh I just saw 05d314a now - what's the problem with Param?
There was a problem hiding this comment.
If we want to use Param as the internal representation, we can create struct ComparableParam(Param); and implement PartialEq manually. What do you think?
There was a problem hiding this comment.
Param has eq implemented, why can't we use Param directly?
There was a problem hiding this comment.
Param is not PartialEqwhich is a trait requirement for ComparableOp which is a trait requirement for Operation.
PauliEvolutionGate to RustPauliEvolutionGate to Rust
|
One or more of the following people are relevant to this code:
|
Coverage Report for CI Build 33200982562Coverage decreased (-0.01%) to 87.734%Details
Uncovered Changes
Coverage Regressions2 previously-covered lines in 2 files lost coverage.
Coverage Stats
💛 - Coveralls |
Summary
We'd like a Rust-native data model that fills the same role as Python's
PauliEvolutiongate.I used
SparseObservableto represent the hermitianoperatorandParamto represent thetime. My implementation considersParam::Objan invariant fortime.The caller can inspect the
operatorandtimewith getter methods. The caller can also take ownership ofoperatorandtimewithSparseObservable::into_parts.PauliEvolutionisPartialEqsuch that two instances are equal if both operations have an equivalentoperatorandtime. We can comparetimewithout consideringParam::Objbecause it's an invariant.PauliEvolutionimplementsOperationandCustomOperationso that it can operate in a circuit. We've skipped thematrixandlabelmembers because there's an ongoing effort to decide how those should behave.Based on the issue description, it appears this module is intended to be used independent of Python, with a Python API coming later. FWIW, I believe it should be relatively straightforward to wrap this in a
PyPauliEvolutionusing PyO3.closes #15450
AI/LLM disclosure