Comments (5)
@Maetveis Please check the issue and try to reproduce.
from rocrand.
The issue here is that the random number generation does not work the way you're thinking it works.
Lets call our random number generator g
. Since g
has internal state lets keep track of the number of calls to g
by its superscript. There can be multiple generators so lets mark them with a subscript.
With this notation for example is the third generator with two prior applications.
What you are expecting is that the random numbers are generated like this:
I.e. the same generator (with the same seed) is used with seqential offsets.
But they are generated like this:
I.e. each output is generated by an independent generator. The next random numbers would be
With offset
= n
each generator is set to the same state as if has been used n
times. So sticking with the same notation:
Your reproducer would pass with this code:
ROCRAND_CALL(rocrand_create_generator(&gen, ROCRAND_RNG_PSEUDO_MRG32K3A));
ROCRAND_CALL(rocrand_create_generator(&gen2, ROCRAND_RNG_PSEUDO_MRG32K3A));
ROCRAND_CALL(rocrand_set_seed(gen, 1));
ROCRAND_CALL(rocrand_set_seed(gen2, 1));
ROCRAND_CALL(rocrand_set_offset(gen2, 1));
// Two applications of gen, overwrite deviceA with second result
ROCRAND_CALL(rocrand_generate(gen, deviceA, NUM));
ROCRAND_CALL(rocrand_generate(gen, deviceA, NUM));
ROCRAND_CALL(rocrand_generate(gen2, deviceB, NUM));
// deviceA and deviceB now have the same values
from rocrand.
Thank you for your quick response and your thorough explanation!
I think the snippet that you have provided does not cover the use case that we are interested in. Our primary goal is to reproduce the behaviour of curand, which generates two lists with an offset
.
For example, given two lists original_ran_list
, and ofsetted_ran_list
generated by generators with the same seed but the generator of ofsetted_ran_list
were applied the offset of n
, the following property should hold: original_ran_list[i+n] == ofsetted_ran_list[i]
. (for curand behaviour see this example:
curand_offset.txt )
if I understand your explanation correctly, with rocRAND one way to achieve the same semantics is to call rocrand_generate
NUM+1
times and then discard the first n
elements. I believe this approach would be rather cumbersome to implement, and very inefficient.
Could you suggest a better solution to achieve the semantics described above?
from rocrand.
This is basically a continuity issue, the random numbers are not generated in a consistent order.
For example if one was to generate a 100 elements using two calls to the host API generating 50 elements each, then compare that with the same generator and the same seed generated with 20 then 80 elements, then the they differ after the first 20 elements.
My explanation was only for explaining what rocRAND does currently, but it wont have the same effect as setting the offset for cuRAND. The rocRAND behaviour is incorrect, I don't think there's a reasonable (as in using the host api) workaround until its fixed.
from rocrand.
You can now try out the branch mrg32k3a_offset (#236) it should fix the mrg32k3a generator (used in your reproducer). Other generators are in separate branches.
from rocrand.
Related Issues (20)
- Add unit test for uniform_distribution_half HOT 1
- Makefile:149: recipe for target 'all' failed HOT 2
- Remove unnecessary if else HOT 1
- Invalid use of inline assembly for GFX1010 target HOT 4
- rocRand is compiled without gfx803 support HOT 4
- can't build rocRAND on nvidia platform, requires amd_comgr HOT 2
- Unknown option `--amdgpu-target` HOT 5
- Please enable two factor authentication in your github account
- Could a spack package be provided for hiprand? HOT 6
- rocRAND/hipRAND 5.4.0 packages are missing symlinks HOT 2
- [cmake error] Could not find a package configuration file provided by "hip" HOT 1
- rocRAND crashes when compiled with avx2 support HOT 3
- Add topics `sobol`, `sobol-sequence`
- Use of undefined member m_engine_size in library/src/rng/xorwow.hpp
- rocrand free an object that is not malloced
- Performance regression in mtgp32 with uniform-double HOT 7
- can not compile on Nvidia platform HOT 2
- Compilation issues form rocRand while building the mxnet HOT 1
- Cannot build 2.7.0 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rocrand.