`PauliLCU` accepts zero-width Pauli words (and target-free scalar `SpinOperator`s) and builds a `num_system = 0` encoding
Maintainers usually reply within 8 days
@kubuyuk is already working on this.
Since Nov 24, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start in python/cudaq_algorithms/pauli_lcu.py at _terms_from_input, where the word width is taken from the first pair, and at the identity check in __init__. Reproduce with the snippet in the issue and compare with _word_pairs_from_input in the Trotter planner, which already rejects zero width. Done when a zero-width word raises a ValueError, scalar-only operators without an explicit num_qubits are rejected, and the identity check treats the empty word as identity.
Written by the indexing model from the issue text.
Description
PauliLCU's input parser does not require a positive word width, so an empty
Pauli word is accepted and produces an encoding of a zero-qubit system whose
"identity" term is not recognized as identity.
Reproduced on main (e46eea9), cudaq 0.15.1:
from cudaq_algorithms import PauliLCU
import cudaq
for h in ({"": 0.5},
[(0.5, "")],
0.5 * cudaq.SpinOperator.identity(),
cudaq.SpinOperator.empty() + 0.5):
e = PauliLCU(h)
print(e.num_system, e.num_ancilla, e.num_terms, e.alpha, e.constant_term, e.terms)
# every line prints: 0 1 1 0.5 0.0 [(0.5, '')]
So a num_system = 0 encoding is constructed with alpha = 0.5 and
constant_term = 0.0 — the empty word is kept as a non-identity term. Only
target-free scalar operators hit this (SpinOperator.identity(),
SpinOperator.empty() + c); 0.5 * cudaq.spin.i(0) targets qubit 0 and
correctly gets width 1 ([(0.5, 'I')]).
Where (python/cudaq_algorithms/pauli_lcu.py, _terms_from_input and __init__):
- mapping / pair input:
width = len(pairs[0][1])(L383) can be 0; the
same-length and allowed-character loops (L385–388) pass vacuously for"";
nothing requireswidth >= 1. SpinOperatorinput:required = max(_term_qubit_extent(...))(L363) is 0
for a target-free operator, soget_pauli_word(0)yields"".__init__:identity = set(word) == {"I"}(L492) isFalsefor""
(set("") == set()), so the term is neither counted inconstant_termnor
excluded byinclude_identity=False.
Expected: a zero-width word should be rejected with a ValueError
(e.g. "Pauli words must have positive width; pass num_qubits for a
scalar-only operator"), consistent with the existing rejections for
inconsistent widths and unsupported characters.
Suggested fix — mirror the Trotter planner. trotter._word_pairs_from_input
already does both things PauliLCU is missing: it rejects zero width
("hamiltonian must act on at least one qubit") and detects identity with the
subset test set(word) <= {"I"} rather than set(word) == {"I"}. Porting the
positive-width check into pauli_lcu._terms_from_input (and, for consistency,
the <= identity test into __init__) closes the gap on both the mapping/pair
path and the target-free SpinOperator path, and keeps the two primitives'
input contracts aligned. For a scalar-only
SpinOperator, callers can already pass a positive explicit num_qubits
(PauliLCU(0.5 * cudaq.SpinOperator.identity(), num_qubits=2) gives
[(0.5, 'II')]); the fix is to make the implicit zero-width path fail loudly
instead of silently succeeding.
Surfaced while reviewing the agent-skill records in #46, which document this
as a "known unguarded source gap" — once fixed, that record can describe it
as a rejection.
- 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
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA/cudaq-algorithms#110 ·
Maintainers usually reply within 8 days
-
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
-
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