Hamiltonian expectation value in one call

Open
#18 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python, rust

Research direction

Start by locating the Rust code that parses Pauli terms and computes qc.expectation(terms), then trace how Python exposes that API. Check how terms are represented and how gradient() accepts inputs; the issue proposes a reusable PauliSum and sharing amplitude passes by flip mask. Done means a Hamiltonian object can be reused with expectation() and passed to gradient(), with the grouped computation described in the issue.

Written by the indexing model from the issue text.

Description

enhancement
What you want to do

coeffs @ qc.expectation(terms) works, but it builds an array of one value per term, and there's
no single object for a Hamiltonian that can be reused across calls or passed to gradient() (M3).

Implementation notes
  • Parse once in Rust. Terms with the same X/Y positions (the same flip mask) can share one pass
    over the amplitudes, which cuts passes from (number of terms) to (number of distinct flip masks).
    For example, all Z-only terms share one pass.
What it could look like
H = qsengine.PauliSum({"ZZI": 1.0, "IZZ": 1.0, "XII": -0.5})
qc.expectation(H)       # -> float
Contributing
  • I would like to open a pull request for this (see CONTRIBUTING.md).
Dominant language
Rust
Stars
1
Forks
0
Avg merge
12m
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from kaiwave/qsengine

All issues in kaiwave/qsengine

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.