Skip to content
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

Improve RNG implementation #648

Open
neworderofjamie opened this issue Jan 10, 2025 · 0 comments
Open

Improve RNG implementation #648

neworderofjamie opened this issue Jan 10, 2025 · 0 comments

Comments

@neworderofjamie
Copy link
Contributor

neworderofjamie commented Jan 10, 2025

As a side result from recent vectorization work, I discovered that XORWOW RNG dominates the memory bandwidth requirements of the neuron kernel when using simple point neuron models and stochasticity. There are two factors at play here:

  1. Under the hood, XORWOW uses a fairly standard Marsaglia generator which is probably a sensible choice. However, it is one with 2^192 sequence length and corresponding 192 bit state space (64-bit seed, 64-bit subsequence and 64-bit offset). This is arguably excessive for our use case:
    • 64-bit seed is excessive
    • GeNN has a 32-bit limit on number of neurons else where so subsequences is also excessive
    • Even if each neuron sampled the RNG 10x during a 0.1ms timestep, a 64-bit offset allows for millions of years of simulation
  2. As well as the 192 bit of state, the curandStateXORWOW struct stores 160 bits of box muller transform state so values can be re-used between calls. There is no point keeping this between kernel launches.

2 can be solved trivially by not using the curand structure directly and will result in significant performance improvemnets. Moving away from a curand RNG would be slightly more annoying but, if we reduced seed to 32-bit, and sequence length and offset to 48-bit, we could drop down to an RNG with an 128-bit state space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant