PauliLCU accepts finite coefficients whose normalization overflows, producing incorrect PREPARE weights
I maintainer di solito rispondono entro 8 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia in python/cudaq_algorithms/pauli_lcu.py nel costruttore intorno alla riga 510, dove i termini di identità vengono accumulati e alpha viene derivato prima che vengano costruiti kernel_args/angoli. Esegui il reproducer fornito contro qpp-cpu per confermare l'alpha infinito e l'alpha finito con constant_term infinito; poi controlla i test PauliLCU esistenti per lo stile di validazione atteso del costruttore. Fatto significa che una normalizzazione accumulata non finita o un offset di identità genera un'eccezione chiara, mentre i coefficienti zero, con segno e negativi validi mantengono il loro comportamento attuale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
The default exact backend accepts two equal, finite coefficients whose sum of absolute values overflows. It constructs alpha == inf and angles == [0.0]. Running the resulting PREPARE returns [1, 0], although the normalized weights of two equal positive coefficients are [1/sqrt(2), 1/sqrt(2)].
The state error is approximately 0.7653668647301795. This uses the public constructor with its default coefficient threshold; no NaN or infinity is supplied by the caller.
This is an extreme-magnitude input-validation/numerical-domain defect. If the public normalization cannot be represented, rejecting the input explicitly is a valid repair; the API need not support an unrepresentable normalization.
Steps to reproduce
Install cudaq==0.17.0 and cudaq-algorithms==0.2.0, save the following as a Python file, and run it:
import cudaq
import numpy as np
from cudaq_algorithms import PauliLCU
from cudaq_algorithms.pauli_lcu import prepare
cudaq.set_target("qpp-cpu")
@cudaq.kernel
def prepare_one(angles: list[float]):
q = cudaq.qvector(1)
prepare(q, angles)
maximum = float.fromhex("0x1.fffffffffffffp+1023")
enc = PauliLCU([(maximum, "X"), (maximum, "Z")])
angles = enc.kernel_args[0]
actual = np.asarray(cudaq.get_state(prepare_one, angles))
print("alpha:", enc.alpha)
print("angles:", angles)
print("prepared state:", actual)
print("error:", np.linalg.norm(actual - np.array([1, 1]) / np.sqrt(2)))
offset = PauliLCU([(maximum, "I"), (maximum, "I"), (1., "X")],
include_identity=False)
print("excluded identity offset:", offset.constant_term, "alpha:", offset.alpha)
Observed:
alpha: inf
angles: [0.0]
prepared state: [1.+0.j 0.+0.j]
error: 0.7653668647301795
excluded identity offset: inf alpha: 1.0
The last example shows that checking alpha alone is insufficient: summing excluded identity terms can overflow constant_term even when alpha remains finite. As a positive control, coefficients [(1.0, "X"), (1.0, "Z")] prepare the equal superposition with state error 1.11e-16.
Expected behavior
Reject nonfinite accumulated normalization or identity offsets with a clear exception, or use a documented rescaled representation that preserves the encoded operator. Do not return an apparently usable object with infinite normalization and silently changed weights.
Environment
- CUDA-Q Algorithms: 0.2.0, installed wheel.
- CUDA-Q: 0.17.0, reported build
1750574c92c613ff76c52fdbaa9289d864a3d640. - Target:
qpp-cpu; Python 3.11.4; macOS 26.7.2, arm64. - Rechecked 2026-11-24. The installed
pauli_lcu.pyandcommon_kernels.pyare byte-identical to Algorithms main at87f8d0fe938439041bca6fc13691d89a11775e66. - No source/package patch was applied. No known last working version; also observed in our earlier 0.15.1-era tests.
Source and suggested repair
The constructor accumulates identity coefficients and computes sum(abs(c) ...) before dividing the masses. Validate the accumulated values before building angles: positive finite normalization and finite identity offset. Zero coefficients and signed coefficients need separate, explicit treatment; negative Hamiltonian coefficients themselves are valid.
This report concerns finite input whose accumulation overflows. Already-nonfinite coefficients are outside its scope. No matching issue was found in the public tracker search on 2026-11-24; that search is not proof that no related discussion exists.
- 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
-
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à 4/5 3-5 giorni Idoneità per principianti 55/100
NVIDIA/cudaq-algorithms#108 ·
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