Skip to content

Commit 73c472e

Browse files
authored
make parakeet benckmark ci capture correct time
Differential Revision: D92783050 Pull Request resolved: pytorch#17322
1 parent a398a96 commit 73c472e

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

‎examples/models/parakeet/main.cpp‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ std::vector<Token> greedy_decode_executorch(
151151
int64_t blank_id,
152152
int64_t num_rnn_layers = 2,
153153
int64_t pred_hidden = 640,
154-
int64_t max_symbols_per_step = 10) {
154+
int64_t max_symbols_per_step = 10,
155+
::executorch::extension::llm::Stats* stats = nullptr) {
155156
std::vector<Token> hypothesis;
156157

157158
// Shape: [1, T, joint_hidden]
@@ -289,6 +290,9 @@ std::vector<Token> greedy_decode_executorch(
289290
t += std::max(dur, static_cast<int64_t>(1));
290291
symbols_on_frame = 0;
291292
} else {
293+
if (hypothesis.empty() && stats) {
294+
stats->first_token_ms = ::executorch::extension::llm::time_in_ms();
295+
}
292296
hypothesis.push_back({static_cast<TokenId>(k), t, dur});
293297

294298
std::vector<int64_t> token_data = {k};
@@ -367,6 +371,19 @@ int main(int argc, char** argv) {
367371
ET_LOG(Error, "Failed to load model.");
368372
return 1;
369373
}
374+
375+
// Load all methods upfront so model_load_time captures the real cost.
376+
// With Mmap load mode, model->load() only sets up memory mappings;
377+
// the actual data is paged in lazily when methods are first loaded.
378+
const std::vector<std::string> required_methods = {
379+
"preprocessor", "encoder", "decoder_step", "joint"};
380+
for (const auto& method : required_methods) {
381+
auto method_load_error = model->load_method(method);
382+
if (method_load_error != Error::Ok) {
383+
ET_LOG(Error, "Failed to load method: %s", method.c_str());
384+
return 1;
385+
}
386+
}
370387
stats.model_load_end_ms = ::executorch::extension::llm::time_in_ms();
371388
stats.inference_start_ms = ::executorch::extension::llm::time_in_ms();
372389

@@ -420,8 +437,6 @@ int main(int argc, char** argv) {
420437
return 1;
421438
}
422439
stats.prompt_eval_end_ms = ::executorch::extension::llm::time_in_ms();
423-
stats.first_token_ms =
424-
stats.prompt_eval_end_ms; // For ASR, first token is at end of encoding
425440

426441
auto& enc_outputs = enc_result.get();
427442
auto f_proj = enc_outputs[0].toTensor(); // [B, T, joint_hidden]
@@ -478,7 +493,14 @@ int main(int argc, char** argv) {
478493

479494
ET_LOG(Info, "Running TDT greedy decode...");
480495
auto decoded_tokens = greedy_decode_executorch(
481-
*model, f_proj, encoded_len, blank_id, num_rnn_layers, pred_hidden);
496+
*model,
497+
f_proj,
498+
encoded_len,
499+
blank_id,
500+
num_rnn_layers,
501+
pred_hidden,
502+
10,
503+
&stats);
482504

483505
ET_LOG(Info, "Decoded %zu tokens", decoded_tokens.size());
484506

0 commit comments

Comments
 (0)