Add periodic boundary support to banded sparse-access oracles

Aperta
#107 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 8 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
38/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Start with python/cudaq_algorithms/sparse/_banded.py and the existing banded oracle tests; trace how locations, values, inverses, and normalization are defined. Implement and test the periodic mode against independently assembled quantized circulant matrices, including alias and small-dimension cases. Done means the stated oracle, unitarity, QSVT solve, documentation, and runnable example criteria pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

banded_oracles currently clips entries that cross the matrix boundary, although its location oracle already computes shifts modulo the register dimension. Add an opt-in periodic mode so constant-coefficient circulant stencils can use SparseOracleEncoding and QSVT through arithmetic oracles, without a per-entry QROM table.

A motivating example is the periodic diffusion-reaction operator
A = (2 + mass) I - S - S.T, where S is a cyclic shift, N = 2**n, and mass > 0 makes the system invertible.

Proposed API
from cudaq_algorithms.sparse import SparseOracleEncoding, banded_oracles

n = 3
mass = 4.0 / 9.0

oracles = banded_oracles(
    offsets=[-1, 0, 1],
    band_values=[-1.0, 2.0 + mass, -1.0],
    num_system=n,
    value_bits=8,
    boundary="periodic",
)
encoding = SparseOracleEncoding(oracles, num_system=n)

Preserve the current clipped behavior as the default, for example boundary="open". This names the existing band truncation; it does not introduce a general PDE boundary-condition solver.

Implementation considerations

The natural extension point is sparse/_banded.py. The generic SparseOracleEncoding assembler should not need a periodic-specific algorithm.

  • Locations: retain the existing modular shift and its explicit inverse.
  • Values: periodic bands retain their coefficients across wrap-around instead of being masked to zero.
  • Signed entries: compute the upper bit from the actual wrapped row/column ordering. The current offset-sign rule is valid for clipped bands, but reverses at a periodic boundary. Simply removing the value mask would give incorrect signs for negative wrap-around entries.
  • Equivalent offsets: define whether offsets congruent modulo N are combined or rejected with a clear error. Cover the self-inverse half-period shift and the N=2 case, where +1 and -1 address the same neighbor. Preserve a valid reverse-slot involution.
  • Contracts: retain clean scratch, zero-valued padded slots, explicit oracle inverses, the existing value-quantization model, and honest normalization/register accounting.

Initially scope this to one-dimensional periodic/circulant matrices. Coordinate-wise periodic boundaries on multidimensional meshes need a separate design; wrapping a flattened index is not equivalent.

Acceptance criteria
  • Existing clipped-mode tests and behavior remain unchanged.
  • Test periodic location/value oracles and their inverses, including coherent inputs, clean scratch, unused slots, and signed wrap-around entries.
  • Compare the good block against an independently assembled quantized circulant matrix divided by the reported normalization; check unitarity and Hermiticity on the supported clean-scratch domain.
  • Test the documented policy for offset aliases, half-period shifts, and very small dimensions.
  • Add a small QSVT solve of the shifted periodic Laplacian, checked against an independent FFT/classical solution, with matrix-quantization and inverse-polynomial errors accounted for separately.
  • Document the option and provide a runnable sparse-access example. Report its register and normalization costs explicitly; it need not match the qubit count of a specialized compact LCU encoding.
Lingua principale
Python
Stelle
19
Fork
18
Merge medio
5g 18h
PR unite (30g)
14

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NVIDIA/cudaq-algorithms

Tutte le issue di NVIDIA/cudaq-algorithms

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.