csprng icon indicating copy to clipboard operation
csprng copied to clipboard

Is the codebase re-seeding on every random tensor generation (if so, can I control the reseeding period)?

Open kwmaeng91 opened this issue 1 year ago • 0 comments

Dear experts,

From what I understood, this codebase samples a random number from /dev/urandom each time when generating a new random tensor, and uses it as a seed to generate the rest of the random tensor (I got the idea from here: https://github.com/pytorch/csprng/issues/43#issuecomment-673640716).

I am confused about this behavior for two reasons:

  1. If AES-CTR is CSPRNG, my understanding is that it does not need to be reseeded. Why is it reseeding on every tensor generation?
  2. If my understanding is correct, the reseeding period seems arbitrary. If I generate a huge random tensor, a lot of random numbers will be generated from a single 128-bit value from /dev/urandom. If I generate multiple small tensors, /dev/urandom will be sampled very frequently. Can I control the reseeding frequency?

Please let me know if I am mistaken in any ways. My understanding of how this codebase works (and/or how CSPRNG works) might be incorrect.

Thank you!

kwmaeng91 avatar Dec 03 '24 00:12 kwmaeng91