Parameterised circuits and gradients (for VQE and QAOA)

Offen
#10 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
python, rust

Rechercherichtung

Start by reading the circuit instruction and matrix construction code, then trace how gate fusion and expectation evaluation work; the issue does not name specific files or tests. Compare adjoint differentiation and parameter-shift behavior against the requested examples, including the special rules for crz and u. Done means parameter rebinding avoids Python re-recording and gradients are available for the stated observables.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

enhancement
What you want to do

expectation() already gives VQE/QAOA energies, but an optimiser loop has to rebuild the whole
circuit for every parameter set and estimate gradients by finite differences. Those are slow and
inaccurate, especially on the 32-bit GPU.

Implementation notes
  • Store the parameter index in the instruction and build the matrix at run time. Gate fusion has to
    happen after the parameters are bound.
  • Adjoint differentiation is the efficient default: one forward pass plus one backward pass,
    holding about three state vectors, for all parameters at once.
  • Parameter-shift as an alternative that works with shots. The two-term rule (±π/2) is valid for
    rx, ry, rz, p and cp. crz has generator eigenvalues {0, ±½} and needs the four-term rule, and
    u should be differentiated through its three angles separately.
  • Rebinding parameters must not re-record the circuit from Python.
What it could look like
theta = qsengine.Parameter("theta")
qc = qsengine.QuantumCircuit(2)
qc.ry(0, theta)
qc.cx(0, 1)

qc.expectation("ZZ", params={"theta": 0.4})
qc.gradient(["ZZ", "XX"], coeffs=[1.0, 0.5], params={"theta": 0.4})   # -> {"theta": dE/dtheta}
Contributing
  • I would like to open a pull request for this (see CONTRIBUTING.md).
Vorherrschende Sprache
Rust
Sterne
1
Forks
0
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus kaiwave/qsengine

Alle Issues in kaiwave/qsengine

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.