get_conn_flattened out of bounds indexing
Created by: PhilipVinc
I noticed that if one enables bound-checks in Numba code (which slows it down considerably, so Numba defaults to not performing it) we sometimes index and write data out of bounds in our get_conn_flattened
.
This is harmless for the given example (we write a zero to some random address) but might cause problems and wrong indexes when working with batches, so it should be fixed ASAP
netket on pv/lazyop [$] via netket_env via 🐍 system took 4s
➜ python -c "import netket as nk; nk.operator.spin.sigmap(nk.hilbert.Spin(0.5), 0).to_dense()"
~/Dropbox/Ricerca/Codes/Python/netket pv/lazyop
netket on pv/lazyop [$] via netket_env via 🐍 system took 5s
➜ NUMBA_BOUNDSCHECK=1 python -c "import netket as nk; nk.operator.spin.sigmap(nk.hilbert.Spin(0.5), 0).to_dense()"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/filippovicentini/Dropbox/Ricerca/Codes/Python/netket/netket/operator/_discrete_operator.py", line 190, in to_dense
return self.to_sparse().todense().A
File "/home/filippovicentini/Dropbox/Ricerca/Codes/Python/netket/netket/operator/_discrete_operator.py", line 158, in to_sparse
x_prime, mels = concrete_op.get_conn_flattened(x, sections)
File "/home/filippovicentini/Dropbox/Ricerca/Codes/Python/netket/netket/operator/_local_operator.py", line 911, in get_conn_flattened
return self._get_conn_flattened_kernel(
IndexError: index is out of bounds