Fixed for decoder dl speed and mobile warnings on low memory devices.

This commit is contained in:
Lucas Winther
2026-07-29 07:47:42 +02:00
parent 2643a446d0
commit 78e99fc415
7 changed files with 208 additions and 32 deletions
+8 -2
View File
@@ -13,6 +13,7 @@ import {
pipeline,
WhisperTextStreamer,
type AutomaticSpeechRecognitionPipeline,
type PretrainedModelOptions,
type ProgressInfo,
} from "@huggingface/transformers";
import { resolveDefaultDtype } from "../lib/models";
@@ -256,7 +257,7 @@ async function createPipeline(
configureWasmThreads(device);
const dtype = message.dtype ?? resolveDefaultDtype(message.modelId, device);
try {
const asr = await pipeline("automatic-speech-recognition", message.modelId, {
const pipelineOptions: PretrainedModelOptions & { sequentialSessionLoad?: boolean } = {
device,
dtype,
// WASM sessions cap graph optimization at "basic" (D-014): the level-2
@@ -268,7 +269,12 @@ async function createPipeline(
session_options: { graphOptimizationLevel: "basic" as const },
}),
progress_callback: forwardProgress,
});
// D-027/D-029: sequential sub-model session loading trades load speed
// for a lower peak-memory footprint — only worth it where the UI
// determined this load risks crashing a mobile tab.
sequentialSessionLoad: message.sequentialSessionLoad ?? false,
};
const asr = await pipeline("automatic-speech-recognition", message.modelId, pipelineOptions);
// What ort actually ended up with (it clamps to 1 without isolation) —
// surfaced to the UI so degraded threading is visible in the field.
const threads = env.backends.onnx.wasm?.numThreads ?? 1;