feat(transcription): whisper threads use Workload::Whisper + GPU detection

Wires the whisper backend through the new tuning helper. gpu_offloaded
combines a compile-time feature check (whisper-vulkan, in default
features) with a runtime libvulkan probe via the hardware module. If
libvulkan1 is missing on Linux, whisper-rs's vulkan backend silently
falls back to CPU, so we should not reduce threads in that case.

The old magnotia_core::constants::inference_thread_count import is
replaced by tuning::{inference_thread_count, Workload}. The constants
module's helper is removed in Task 6.1 once the LLM call site has
also migrated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
jars
2026-05-09 12:21:33 +01:00
parent d6bde52d6e
commit e715da3b54
2 changed files with 6 additions and 3 deletions

3
Cargo.lock generated
View File

@@ -2793,7 +2793,6 @@ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"gdk", "gdk",
"gtk", "gtk",
"libloading 0.8.9",
"magnotia-ai-formatting", "magnotia-ai-formatting",
"magnotia-audio", "magnotia-audio",
"magnotia-cloud-providers", "magnotia-cloud-providers",
@@ -2855,12 +2854,14 @@ name = "magnotia-core"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"libloading 0.8.9",
"num_cpus", "num_cpus",
"serde", "serde",
"serde_json", "serde_json",
"sysinfo", "sysinfo",
"tempfile", "tempfile",
"thiserror 2.0.18", "thiserror 2.0.18",
"tracing",
] ]
[[package]] [[package]]

View File

@@ -10,8 +10,9 @@ use std::path::Path;
use whisper_rs::{FullParams, SamplingStrategy, WhisperContext, WhisperContextParameters}; use whisper_rs::{FullParams, SamplingStrategy, WhisperContext, WhisperContextParameters};
use magnotia_core::constants::inference_thread_count;
use magnotia_core::error::{MagnotiaError, Result}; use magnotia_core::error::{MagnotiaError, Result};
use magnotia_core::hardware::vulkan_loader_available;
use magnotia_core::tuning::{inference_thread_count, Workload};
use magnotia_core::types::{Segment, TranscriptionOptions}; use magnotia_core::types::{Segment, TranscriptionOptions};
use crate::transcriber::{Transcriber, TranscriberCapabilities}; use crate::transcriber::{Transcriber, TranscriberCapabilities};
@@ -78,7 +79,8 @@ impl Transcriber for WhisperRsBackend {
params.set_initial_prompt(prompt); params.set_initial_prompt(prompt);
} }
} }
params.set_n_threads(inference_thread_count() as i32); let gpu_offloaded = cfg!(feature = "whisper-vulkan") && vulkan_loader_available();
params.set_n_threads(inference_thread_count(Workload::Whisper, gpu_offloaded) as i32);
params.set_print_special(false); params.set_print_special(false);
params.set_print_progress(false); params.set_print_progress(false);
params.set_print_realtime(false); params.set_print_realtime(false);