Skip to content

Commit 2adf8d8

Browse files
authored
parallel : add option for different RNG seeds (ggml-org#14757)
ggml-ci
1 parent 021cc28 commit 2adf8d8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

examples/parallel/parallel.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ int main(int argc, char ** argv) {
184184
// extra text to insert in each client's prompt in order to make it larger
185185
const int32_t n_junk = std::max(1, params.n_junk);
186186

187+
// signed seed, use negative values to indicate different seeds for the different clients
188+
const int32_t & sseed = params.sampling.seed;
189+
187190
// init llama.cpp
188191
llama_backend_init();
189192
llama_numa_init(params.numa);
@@ -219,12 +222,21 @@ int main(int argc, char ** argv) {
219222

220223
const int n_ctx = llama_n_ctx(ctx);
221224

225+
if (sseed >= 0) {
226+
LOG_INF("%s: initializing all samplers with the same RNG seed: %d (use a negative seed to have different seeds)\n", __func__, sseed);
227+
} else {
228+
LOG_INF("%s: initializing samplers with different RNG seeds, starting from %d\n", __func__, sseed);
229+
}
230+
222231
std::vector<client> clients(n_clients);
223232
for (size_t i = 0; i < clients.size(); ++i) {
224233
auto & client = clients[i];
225234
client.id = i;
226235
client.smpl = common_sampler_init(model, params.sampling);
227-
//params.sampling.seed++;
236+
237+
if (sseed < 0) {
238+
params.sampling.seed--;
239+
}
228240
}
229241

230242
std::vector<llama_token> tokens_system;

0 commit comments

Comments
 (0)