Skip to content

Commit

Permalink
update seed in top_p_sampling (#59494)
Browse files Browse the repository at this point in the history
  • Loading branch information
carryyu authored Nov 30, 2023
1 parent 9ffb77a commit 1adc3e9
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions paddle/phi/kernels/gpu/top_p_sampling_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -620,18 +620,13 @@ void TopPSamplingKernel(const Context& dev_ctx,
phi::Stream(reinterpret_cast<phi::StreamId>(dev_ctx.stream())));
dev_curand_states =
reinterpret_cast<curandState_t*>(curand_states_buf->ptr());
unsigned int seed = 0;
uint64_t seed;
if (random_seed == -1) {
#ifndef _WIN32
rand_r(&seed);
setup_kernel<<<1, 256, 0, cu_stream>>>(dev_curand_states, seed, bs);
#else
srand(seed);
setup_kernel<<<1, 256, 0, cu_stream>>>(dev_curand_states, rand(), bs);
#endif
seed = static_cast<uint64_t>(time(NULL) % 1000000);
} else {
seed = random_seed;
}
setup_kernel<<<1, 256, 0, cu_stream>>>(dev_curand_states, seed, bs);

DenseTensor count_iter;
count_iter.Resize(phi::make_ddim({bs + 1}));
Expand Down

0 comments on commit 1adc3e9

Please sign in to comment.