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

Use GenPC (Permuted Congruential) as the default random number generator everywhere #1099

Merged
merged 2 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cpp/include/raft/cluster/kmeans_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ struct KMeansParams {
/**
* Seed to the random number generator.
*/
raft::random::RngState rng_state =
raft::random::RngState(0, raft::random::GeneratorType::GenPhilox);
raft::random::RngState rng_state{0};

/**
* Metric to use for distance computation.
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/raft/random/detail/make_regression.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void make_regression_caller(const raft::handle_t& handle,
DataT noise = (DataT)0.0,
bool shuffle = true,
uint64_t seed = 0ULL,
raft::random::GeneratorType type = raft::random::GenPhilox)
raft::random::GeneratorType type = raft::random::GenPC)
{
n_informative = std::min(n_informative, n_cols);

Expand Down
4 changes: 2 additions & 2 deletions cpp/include/raft/random/make_blobs.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void make_blobs(DataT* out,
DataT center_box_min = (DataT)-10.0,
DataT center_box_max = (DataT)10.0,
uint64_t seed = 0ULL,
GeneratorType type = GenPhilox)
GeneratorType type = GenPC)
{
detail::make_blobs_caller(out,
labels,
Expand Down Expand Up @@ -140,7 +140,7 @@ void make_blobs(
DataT center_box_min = (DataT)-10.0,
DataT center_box_max = (DataT)10.0,
uint64_t seed = 0ULL,
GeneratorType type = GenPhilox)
GeneratorType type = GenPC)
{
if (centers.has_value()) {
RAFT_EXPECTS(centers.value().extent(0) == (IdxT)n_clusters,
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/raft/random/make_regression.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void make_regression(const raft::handle_t& handle,
DataT noise = (DataT)0.0,
bool shuffle = true,
uint64_t seed = 0ULL,
GeneratorType type = GenPhilox)
GeneratorType type = GenPC)
{
detail::make_regression_caller(handle,
out,
Expand Down Expand Up @@ -149,7 +149,7 @@ void make_regression(const raft::handle_t& handle,
DataT noise = DataT{},
bool shuffle = true,
uint64_t seed = 0ULL,
GeneratorType type = GenPhilox)
GeneratorType type = GenPC)
{
const auto n_samples = out.extent(0);
assert(values.extent(0) == n_samples);
Expand Down
2 changes: 1 addition & 1 deletion cpp/test/linalg/reduce_rows_by_key.cu
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ReduceRowTest : public ::testing::TestWithParam<ReduceRowsInputs<T>> {
rmm::device_uvector<T> weight(0, stream);
if (params.weighted) {
weight.resize(nobs, stream);
raft::random::RngState r(params.seed, raft::random::GeneratorType::GenPhilox);
raft::random::RngState r(params.seed);
uniform(handle, r, weight.data(), nobs, T(1), params.max_weight);
}

Expand Down
6 changes: 6 additions & 0 deletions cpp/test/random/make_regression.cu
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ class MakeRegressionTest : public ::testing::TestWithParam<MakeRegressionInputs<

typedef MakeRegressionTest<float> MakeRegressionTestF;
const std::vector<MakeRegressionInputs<float>> inputsf_t = {
{0.01f, 256, 32, 16, 1, -1, 0.f, true, raft::random::GenPC, 1234ULL},
{0.01f, 1000, 100, 47, 4, 65, 4.2f, true, raft::random::GenPC, 1234ULL},
{0.01f, 20000, 500, 450, 13, -1, -3.f, false, raft::random::GenPC, 1234ULL},
{0.01f, 256, 32, 16, 1, -1, 0.f, true, raft::random::GenPhilox, 1234ULL},
{0.01f, 1000, 100, 47, 4, 65, 4.2f, true, raft::random::GenPhilox, 1234ULL},
{0.01f, 20000, 500, 450, 13, -1, -3.f, false, raft::random::GenPhilox, 1234ULL}};
Expand All @@ -147,6 +150,9 @@ INSTANTIATE_TEST_CASE_P(MakeRegressionTests, MakeRegressionTestF, ::testing::Val

typedef MakeRegressionTest<double> MakeRegressionTestD;
const std::vector<MakeRegressionInputs<double>> inputsd_t = {
{0.01, 256, 32, 16, 1, -1, 0.0, true, raft::random::GenPC, 1234ULL},
{0.01, 1000, 100, 47, 4, 65, 4.2, true, raft::random::GenPC, 1234ULL},
{0.01, 20000, 500, 450, 13, -1, -3.0, false, raft::random::GenPC, 1234ULL},
{0.01, 256, 32, 16, 1, -1, 0.0, true, raft::random::GenPhilox, 1234ULL},
{0.01, 1000, 100, 47, 4, 65, 4.2, true, raft::random::GenPhilox, 1234ULL},
{0.01, 20000, 500, 450, 13, -1, -3.0, false, raft::random::GenPhilox, 1234ULL}};
Expand Down
16 changes: 8 additions & 8 deletions cpp/test/random/rng_discrete.cu
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,16 @@ class RngDiscreteTest : public ::testing::TestWithParam<RngDiscreteInputs<IdxT>>
};

const std::vector<RngDiscreteInputs<int>> inputs_i32 = {
{1, 10000, 5, 5, GenPhilox, 123ULL},
{1, 10000, 10, 7, GenPhilox, 456ULL},
{1000, 100, 10000, 20, GenPhilox, 123ULL},
{1, 10000, 5, 5, GenPC, 1234ULL},
{1, 10000, 5, 5, GenPC, 123ULL},
{1, 10000, 10, 7, GenPC, 456ULL},
{1000, 100, 10000, 20, GenPC, 123ULL},
{1, 10000, 5, 5, GenPhilox, 1234ULL},
};
const std::vector<RngDiscreteInputs<int64_t>> inputs_i64 = {
{1, 10000, 5, 5, GenPhilox, 123ULL},
{1, 10000, 10, 7, GenPhilox, 456ULL},
{1000, 100, 10000, 20, GenPhilox, 123ULL},
{1, 10000, 5, 5, GenPC, 1234ULL},
{1, 10000, 5, 5, GenPC, 123ULL},
{1, 10000, 10, 7, GenPC, 456ULL},
{1000, 100, 10000, 20, GenPC, 123ULL},
{1, 10000, 5, 5, GenPhilox, 1234ULL},
};

#define RNG_DISCRETE_TEST(test_type, test_name, test_inputs) \
Expand Down