-
Notifications
You must be signed in to change notification settings - Fork 241
Make permute deterministic given a seed #3075
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
e2b3ce7
5021723
c479663
9f84b8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,7 +90,8 @@ template <typename InputOutputValueType, typename IntType, typename IdxType, typ | |
| void permute(raft::resources const& handle, | ||
| raft::device_matrix_view<const InputOutputValueType, IdxType, Layout> in, | ||
| std::optional<raft::device_vector_view<IntType, IdxType>> permsOut, | ||
| std::optional<raft::device_matrix_view<InputOutputValueType, IdxType, Layout>> out) | ||
| std::optional<raft::device_matrix_view<InputOutputValueType, IdxType, Layout>> out, | ||
| uint64_t seed = 0ULL) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think, this is a "slightly breaking" change: the previous behavior was non-deterministic and the new behavior is deterministic. Shall we pass the seed as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll change it to std::optional<uint64_t> seed = std::nullopt, falling back to rand() when unset so existing callers keep their current non-deterministic behavior. Will push an update soon. |
||
| { | ||
| static_assert(std::is_integral_v<IntType>, | ||
| "permute: The type of each element " | ||
|
|
@@ -126,7 +127,8 @@ void permute(raft::resources const& handle, | |
| D, | ||
| N, | ||
| is_row_major, | ||
| resource::get_cuda_stream(handle)); | ||
| resource::get_cuda_stream(handle), | ||
| seed); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -190,9 +192,10 @@ void permute(IntType* perms, | |
| IntType D, | ||
| IntType N, | ||
| bool rowMajor, | ||
| cudaStream_t stream) | ||
| cudaStream_t stream, | ||
| uint64_t seed = 0ULL) // default seed | ||
| { | ||
| detail::permute<Type, IntType, IdxType, TPB>(perms, out, in, D, N, rowMajor, stream); | ||
| detail::permute<Type, IntType, IdxType, TPB>(perms, out, in, D, N, rowMajor, stream, seed); | ||
| } | ||
|
|
||
| }; // namespace random | ||
|
|
||
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.
Maybe it would be a bit cleaner to pass a single generator by reference to the two functions here in place of the integer seed?
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.
Thanks for the suggestion! I'll build one std::mt19937_64 in make_regression_caller and pass it by reference to both permute calls instead of deriving seed/seed + 1.