Skip to content

Port PauliEvolutionGate to Rust - #16719

Open
davidfcohen wants to merge 30 commits into
Qiskit:mainfrom
davidfcohen:port-pauli-evolution
Open

Port PauliEvolutionGate to Rust#16719
davidfcohen wants to merge 30 commits into
Qiskit:mainfrom
davidfcohen:port-pauli-evolution

Conversation

@davidfcohen

@davidfcohen davidfcohen commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

We'd like a Rust-native data model that fills the same role as Python's PauliEvolution gate.

I used SparseObservable to represent the hermitian operator and Param to represent the time. My implementation considers Param::Obj an invariant for time.

The caller can inspect the operator and time with getter methods. The caller can also take ownership of operator and time with SparseObservable::into_parts.

PauliEvolution is PartialEq such that two instances are equal if both operations have an equivalent operator and time. We can compare time without considering Param::Obj because it's an invariant.

PauliEvolution implements Operation and CustomOperation so that it can operate in a circuit. We've skipped the matrix and label members 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 PyPauliEvolution using PyO3.

closes #15450

AI/LLM disclosure

  • I didn't use LLM tooling, or only used it privately.
  • I used the following tool to help write this PR description:
  • I used the following tool to generate or modify code:

@raynelfss raynelfss added the Rust This PR or issue is related to Rust code in the repository label Aug 7, 2026
@github-project-automation github-project-automation Bot moved this to Ready in Qiskit 2.6 Aug 7, 2026
@raynelfss raynelfss added this to the 2.6.0 milestone Aug 7, 2026

@Cryoris Cryoris left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just use Param for the time parameter, that'll also give the compatibility with Python and C for free.

@Cryoris Cryoris Aug 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I just saw 05d314a now - what's the problem with Param?

@davidfcohen davidfcohen Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to use Param as the internal representation, we can create struct ComparableParam(Param); and implement PartialEq manually. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Param has eq implemented, why can't we use Param directly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Param is not PartialEqwhich is a trait requirement for ComparableOp which is a trait requirement for Operation.

Comment thread crates/circuit_library/src/pauli_evolution_gate.rs Outdated
@davidfcohen davidfcohen self-assigned this Aug 12, 2026
@davidfcohen davidfcohen linked an issue Aug 12, 2026 that may be closed by this pull request
Comment thread crates/circuit_library/src/pauli_evolution_gate.rs Outdated
@davidfcohen davidfcohen changed the title [WIP] Port PauliEvolutionGate to Rust Port PauliEvolutionGate to Rust Aug 14, 2026
@davidfcohen
davidfcohen requested a review from Cryoris August 14, 2026 19:35
@davidfcohen davidfcohen added the Changelog: None Do not include in the GitHub Release changelog. label Aug 14, 2026
@davidfcohen
davidfcohen marked this pull request as ready for review August 14, 2026 22:14
@davidfcohen
davidfcohen requested a review from a team as a code owner August 14, 2026 22:14
@qiskit-bot

Copy link
Copy Markdown
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@coveralls

coveralls commented Aug 28, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 33200982562

Coverage decreased (-0.01%) to 87.734%

Details

  • Coverage decreased (-0.01%) from the base build.
  • Patch coverage: 39 uncovered changes across 1 file (57 of 96 lines covered, 59.38%).
  • 2 coverage regressions across 2 files.

Uncovered Changes

File Changed Covered %
crates/circuit_library/src/pauli_evolution_gate.rs 96 57 59.38%

Coverage Regressions

2 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
crates/circuit/src/parameter/parameter_expression.rs 1 90.32%
crates/qasm2/src/lex.rs 1 93.06%

Coverage Stats

Coverage Status
Relevant Lines: 131175
Covered Lines: 115085
Line Coverage: 87.73%
Coverage Strength: 979360.12 hits per line

💛 - Coveralls

@davidfcohen davidfcohen added type: enhancement It's working, but needs polishing mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library type: feature request New feature or request and removed type: enhancement It's working, but needs polishing type: feature request New feature or request labels Aug 28, 2026
@davidfcohen davidfcohen removed their assignment Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: None Do not include in the GitHub Release changelog. mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library performance Rust This PR or issue is related to Rust code in the repository

Projects

Status: Ready

Development

Successfully merging this pull request may close these issues.

Port PauliEvolutionGate to Rust

6 participants