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

[CUDA] Random number generation on CUDA #5471

Closed
shiyu1994 opened this issue Sep 6, 2022 · 3 comments
Closed

[CUDA] Random number generation on CUDA #5471

shiyu1994 opened this issue Sep 6, 2022 · 3 comments

Comments

@shiyu1994
Copy link
Collaborator

Summary

Support generation of random numbers on CUDA.

Motivation

Sometimes random number generation is repeatedly called during the training process. For example, in the rank_xendcg objective. Supporting generation of random numbers on CUDA can accelerates these processes.

References

See the code snippet below for random number generation in boosting with rank_xendcg

inline void GetGradientsForOneQuery(data_size_t query_id, data_size_t cnt,
const label_t* label, const double* score,
score_t* lambdas,
score_t* hessians) const override {
// Skip groups with too few items.
if (cnt <= 1) {
for (data_size_t i = 0; i < cnt; ++i) {
lambdas[i] = 0.0f;
hessians[i] = 0.0f;
}
return;
}
// Turn scores into a probability distribution using Softmax.
std::vector<double> rho(cnt, 0.0);
Common::Softmax(score, rho.data(), cnt);
// An auxiliary buffer of parameters used to form the ground-truth
// distribution and compute the loss.
std::vector<double> params(cnt);
double inv_denominator = 0;
for (data_size_t i = 0; i < cnt; ++i) {
params[i] = Phi(label[i], rands_[query_id].NextFloat());
inv_denominator += params[i];
}
// sum_labels will always be positive number
inv_denominator = 1. / std::max<double>(kEpsilon, inv_denominator);

@shiyu1994
Copy link
Collaborator Author

Closed in favor of being in #2302. We decided to keep all feature requests in one place.

Welcome to contribute this feature! Please re-open this issue (or post a comment if you are not a topic starter) if you are actively working on implementing this feature.

@github-actions

This comment was marked as off-topic.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2023
@jameslamb
Copy link
Collaborator

Sorry, this was locked accidentally. Just unlocked it. We'd still love help with this feature!

@microsoft microsoft unlocked this conversation Aug 17, 2023
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

2 participants