-
Notifications
You must be signed in to change notification settings - Fork 57
Description
Describe the bug
xoroshiro128p_uniform_float32 should generate values [0.0, 1.0), but under some specific circumstances (see code I provide with the specific seed) it generated 1.0
Steps/Code to reproduce bug
from math import *
import numpy as np
import numba
from numba import cuda
from numba.cuda.random import *
seed = 18058
w = 16384
h = 100
states = create_xoroshiro128p_states(w, seed=seed)
outp_array = cuda.device_array(shape=(w, h), dtype=np.float32)
@cuda.jit
def generate_using_xoroshiro128p_uniform_float32(rng_states, res):
i = cuda.grid(1)
w, h = res.shape
if i < w:
for j in range(h):
res[i, j] = xoroshiro128p_uniform_float32(rng_states, i)
tpb = 256
bpg = int(np.ceil(w / tpb))
generate_using_xoroshiro128p_uniform_float32[bpg, tpb](states, outp_array)
outp_array_h = outp_array.copy_to_host()
print(outp_array_h[13343, 30:40])
print(outp_array_h[13343, 36])Expected behavior
1.0 should not happen as xoroshiro128p_uniform_float32 should be made to generate values in [0.0, 1.0)
This broke my simulation as it have code expecting strictly some x that 0 <= x < 1
Environment details (please complete the following information):
numba version: 0.60.0
CUDA driver version: 12.9
Windows 10
python 3.10.11
Additional context
I know this might be a version of numba before being officially incorporating into the NVIDIA development team, but assuming no major changes to the RNG code, as I searched in here and the original numba repo's issue section and found no mention of this, the bug has likely silently persisted