RuntimeWarning: invalid value encountered in det
This warning gets emitted a lot and is really unhelpful.
- Track down where this is coming from
- See if we can change code paths so it doesn't happen
I suspect this may be coming from cirq somewhere?
An example:
import qualtran.testing as qlt_testing
from qualtran.bloqs.block_encoding import (
_black_box_block_bloq,
)
qlt_testing.assert_bloq_example_serializes(_black_box_block_bloq)
This does it too
from qualtran.bloqs.block_encoding import _black_box_block_bloq
bloq = _black_box_block_bloq.make()
bloq.t_complexity()
in dev_tools/bloq_report_card.ipynb these are the bloq examples that raise the det warning
- pair_potential
- black_box_block_bloq
- potential_energy
- hubbard_time_evolution_by_gqsp
- approx_cswap_large
Ok, this is an issue with numpy on Mac ARM. You can reproduce it by doing the determinant of any complex matrix, such as:
mat = [[1,0],[0,1]]
mat = np.asarray(mat, dtype="complex128")
np.linalg.det(mat)
I will fix in upstream cirq, but I recommend executing np.seterr(all='ignore') on any affected Macs.
See https://github.com/quantumlib/Cirq/pull/6599
This will be fixed as soon as cirq version gets upgraded. In the meantime, add np.seterr(all='ignore') if it annoys you.