evolved_operator_terms quantizes every coefficient to 1e-12, destroying precision at the API's own default atol
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Read cpp/monoprop/detail/monomial_propagator/MonomialPropagatorImpl.h around lines 1069–1073 and trace the coefficient decoding in the cited Majorana and Pauli algebra files. Then run the listed tests and add a regression case for a coefficient around 1e-10 at atol=1e-12; done means the returned coefficient retains full double precision and the existing tests pass.
Written by the indexing model from the issue text.
Description
🤖 AI text below 🤖
What
MonomialPropagator<NumModes>::evolved_operator_terms quantizes every decoded coefficient to 12
decimal places before returning it.
cpp/monoprop/detail/monomial_propagator/MonomialPropagatorImpl.h:1069-1073
// Round to drop anti-hermitian numerical noise (Majorana un-applies the Hermitian phase).
const auto decoded = algebra_decode_coeff<NumModes>(basis_, coeff, mono);
const std::complex<double> rounded(std::round(decoded.real() * 1e12) / 1e12,
std::round(decoded.imag() * 1e12) / 1e12);
terms.emplace_back(bitset_to_indices<NumModes>(mono), rounded);
Why this is a problem
The "anti-hermitian numerical noise" the comment describes cannot arise:
- Majorana:
decode_coeffmultiplies byhermitian_coefficient<NumModes>(maj)
(cpp/monoprop/algebra/MajoranaAlgebra.h), which returns an element ofPOWERS_OF_I— components
are exactly0.0and±1.0. - Pauli:
decode_pauli_coeffreturns{coeff, 0.0}outright.
coeff is a real double, so in both cases the complex multiply is exact in IEEE-754 and the
component that should be zero already is an exact zero. There is nothing to scrub.
What the rounding does do is quantize to 1e-12 absolute. evolved_operator is exposed to Python
with a default atol=1e-12
(MajoranaPropagator.evolved_operator / PauliPropagator.evolved_operator), so it deliberately
admits terms whose magnitude the rounding then reduces to one or two significant digits:
| true coefficient | returned |
|---|---|
1.23456789012345e-3 |
1.23456789e-3 (9 s.f.) |
4.7213456789e-10 |
4.72e-10 (3 s.f.) |
8.31e-12 |
8e-12 (1 s.f.) |
So the API's own default tolerance selects exactly the range where the rounding is most destructive.
Suggested fix
Return decoded unchanged and drop the rounded temporary.
If a noise scrub is still wanted for defensiveness, snap only the component that is required to be
zero, relative to the magnitude of the other one — do not quantize both components absolutely.
Verification
- Existing coverage:
tests/test_nonfermi.py,tests/test_majorana.py,tests/test_pauli.py,
tests/test_monoprop_smoke.py(line 149 callsevolved_operator(parameters, 1e-12)). These compare
withisclose(atol=1e-12), so removing the rounding should leave them green. - Add a regression test: build a case with an evolved coefficient around
1e-10and assert
evolved_operator(..., atol=1e-12)returns it to fulldoubleprecision. This fails today.
Found by a code-reading review of the repository at 29a8050. No build tree was available, so the
analysis is from source inspection and should be confirmed against a build.
- Dominant language
- C++
- Stars
- 52
- Forks
- 2
- Avg merge
- 16h 47m
- Merged PRs (30d)
- 27
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a 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 Algorithmiq/monoprop
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Algorithmiq/monoprop#193 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Algorithmiq/monoprop#192 ·
Maintainers usually reply within 1 day
-
bug performance
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Algorithmiq/monoprop#191 ·
Maintainers usually reply within 1 day
-
documentation enhancement
Difficulty 3/5 1-2 days Newbie friendliness 57/100
Algorithmiq/monoprop#412 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 58/100
Algorithmiq/monoprop#405 ·
Maintainers usually reply within 1 day
All issues in Algorithmiq/monoprop
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 91/100
FujiNetWIFI/fujinet-firmware#2045 ·
Maintainers usually reply within 1 day
-
(S1 - Need confirmation)
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
CleverRaven/Cataclysm-DDA#89159 ·
Maintainers usually reply within 1 day
-
area:libnvmpi bug P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
gjrtimmer/jetson-nvmpi#33 ·
-
bug(wasi_crypto): ArrayOutput::pull reports the wrong all-pulled flagPossibly taken @Yashbhu claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
bug question
Difficulty 1/5 Under an hour Newbie friendliness 62/100