chore: stabilize current head before Phase 10a QC

This commit is contained in:
2026-05-10 23:00:25 +01:00
parent c95a5da077
commit b463c32f17
24 changed files with 238 additions and 89 deletions

View File

@@ -116,7 +116,10 @@ fn verified_manifest_path(dir: &Path) -> PathBuf {
dir.join(".magnotia-verified")
}
fn verified_manifest_matches(entry: &magnotia_core::model_registry::ModelEntry, dir: &Path) -> bool {
fn verified_manifest_matches(
entry: &magnotia_core::model_registry::ModelEntry,
dir: &Path,
) -> bool {
let manifest = match std::fs::read_to_string(verified_manifest_path(dir)) {
Ok(contents) => contents,
Err(_) => return false,

View File

@@ -70,9 +70,7 @@ impl TranscriptionProvider for LocalProviderAdapter {
.map(|c| c.sample_rate)
.unwrap_or(magnotia_core::constants::WHISPER_SAMPLE_RATE),
channels: local.map(|c| c.channels).unwrap_or(1),
initial_prompt_supported: local
.map(|c| c.supports_initial_prompt)
.unwrap_or(false),
initial_prompt_supported: local.map(|c| c.supports_initial_prompt).unwrap_or(false),
language_hint_supported: true,
streaming_supported: false,
cost_class: CostClass::Free,

View File

@@ -65,7 +65,9 @@ impl Transcriber for WhisperRsBackend {
);
let mut state = self.ctx.create_state().map_err(|e| {
MagnotiaError::TranscriptionFailed(WhisperBackendError::State(e.to_string()).to_string())
MagnotiaError::TranscriptionFailed(
WhisperBackendError::State(e.to_string()).to_string(),
)
})?;
let mut params = FullParams::new(SamplingStrategy::Greedy { best_of: 1 });

View File

@@ -30,7 +30,10 @@ fn jfk_transcription_benchmark() {
let sample_rate = u32::from_le_bytes(bytes[24..28].try_into().unwrap());
let channels = u16::from_le_bytes(bytes[22..24].try_into().unwrap());
let bits = u16::from_le_bytes(bytes[34..36].try_into().unwrap());
eprintln!("[bench] wav spec: {} Hz, {} ch, {}-bit", sample_rate, channels, bits);
eprintln!(
"[bench] wav spec: {} Hz, {} ch, {}-bit",
sample_rate, channels, bits
);
assert_eq!(sample_rate, 16_000, "expected 16 kHz wav");
assert_eq!(channels, 1, "expected mono");
assert_eq!(bits, 16, "expected 16-bit PCM");
@@ -48,7 +51,10 @@ fn jfk_transcription_benchmark() {
);
let rss_before_load_kb = read_rss_kb();
eprintln!("[bench] RSS before model load: {} MB", rss_before_load_kb / 1024);
eprintln!(
"[bench] RSS before model load: {} MB",
rss_before_load_kb / 1024
);
let load_start = Instant::now();
let ctx = WhisperContext::new_with_params(&model_path, WhisperContextParameters::default())
@@ -57,9 +63,11 @@ fn jfk_transcription_benchmark() {
eprintln!("[bench] model load: {:.2}s", load_dur.as_secs_f64());
let rss_after_load_kb = read_rss_kb();
eprintln!("[bench] RSS after model load: {} MB (delta +{} MB)",
eprintln!(
"[bench] RSS after model load: {} MB (delta +{} MB)",
rss_after_load_kb / 1024,
(rss_after_load_kb.saturating_sub(rss_before_load_kb)) / 1024);
(rss_after_load_kb.saturating_sub(rss_before_load_kb)) / 1024
);
let mut state = ctx.create_state().expect("whisper state");
let mut params = FullParams::new(SamplingStrategy::Greedy { best_of: 1 });
@@ -110,12 +118,20 @@ fn jfk_transcription_benchmark() {
let rss_final_kb = read_rss_kb();
eprintln!("[bench] RSS final: {} MB", rss_final_kb / 1024);
eprintln!("");
eprintln!();
eprintln!("=== SUMMARY ===");
eprintln!("audio: {:.2}s", audio_secs);
eprintln!("model_load: {:.2}s", load_dur.as_secs_f64());
eprintln!("cold xc: {:.2}s RTF={:.3}", cold_dur.as_secs_f64(), cold_dur.as_secs_f64() / audio_secs);
eprintln!("warm xc: {:.2}s RTF={:.3}", warm_dur.as_secs_f64(), warm_dur.as_secs_f64() / audio_secs);
eprintln!(
"cold xc: {:.2}s RTF={:.3}",
cold_dur.as_secs_f64(),
cold_dur.as_secs_f64() / audio_secs
);
eprintln!(
"warm xc: {:.2}s RTF={:.3}",
warm_dur.as_secs_f64(),
warm_dur.as_secs_f64() / audio_secs
);
eprintln!("RSS peak: {} MB", rss_final_kb / 1024);
}
@@ -124,7 +140,9 @@ fn read_rss_kb() -> u64 {
let s = std::fs::read_to_string(format!("/proc/{pid}/status")).unwrap_or_default();
for line in s.lines() {
if let Some(rest) = line.strip_prefix("VmRSS:") {
return rest.trim().split_whitespace().next()
return rest
.split_whitespace()
.next()
.and_then(|n| n.parse::<u64>().ok())
.unwrap_or(0);
}

View File

@@ -82,14 +82,7 @@ fn whisper_thread_count_sweep() {
for (label, power, gpu_offloaded_for_helper) in panels {
env::set_var("MAGNOTIA_POWER_STATE_OVERRIDE", power);
let helper_pick = inference_thread_count(Workload::Whisper, gpu_offloaded_for_helper);
run_sweep_panel(
label,
helper_pick,
&ctx,
&samples,
audio_secs,
&targets,
);
run_sweep_panel(label, helper_pick, &ctx, &samples, audio_secs, &targets);
}
env::remove_var("MAGNOTIA_POWER_STATE_OVERRIDE");
}
@@ -102,10 +95,8 @@ fn run_sweep_panel(
audio_secs: f64,
targets: &[i32],
) {
eprintln!("");
eprintln!(
"=== n_threads scaling: {label} (helper picks: {helper_pick}) ==="
);
eprintln!();
eprintln!("=== n_threads scaling: {label} (helper picks: {helper_pick}) ===");
eprintln!("n_threads | xc_time | RTF | speedup_vs_1");
eprintln!("----------|---------|--------|-------------");
let mut baseline_dur: Option<f64> = None;