Skip to content

Commit 8ce3095

Browse files
authored
Runner logs (#15279)
### Summary Move some runner logs around. 1. Move the stats so it doesn't interfere with generation 2. Add a different message to end of generation to indicate we cut off because tokens, not because of eos ### Test plan lora demo
1 parent 0dbf06e commit 8ce3095

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

extension/llm/runner/text_llm_runner.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ Error TextLLMRunner::generate(
169169
stats_->first_token_ms = time_in_ms();
170170
stats_->prompt_eval_end_ms = time_in_ms();
171171

172+
RUNNER_ET_LOG(
173+
config.warming,
174+
"RSS after prompt prefill: %f MiB (0 if unsupported)",
175+
get_rss_bytes() / 1024.0 / 1024.0);
176+
172177
// print the first token from prefill. No prev_token so use cur_token for it.
173178
auto decode_result = tokenizer_->decode(cur_token, cur_token);
174179
if (!decode_result.ok()) {
@@ -179,10 +184,6 @@ Error TextLLMRunner::generate(
179184
return ::executorch::runtime::Error::InvalidArgument;
180185
}
181186
wrapped_callback(std::move(*decode_result));
182-
RUNNER_ET_LOG(
183-
config.warming,
184-
"RSS after prompt prefill: %f MiB (0 if unsupported)",
185-
get_rss_bytes() / 1024.0 / 1024.0);
186187

187188
// start the main loop
188189
prompt_tokens.push_back(cur_token);

extension/llm/runner/text_token_generator.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,13 @@ class ET_EXPERIMENTAL TextTokenGenerator {
128128
if (eos_ids_->find(cur_token) != eos_ids_->end()) {
129129
printf("\n");
130130
ET_LOG(Info, "\nReached to the end of generation");
131-
break;
131+
return pos - start_pos;
132132
}
133133
}
134+
ET_LOG(
135+
Info,
136+
"\nFinished generation. Generated %" PRIi32 " tokens.",
137+
start_pos + max_new_tokens);
134138
return pos - start_pos;
135139
}
136140

0 commit comments

Comments
 (0)