Class: Cohere::Transcribe::ASR::BatchTelemetry
- Inherits:
-
Object
- Object
- Cohere::Transcribe::ASR::BatchTelemetry
- Defined in:
- lib/cohere/transcribe/asr/batching.rb
Overview
Mutable, run-local telemetry for native ASR batching. The public statistics object intentionally remains immutable; Engine copies these counters into it after a group completes.
Instance Attribute Summary collapse
-
#asr_batches ⇒ Object
Returns the value of attribute asr_batches.
-
#batch_history ⇒ Object
readonly
Returns the value of attribute batch_history.
-
#effective_batch_max ⇒ Object
Returns the value of attribute effective_batch_max.
-
#effective_batch_min ⇒ Object
Returns the value of attribute effective_batch_min.
-
#feature_worker_seconds ⇒ Object
Returns the value of attribute feature_worker_seconds.
-
#final_batch_cap ⇒ Object
Returns the value of attribute final_batch_cap.
-
#final_batch_size ⇒ Object
Returns the value of attribute final_batch_size.
-
#generate_device_seconds ⇒ Object
Returns the value of attribute generate_device_seconds.
-
#generated_tokens ⇒ Object
Returns the value of attribute generated_tokens.
-
#generation_analysis_seconds ⇒ Object
Returns the value of attribute generation_analysis_seconds.
-
#h2d_seconds ⇒ Object
Returns the value of attribute h2d_seconds.
-
#oom_retries ⇒ Object
Returns the value of attribute oom_retries.
-
#processor_rows ⇒ Object
Returns the value of attribute processor_rows.
Instance Method Summary collapse
- #finalize(controller) ⇒ Object
-
#initialize ⇒ BatchTelemetry
constructor
A new instance of BatchTelemetry.
- #record_oom(rows, max_new_tokens:) ⇒ Object
- #record_success(rows, max_new_tokens:, generated_tokens: 0, generated_tokens_by_row: [], generation_call_wall_seconds: nil, padded_audio_seconds: nil, native_metrics: nil) ⇒ Object
Constructor Details
#initialize ⇒ BatchTelemetry
Returns a new instance of BatchTelemetry.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 24 def initialize @asr_batches = 0 @processor_rows = 0 @generated_tokens = 0 @oom_retries = 0 @effective_batch_min = 0 @effective_batch_max = 0 @final_batch_size = 0 @final_batch_cap = 0 @feature_worker_seconds = 0.0 @h2d_seconds = 0.0 @generate_device_seconds = 0.0 @generation_analysis_seconds = 0.0 @batch_history = [] end |
Instance Attribute Details
#asr_batches ⇒ Object
Returns the value of attribute asr_batches.
10 11 12 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 10 def asr_batches @asr_batches end |
#batch_history ⇒ Object (readonly)
Returns the value of attribute batch_history.
22 23 24 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 22 def batch_history @batch_history end |
#effective_batch_max ⇒ Object
Returns the value of attribute effective_batch_max.
10 11 12 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 10 def effective_batch_max @effective_batch_max end |
#effective_batch_min ⇒ Object
Returns the value of attribute effective_batch_min.
10 11 12 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 10 def effective_batch_min @effective_batch_min end |
#feature_worker_seconds ⇒ Object
Returns the value of attribute feature_worker_seconds.
10 11 12 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 10 def feature_worker_seconds @feature_worker_seconds end |
#final_batch_cap ⇒ Object
Returns the value of attribute final_batch_cap.
10 11 12 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 10 def final_batch_cap @final_batch_cap end |
#final_batch_size ⇒ Object
Returns the value of attribute final_batch_size.
10 11 12 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 10 def final_batch_size @final_batch_size end |
#generate_device_seconds ⇒ Object
Returns the value of attribute generate_device_seconds.
10 11 12 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 10 def generate_device_seconds @generate_device_seconds end |
#generated_tokens ⇒ Object
Returns the value of attribute generated_tokens.
10 11 12 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 10 def generated_tokens @generated_tokens end |
#generation_analysis_seconds ⇒ Object
Returns the value of attribute generation_analysis_seconds.
10 11 12 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 10 def generation_analysis_seconds @generation_analysis_seconds end |
#h2d_seconds ⇒ Object
Returns the value of attribute h2d_seconds.
10 11 12 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 10 def h2d_seconds @h2d_seconds end |
#oom_retries ⇒ Object
Returns the value of attribute oom_retries.
10 11 12 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 10 def oom_retries @oom_retries end |
#processor_rows ⇒ Object
Returns the value of attribute processor_rows.
10 11 12 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 10 def processor_rows @processor_rows end |
Instance Method Details
#finalize(controller) ⇒ Object
86 87 88 89 90 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 86 def finalize(controller) @final_batch_size = controller.current_size @final_batch_cap = controller.max_size self end |
#record_oom(rows, max_new_tokens:) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 77 def record_oom(rows, max_new_tokens:) @oom_retries += 1 @batch_history << { "event" => "oom", "segments" => rows, "max_new_tokens" => max_new_tokens }.freeze end |
#record_success(rows, max_new_tokens:, generated_tokens: 0, generated_tokens_by_row: [], generation_call_wall_seconds: nil, padded_audio_seconds: nil, native_metrics: nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cohere/transcribe/asr/batching.rb', line 40 def record_success(rows, max_new_tokens:, generated_tokens: 0, generated_tokens_by_row: [], generation_call_wall_seconds: nil, padded_audio_seconds: nil, native_metrics: nil) prepare_seconds = native_metrics && ( native_metrics.fetch(:feature_wall_seconds, 0.0) + native_metrics.fetch(:mel_pack_seconds, 0.0) ) h2d_seconds = native_metrics&.fetch(:encoder_input_seconds, nil) generate_device_seconds = native_metrics && ( native_metrics.fetch(:encoder_compute_seconds, 0.0) + native_metrics.fetch(:decoder_total_seconds, 0.0) ) generation_analysis_seconds = native_metrics&.fetch(:render_seconds, nil) @asr_batches += 1 @processor_rows += rows @generated_tokens += generated_tokens @effective_batch_min = @effective_batch_min.zero? ? rows : [@effective_batch_min, rows].min @effective_batch_max = [@effective_batch_max, rows].max @feature_worker_seconds += prepare_seconds.to_f @h2d_seconds += h2d_seconds.to_f @generate_device_seconds += generate_device_seconds.to_f @generation_analysis_seconds += generation_analysis_seconds.to_f @batch_history << { "segments" => rows, "processor_rows" => rows, "max_new_tokens" => max_new_tokens, "generated_tokens" => generated_tokens, "generated_tokens_by_row" => generated_tokens_by_row.freeze, "prepare_seconds" => prepare_seconds, "h2d_seconds" => h2d_seconds, "generation_call_wall_seconds" => generation_call_wall_seconds, "generate_device_seconds" => generate_device_seconds, "generation_analysis_seconds" => generation_analysis_seconds, "padded_audio_seconds" => padded_audio_seconds }.freeze end |