Parameterised circuits and gradients (for VQE and QAOA)

Abierto
#10 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python, rust

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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).
Lenguaje dominante
Rust
Estrellas
1
Forks
0
Merge medio
12 min
PR fusionados (30 d)
4

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de kaiwave/qsengine

Todos los issues de kaiwave/qsengine

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.