-
Notifications
You must be signed in to change notification settings - Fork 655
Poisson distribution using cuRAND and STL #6096
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
Conversation
Greptile OverviewGreptile SummaryThis PR adds Poisson distribution support using
The implementation acknowledges that CPU and GPU variants produce different results due to different underlying algorithms. Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Test as Test Code
participant Philox as Philox4x32_10
participant PoissonDist as poisson_dist
participant CurandGen as CurandGenerator
participant cuRAND as curand_poisson
participant StdLib as std::poisson_distribution
Note over Test,StdLib: GPU Path
Test->>Philox: init(seed, seq, offset)
Test->>CurandGen: CurandGenerator(curand_state)
Test->>PoissonDist: operator()(CurandGenerator)
PoissonDist->>CurandGen: Access state
PoissonDist->>cuRAND: curand_poisson(&state, mean)
cuRAND-->>PoissonDist: uint32_t value
PoissonDist-->>Test: uint32_t value
Note over Test,StdLib: CPU Path
Test->>Philox: init(seed, seq, offset)
Test->>PoissonDist: operator()(Philox)
PoissonDist->>StdLib: std::poisson_distribution(mean)(rng)
StdLib->>Philox: operator()() [multiple calls]
Philox-->>StdLib: uint32_t random values
StdLib-->>PoissonDist: uint32_t value
PoissonDist-->>Test: uint32_t value
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, no comments
Signed-off-by: Michał Zientkiewicz <[email protected]>
Signed-off-by: Michał Zientkiewicz <[email protected]>
Signed-off-by: Michał Zientkiewicz <[email protected]>
Signed-off-by: Michal Zientkiewicz <[email protected]>
Signed-off-by: Michal Zientkiewicz <[email protected]>
Signed-off-by: Michal Zientkiewicz <[email protected]>
51d34e0 to
e475f07
Compare
| template <typename CurandState> | ||
| struct CurandGenerator { | ||
| CurandState &state; | ||
| __device__ explicit CurandGenerator(CurandState &s) : state(s) {} | ||
| __device__ inline uint32_t operator()() const { | ||
| return curand(&state); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to non-tests.
| } | ||
| } | ||
|
|
||
| namespace { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to a header file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, no comments
Signed-off-by: Michal Zientkiewicz <[email protected]>
Signed-off-by: Michal Zientkiewicz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, no comments
Signed-off-by: Michal Zientkiewicz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, no comments
| namespace dali { | ||
| namespace random { | ||
|
|
||
| template <typename CurandState> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved here from the tests. It'll be useful in production code.
|
CI MESSAGE: [39149793]: BUILD STARTED |
|
CI MESSAGE: [39149793]: BUILD FAILED |
The distribution carries only the mean value and the actual distribution is selected a evaluation time. The results are not consistent between CPU and GPU. --------- Signed-off-by: Michal Zientkiewicz <[email protected]>
Category:
New feature (non-breaking change which adds functionality)
Refactoring (Redesign of existing code that doesn't affect functionality)
Description:
This PR adds Poisson distribution implemented with cuRAND for GPU and
std::poisson_distributionfor CPU.The tests cover distribution histograms.
There's also significant refactoring of the random distribution tests.
Additional information:
Affected modules and functionalities:
Key points relevant for the review:
Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A