Skip to content

[LLava] Fix stats for C++ runner #5147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci/scripts/test_llava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ if hash nproc &> /dev/null; then NPROC=$(nproc); fi
EXECUTORCH_COMMON_CMAKE_ARGS=" \
-DCMAKE_INSTALL_PREFIX=${BUILD_DIR} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DEXECUTORCH_ENABLE_LOGGING=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
Expand Down
7 changes: 6 additions & 1 deletion examples/models/llava/runner/llava_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ Error LlavaRunner::generate_from_pos(

uint64_t prefill_next_token =
ET_UNWRAP(prefill_prompt(prompt, start_pos, /*bos=*/0, /*eos*/ 0));
stats_.first_token_ms = util::time_in_ms();
stats_.prompt_eval_end_ms = util::time_in_ms();
stats_.num_prompt_tokens = start_pos;

// Generate tokens
Expand All @@ -116,7 +118,6 @@ Error LlavaRunner::generate_from_pos(

// Bookkeeping
stats_.num_generated_tokens = num_generated_tokens;
::executorch::llm::print_report(stats_);
if (stats_callback) {
stats_callback(stats_);
}
Expand Down Expand Up @@ -151,6 +152,7 @@ Error LlavaRunner::generate(
};

int64_t pos = 0;
stats_.inference_start_ms = util::time_in_ms();

// prefill preset prompt
prefill_prompt(kPresetPrompt, pos, /*bos=*/1, /*eos*/ 0);
Expand All @@ -167,6 +169,9 @@ Error LlavaRunner::generate(
Error err = generate_from_pos(
prompt, seq_len, pos, wrapped_callback, stats_callback, echo);

stats_.inference_end_ms = util::time_in_ms();
::executorch::llm::print_report(stats_);

ET_LOG(
Info,
"RSS after finishing text generation: %f MiB (0 if unsupported)",
Expand Down
Loading