-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ti.random(ti.i32)
always returns number of the same parity in the same thread
#7182
Comments
Ideas:
Resources: |
@lucifer1004 Thanks! Would you like to contribute the RNGs to Taichi? Maybe we can let them be an official module (maybe |
We need to expose the random states of each thread to Python first if we want to implement RNGs outside the Taichi runtime. taichi/taichi/runtime/llvm/runtime_module/runtime.cpp Lines 526 to 532 in 800ff2b
|
I would love to contribute, but I have higher priorities at the moment. So if this needs to be implemented very soon, I may not be able to help. |
@lucifer1004 Thank you very much! This is an old problem, and this doesn't need to be implemented very soon. Please contribute whenever is convenient for you! |
As for this specific issue, the root cause is
Then the taichi/taichi/runtime/llvm/runtime_module/runtime.cpp Lines 534 to 540 in b48baeb
If we change |
We can move it to |
@lucifer1004 @bobcao3 Thanks! Let me make a quick fix. |
BTW @bobcao3 it seems that the SPIRV-based backends don't use this random seed? |
They don't (and they uses a different algorithm), so this doesn't apply there. |
Shall we close this issue and open a new one to track the RNG implementations? @lin-hitonami |
Good idea! Please open a new one! |
Issue: taichi-dev#7182 ### Brief Summary
Consider this program which generates 100 random ints and checks their parity (even or odd)
This ends up printing
More generally, I noticed that, for a given thread, regardless of the random seed, the 1st random int it generates always has the same parity.
The text was updated successfully, but these errors were encountered: