Skip to content

Commit

Permalink
Add abort to avoid slow cuda issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanUnderhill committed Nov 14, 2024
1 parent b90bfc6 commit e2d1574
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/sampling_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct SamplingBenchmark {
int num_iter = 1000;

auto logits = params->p_device->Allocate<float>(static_cast<size_t>(config.model.vocab_size) * batch_size_);
auto test_start = std::chrono::high_resolution_clock::now();

for (int i = 0; i < num_iter; i++) {
auto generator = Generators::CreateGenerator(*model, *params);
Expand All @@ -57,6 +58,10 @@ struct SamplingBenchmark {
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
total_time += duration.count();
if (std::chrono::duration_cast<std::chrono::minutes>(stop - start) > std::chrono::minutes(1)) {
std::cout << Generators::SGR::Bg_Red << " ABORTING " << Generators::SGR::Reset << " loop due to slow performance(took more than 1 minute) on iteration " << i << std::endl;
break;
}
}
double average_time = total_time / double(num_iter);
std::cout << "Average time taken: " << average_time << " microseconds" << std::endl;
Expand Down

0 comments on commit e2d1574

Please sign in to comment.