PauliLCU accepts finite coefficients whose normalization overflows, producing incorrect PREPARE weights
Maintainers usually reply within 8 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in python/cudaq_algorithms/pauli_lcu.py at the constructor around line 510, where identity terms are accumulated and alpha is derived before kernel_args/angles are built. Run the provided reproducer against qpp-cpu to confirm the infinite alpha and finite alpha with infinite constant_term; then check the existing PauliLCU tests for the constructor's expected validation style. Done means nonfinite accumulated normalization or identity offset raises a clear exception, while zero, signed, and valid negative coefficients keep their current behavior.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 19
- Forks
- 18
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 14
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/cudaq-algorithms
-
Support negative spin projections in make_hartree_fock_occupationPossibly taken @Schrodingerscat07 claimed this 20 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
NVIDIA/cudaq-algorithms#77 · 1 comment ·
Maintainers usually reply within 8 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
NVIDIA/cudaq-algorithms#76 ·
Maintainers usually reply within 8 days
-
`PauliLCU` accepts zero-width Pauli words (and target-free scalar `SpinOperator`s) and builds a `num_system = 0` encodingMay be free again @kubuyuk claimed this 11 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
NVIDIA/cudaq-algorithms#58 · 1 comment ·
Maintainers usually reply within 8 days
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
NVIDIA/cudaq-algorithms#108 ·
Maintainers usually reply within 8 days
-
Difficulty 5/5 Over a week Newbie friendliness 38/100
NVIDIA/cudaq-algorithms#107 ·
Maintainers usually reply within 8 days
All issues in NVIDIA/cudaq-algorithms
Similar issues
-
auto-reported bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
stix-atlas.json: the same relationship id is used for several different mitigates relationshipsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
backend bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
nolte/kamerplanter#3193 ·
Maintainers usually reply within 1 day
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwisePossibly taken @abdulwaarith0 claimed this today. Openneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
MakazhanAlpamys/Soup#3690 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day