diff --git a/node_modules/@huggingface/transformers/.bun-tag-8719566ebeed846f b/.bun-tag-8719566ebeed846f new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dist/transformers.web.js b/dist/transformers.web.js index bb7b32717a42475a5f66411a33d5e5964dfda3e2..03de63967e99f8f3c847858621d72577ef037391 100644 --- a/dist/transformers.web.js +++ b/dist/transformers.web.js @@ -18558,22 +18558,49 @@ async function getSession(pretrained_model_name_or_path, fileName, options, cach return { buffer_or_path, session_options, session_config }; } async function constructSessions(pretrained_model_name_or_path, names, options, cache_sessions = void 0) { - return Object.fromEntries( - await Promise.all( - Object.keys(names).map(async (name) => { - const cache_config = cache_sessions?.[name] ?? false; - const { buffer_or_path, session_options, session_config } = await getSession( - pretrained_model_name_or_path, - names[name], - options, - cache_config, - name - ); - const session = await createInferenceSession(buffer_or_path, session_options, session_config); - return [name, session]; - }) - ) - ); + // Patched (whisper_web): each entry briefly holds a full-size decoded + // model buffer in JS-heap memory (on top of onnxruntime-web's own WASM-heap + // copy during session creation); loading Whisper's encoder and decoder + // concurrently keeps both buffers alive at once and roughly doubles the + // load-time memory peak, which is enough to OOM-crash mobile browsers on + // larger models (e.g. medium, ~460 MB combined). `options.sequentialSessionLoad` + // (set by the caller only when that risk is real, D-027/D-029) loads + // sub-model sessions one at a time instead of Promise.all-ing them, so the + // previous entry's buffer becomes garbage before the next one is fetched — + // at the cost of losing the download concurrency a fast connection could + // otherwise use, which is the default (and always was, pre-D-027). + if (!options?.sequentialSessionLoad) { + return Object.fromEntries( + await Promise.all( + Object.keys(names).map(async (name) => { + const cache_config = cache_sessions?.[name] ?? false; + const { buffer_or_path, session_options, session_config } = await getSession( + pretrained_model_name_or_path, + names[name], + options, + cache_config, + name + ); + const session = await createInferenceSession(buffer_or_path, session_options, session_config); + return [name, session]; + }) + ) + ); + } + const entries = []; + for (const name of Object.keys(names)) { + const cache_config = cache_sessions?.[name] ?? false; + const { buffer_or_path, session_options, session_config } = await getSession( + pretrained_model_name_or_path, + names[name], + options, + cache_config, + name + ); + const session = await createInferenceSession(buffer_or_path, session_options, session_config); + entries.push([name, session]); + } + return Object.fromEntries(entries); } function replaceTensors(obj) { for (let prop in obj) {