degree_jacobi_anger_approximation silently returns degree ~1 for a large fraction of inputs (and can raise AssertionError) — up to ~1000× cost underestimates in HamiltonianSimulationByGQSP
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Start in qualtran/linalg/polynomial/jacobi_anger_approximations.py and reproduce the supplied examples and scan across the stated τ and precision ranges. Inspect the degree search and its final assertion, focusing on behavior near Bessel function oscillation zeros. Done means the returned degree avoids the documented severe underestimates and the assertion failures; the issue proposes a regression test over the scanned range.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version: qualtran 0.7.0 (pip), Python 3.14, scipy 1.18 / numpy 2.x, macOS. File: qualtran/linalg/polynomial/jacobi_anger_approximations.py.
Minimal repro
from qualtran.linalg.polynomial.jacobi_anger_approximations import (
degree_jacobi_anger_approximation,
)
degree_jacobi_anger_approximation(150.0, precision=5e-4) # returns 1 (should be ≈160+)
degree_jacobi_anger_approximation(1500.0, precision=5e-4) # returns 1529 (correct)
degree_jacobi_anger_approximation(225000.0, precision=5e-4) # returns 1 (should be ≈225,000+)
Some inputs instead crash on the function’s own final assert (various τ at precision=1e-3).
How often
Self-contained scan — paste and run; reproduces the table below exactly (verified on a clean qualtran==0.7.0 install, 2026-08-16):
import numpy as np
from qualtran.linalg.polynomial.jacobi_anger_approximations import (
degree_jacobi_anger_approximation as deg)
taus = 10 ** np.random.default_rng(20260810).uniform(1, 6, 4000)
for eps in (1e-3, 5e-4, 1e-4):
wrong = crash = 0
for t in taus:
try:
# |J_n(t)| only decays for n > t, so any d < t/2 cannot be sound
if deg(float(t), precision=eps) < t / 2:
wrong += 1
except AssertionError:
crash += 1
print(f"eps={eps:<7} silently wrong {100wrong/len(taus):5.1f}% "
f"AssertionError {100crash/len(taus):4.1f}%")
Log-uniform scan of 4,000 values of t ∈ [10, 10⁶]:
| precision | silently wrong (d < t/2) | AssertionError | median underestimate factor |
|---|---|---|---|
| 1e-3 | 40.4% | 6.4% | ~2800× |
| 5e-4 | 35.5% | 0% | ~630× |
| 1e-4 | 13.5% | 0% | ~170× |
(The d < t/2 flag is deliberately conservative — it only counts degrees that cannot possibly be sound. Rates are stable across seeds: an independent seed at 2,000 samples gives 38.4% / 33.7% / 12.8%.)
Root cause
The truncation criterion |J_{d+1}(t)| ≤ ε is only meaningful in the decay regime n > t. For n ≲ t, J_n(t) oscillates through zeros with envelope ≈ √(2/πt), and the implementation makes three assumptions that fail there:
1. The doubling probe tests a single value. term_too_small(d) checks one |J_d(t)|. If the doubling sequence 1, 2, 4, … lands near an oscillation zero, the loop exits with d far inside the oscillatory band, where thousands of O(t^{-1/2}) terms remain in the tail.
2. bisect.bisect_left(range(d), True, key=term_too_small) requires the predicate to be monotone (False…False,True…True). In the oscillatory band it is not, so bisect returns an arbitrary crossing; the final assert not term_too_small(d) and term_too_small(d+1) only checks a local crossing, which any oscillation zero satisfies — so it usually passes on wrong answers, and occasionally fails outright (the AssertionError mode).
3. Deterministic total failure at large t: once √(2/πt) < ε — i.e. t > 2/(πε²), about 6.4×10⁵ at ε = 1e-3 — every n in the oscillatory band tests “too small,” so the first probe succeeds and the function returns ~1 for essentially all such t.
Impact
HamiltonianSimulationByGQSP consumes this degree with τ = t·α (block-encoding 1-norm times time). τ in the 10⁴–10⁶ range is routine for chemistry/materials-scale estimates, so resource counts derived through this path can silently underestimate T/Toffoli cost by 2–3 orders of magnitude. (Found while cross-validating qualtran against other resource estimators; at τ ≈ 150 on a 6×6 XXZ evolution instance the GQSP cost came out ~1000× low. It has since fired in a second, unrelated realistic costing: a 2D transverse-field Ising dynamics instance at τ = 960, precision 5e-4, returned degree 31 — a ~32× degree underestimate.)
Suggested fix
Restrict the search to the monotone decay regime: start both the doubling probe and the bisect at n₀ = ceil(|t|) (|J_n(t)| is monotonically and super-exponentially decreasing in n for n > |t|), e.g.
n0 = max(1, math.ceil(abs(t)))
d = n0
while not term_too_small(d):
d *= 2
d = n0 + bisect.bisect_left(range(n0, d), True, key=term_too_small) - 1
This also fixes the AssertionError mode (the predicate is monotone on [n₀, ∞)) and matches the symbolic branch’s asymptotic d = O(t + log(1/ε)/log log(1/ε)). A stricter follow-up would bound the tail sum rather than a single term, but the n₀ floor is the load-bearing correction. Happy to submit a PR with the fix + a regression test over the scanned τ range if useful.
- Lenguaje dominante
- Python
- Estrellas
- 397
- Forks
- 127
- Merge medio
- 2 d 19 h
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de quantumlib/Qualtran
-
`show_bloq` not workingAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
quantumlib/Qualtran#2007 ·
Los mantenedores suelen responder en 3 días
-
Addition call_graph inconsistent with decomposition for registers with unequal bitsizesQuizá libre de nuevo @rupasri118 la tomó hace 56 días y no hay ningún pull request abierto. Abiertokind/bug-report
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
quantumlib/Qualtran#1818 · 2 comentarios ·
Los mantenedores suelen responder en 3 días
-
Dificultad 3/5 1-2 días Aptitud para principiantes 75/100
quantumlib/Qualtran#2008 ·
Los mantenedores suelen responder en 3 días
-
kickmix: `Circuit.reaction_depth()` materialises every op (≈ 135–170 B/op transient), limiting verifiable circuit sizePosiblemente ocupada @manwithacat la tomó hace 27 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
quantumlib/Qualtran#1993 ·
Los mantenedores suelen responder en 3 días
-
Windows wheel (or source) for kickmix library needed for Kaggle quantum compilation challengeAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
quantumlib/Qualtran#1991 ·
Los mantenedores suelen responder en 3 días
Todos los issues de quantumlib/Qualtran
Issues similares
-
flaky: test_fire_returns_thread_per_http_entry_on_head waits 5 s per dispatch worker on busy shardsAbiertostatus/accepted type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
microsoft/apm#5309 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug vector-store
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
EverMind-AI/Raven#1413 ·
Los mantenedores suelen responder en 1 día
-
Tests: parallel pyinstallcheck runs oversubscribe the machine through nested TBB and BLAS poolsPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
ACCESS-NRI/containerised-environments-infra#143 ·
Los mantenedores suelen responder en 2 días