Add modular increment and decrement arithmetic primitives
I maintainer di solito rispondono entro 8 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Start with python/cudaq_algorithms/primitives/_arithmetic.py and the existing exports from cudaq_algorithms.primitives; read the current constant arithmetic kernels and their tests to follow the project’s conventions. Implement and test increment and decrement against the stated wraparound, slice, inverse, and control contracts. Done includes API exports, documentation, exhaustive small-register and statevector tests, gate and resource counts, and comparisons with the CDKM and QFT adders at K=1.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Cyclic shifts, counters, and structured block encodings often need only j -> j +/- 1 mod 2**n. Add specialized public increment and decrement device kernels alongside the existing generic arithmetic.
The current arithmetic module offers:
- CDKM
add_constant/subtract_constant, which take ann-qubit work register and a carry qubit. - QFT constant addition/subtraction, which need no work register but use Fourier transforms and phase operations.
A dedicated binary increment/decrement would provide a simple interface and another resource tradeoff for this common special case.
Proposed API and contract
from cudaq_algorithms.primitives import increment, decrement
# Inside a CUDA-Q kernel; target[0] is the least-significant bit.
increment(target) # target <- target + 1 mod 2**target.size()
decrement(target) # exact inverse
# Incrementing the upper subregister adds a power-of-two offset.
increment(target[2:]) # full register <- full register + 4 mod 2**n
- In-place, little-endian, modular arithmetic: overflow/underflow wraps; no carry output.
- No scratch register, constant-bit array, or internal qubit allocation.
- Empty views are no-ops; a one-qubit increment or decrement is X.
- Preserve coherent amplitudes and relative phases.
- Support external controls through
cudaq.control, with disjoint control and target registers.
Candidate implementation
For increment, sweep target bits from most significant down to bit 1, flipping bit k controlled on every lower bit being 1; finish with X on bit 0. Decrement is the explicitly reversed gate sequence, consistent with the arithmetic module's hand-written inverse style.
At the expressed-circuit level, this is one X and n-1 controlled-X operations with control counts 1, ..., n-1. This is not a claim of linear elementary-gate or Toffoli cost. Larger controlled operations must be accounted for under the chosen decomposition/backend.
Acceptance criteria
- Export the kernels from
cudaq_algorithms.primitivesand document their register, wraparound, and control contracts. - Exhaustively test small-register basis permutations, both wrap boundaries, width one, empty views, and inverse round trips.
- Compare complete statevectors on complex superpositions and test superposed external controls, including identity on the inactive control branch.
- Test register slices, including power-of-two shifts that leave the lower bits unchanged.
- Pin logical gate/control counts and allocated-qubit counts. Report decomposed counts/depth and any decomposition workspace where available; distinguish Toffolis from higher-controlled X operations.
- Compare the specialization with the existing CDKM and QFT constant adders at
K=1, including GPU statevector execution where available. Document the measured tradeoffs rather than assuming the specialized implementation is always faster.
The initial change can add these entry points without changing existing adder behavior.
Related: #79 (general adder optimization) and #107 (periodic banded sparse-access oracles).
- Lingua principale
- Python
- Stelle
- 19
- Fork
- 18
- Merge medio
- 5g 18h
- PR unite (30g)
- 14
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di NVIDIA/cudaq-algorithms
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NVIDIA/cudaq-algorithms#110 ·
I maintainer di solito rispondono entro 8 giorni
-
Support negative spin projections in make_hartree_fock_occupationForse già presa @Schrodingerscat07 l’ha presa 20 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
NVIDIA/cudaq-algorithms#77 · 1 commento ·
I maintainer di solito rispondono entro 8 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
NVIDIA/cudaq-algorithms#76 ·
I maintainer di solito rispondono entro 8 giorni
-
`PauliLCU` accepts zero-width Pauli words (and target-free scalar `SpinOperator`s) and builds a `num_system = 0` encodingForse di nuovo libera @kubuyuk l’ha presa 11 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
NVIDIA/cudaq-algorithms#58 · 1 commento ·
I maintainer di solito rispondono entro 8 giorni
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
NVIDIA/cudaq-algorithms#107 ·
I maintainer di solito rispondono entro 8 giorni
Tutte le issue di NVIDIA/cudaq-algorithms
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
521xueweihan/HelloGitHub#4729 ·
-
auto-reported bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
cliproxy-quota: a tab around a credential email skips own-accounts and paced-accounts matchingApertaneeds-triage type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
pollen-robotics/reachy_mini_conversation_app#631 ·
I maintainer di solito rispondono entro 7 giorni
-
stix-atlas.json: the same relationship id is used for several different mitigates relationshipsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100