Skip to content

Commit

Permalink
Fixed number of input tokens for VLM. (#1317)
Browse files Browse the repository at this point in the history
Fixed number of input tokens for VLM.
  • Loading branch information
popovaan authored Dec 5, 2024
1 parent 7d8912f commit c2a8f97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/cpp/src/visual_language/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class ov::genai::VLMPipeline::VLMPipelineImpl {

// Common perf metrics
auto& res_raw_counters = decoded.perf_metrics.raw_metrics;
decoded.perf_metrics.num_input_tokens = prompt_ids.get_size();
decoded.perf_metrics.load_time = m_load_time_ms;
res_raw_counters.generate_durations.emplace_back(PerfMetrics::get_microsec(generate_end_time - generate_start_time));
res_raw_counters.detokenization_durations.emplace_back(PerfMetrics::get_microsec(decode_end_time - decode_start_time));
Expand Down
25 changes: 12 additions & 13 deletions tests/python_tests/test_vlm_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,18 @@ def test_perf_metrics(cache):

assert perf_metrics is not None

assert perf_metrics.get_load_time() > 0
assert perf_metrics.get_num_generated_tokens() > 0
assert perf_metrics.get_num_input_tokens() > 0
assert perf_metrics.get_ttft().mean > 0
assert perf_metrics.get_tpot().mean > 0
assert perf_metrics.get_ipot().mean > 0
assert perf_metrics.get_throughput().mean > 0
assert perf_metrics.get_inference_duration().mean > 0
assert perf_metrics.get_generate_duration().mean > 0
assert perf_metrics.get_tokenization_duration().mean > 0
assert perf_metrics.get_detokenization_duration().mean > 0
assert perf_metrics.get_detokenization_duration().mean > 0
assert perf_metrics.get_prepare_embeddings_duration().mean > 0
assert 0 < perf_metrics.get_load_time() < 2000
assert 0 < perf_metrics.get_num_generated_tokens() < 100
assert 0 < perf_metrics.get_num_input_tokens() < 100
assert 0 < perf_metrics.get_ttft().mean < 1000
assert 0 < perf_metrics.get_tpot().mean < 100
assert 0 < perf_metrics.get_ipot().mean < 100
assert 0 < perf_metrics.get_throughput().mean < 1000
assert 0 < perf_metrics.get_inference_duration().mean < 1000
assert 0 < perf_metrics.get_generate_duration().mean < 1000
assert 0 < perf_metrics.get_tokenization_duration().mean < 100
assert 0 < perf_metrics.get_detokenization_duration().mean < 10
assert 0 < perf_metrics.get_prepare_embeddings_duration().mean < 100

# assert that calculating statistics manually from the raw counters we get the same results as from PerfMetrics
vlm_raw_metrics = perf_metrics.vlm_raw_metrics
Expand Down

0 comments on commit c2a8f97

Please sign in to comment.