7.3 KiB
status
| status |
|---|
| in-progress |
001-1 — Transformers.js 4.2.0 → 4.3.2 Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: superpowers:executing-plans (inline, no nested subagents — coordination plan rule). Steps use checkbox (
- [ ]) syntax for tracking.
Goal: run the browser engine on @huggingface/transformers 4.3.2 with the D-027/D-028
sequential-session patch carried over, and re-test the decisions the upgrade may obsolete.
Architecture: dependency bump + bun patch regeneration; a small runtime-guard test file pins
the installed version, the patch, and the upstream seek-loop condition D-021 depends on, so a future
bump that silently drops the patch or changes the condition fails the fast suite. Re-tests run as
scratch measurement scripts outside the repo (/tmp/ws1/); their numbers go into D-WS1* entries.
Tech Stack: Bun 1.3, @huggingface/transformers 4.3.2 (onnxruntime-web 1.31.0-dev.20260914,
onnxruntime-node 1.30.0), bun:test.
Spec: docs/specs/001-transcription-quality-and-speed.md (Goal 1); coordination rules in
docs/plans/001-0-coordination.md.
Global Constraints
- Bun only; no new runtime dependency; transformers stays a devDependency (D-031).
- New decisions are
## D-WS1<letter> — …appended at the bottom ofdocs/Decisions.md; Accepted entries are superseded, never rewritten. - Heavy commands (real-model runs, benchmarks, model downloads, full
bun test) underflock /tmp/whisper-heavy.lock. Ports 3110–3119. No push, no publishing. - Measurements are CPU numbers (onnxruntime-node, or onnxruntime-web wasm EP under Bun); say which.
- No WebGPU-only default change ships on WASM numbers; WebGPU items → "needs owner's browser check".
Review Focus
- Patch silently lost on reinstall (lockfile/
patchedDependencieskey mismatch) → the app loads fine but mobile OOM returns. Pinned by Task 1's patch-applied test. - onnxruntime-web file names changed (new version may ship different
.mjs/.wasmnames) →/ort/serving anddist/ortcopy must still contain what ort-web requests. Task 1: build and checkdist/ort/containsort-wasm-simd-threaded.jsep.{mjs,wasm}(the WebGPU bundle's files). - Upstream changes the seek-loop condition → D-021's
max_new_tokenscould become wrong or unneeded without notice. Pinned by Task 2's source-tripwire test. - onnxruntime-node 1.30 drifts real-model WER →
tests/live-real-model.test.tsunder the lock (Task 5). - q8 decoders on WASM at default optimization level (D-014's failure) — Task 3 measures every level before any change to the worker's session options.
Task 1: Upgrade to 4.3.2 and carry the patch
Files:
- Create:
tests/transformers-runtime.test.ts - Modify:
package.json,bun.lock,AGENTS.md(patch path),docs/WorkBreakdown.md - Create:
patches/@huggingface%2Ftransformers@4.3.2.patch; Delete: the 4.2.0 patch
Interfaces:
-
Produces:
tests/transformers-runtime.test.ts(Task 2 adds a case to it). -
Step 1: Write the failing test
describe("@huggingface/transformers runtime"):"installed version is the pinned 4.3.2"—node_modules/@huggingface/transformers/package.json.version === "4.3.2"."patchedDependencies points at an existing patch for the installed version"— rootpackage.jsonpatchedDependencies["@huggingface/transformers@4.3.2"]is a path that exists."web bundle's constructSessions carries the sequential-load patch (D-027/D-028)"— theconstructSessionsfunction text sliced fromdist/transformers.web.jscontainsoptions?.sequentialSessionLoadand bothPromise.all(andfor (const name of Object.keys(names)).
-
Step 2: Run
bun test tests/transformers-runtime.test.ts→ FAIL on version (4.2.0) and key. -
Step 3:
bun add -d @huggingface/transformers@4.3.2(remove the 4.2.0patchedDependenciesentry first if bun refuses),bun patch @huggingface/transformers, re-apply the 4.2.0 hunk toconstructSessionsindist/transformers.web.js(upstream is unchanged: still a barePromise.all),bun patch --commit node_modules/@huggingface/transformers.git rmthe 4.2.0 patch. Re-link the shared.cachesymlink if the reinstall removed it. -
Step 4: Run the test → PASS;
bun install --frozen-lockfileclean; typecheck; fast suite;bun run build;ls dist/ortshows the files ort-web 1.31 requests. -
Step 5: docs: AGENTS.md patch filename;
D-WS1a(upgrade, patch carried, why upstream doesn't obsolete it, ort versions, Parakeet = CTC only); WorkBreakdown tick. Commit "Upgrade @huggingface/transformers to 4.3.2 and carry the sequential-session patch".
Task 2: D-021 re-test (seek loop)
Files: Modify tests/transformers-runtime.test.ts, docs/Decisions.md,
src/worker/inference.worker.ts (comment only: "4.2" → "4.2–4.3", cite D-WS1b).
- Step 1: Test
"Whisper generate still takes the seek loop when max_new_tokens is unset (D-021)"—src/models/whisper/modeling_whisper.jscontainsif (generation_config.return_timestamps && !kwargs.max_new_tokens). Run → PASS expected (tripwire; it encodes the revisit condition, verified against the 4.3.2 source). - Step 2: Measure (
/tmp/ws1/d021.ts, onnxruntime-node, under the lock): tiny.en q8 onen_alien.opus(ffmpeg-static → 16 kHz f32), pipeline options as the worker (chunk_length_s 30, stride_length_s 5, return_timestamps true), with and withoutmax_new_tokens: 440; record wall-clock, generate-pass count (wrapmodel.generate), window count, WER vsen_alien.txt(tests/dsp.tswordErrorRate). - Step 3:
D-WS1bwith the numbers; keepmax_new_tokens: 440unless the seek path is now both faster and not worse on WER. Commit.
Task 3: D-014 re-test (WASM graphOptimizationLevel)
Files: docs/Decisions.md; src/worker/inference.worker.ts only if the outcome is "drop".
- Step 1: Measure (
/tmp/ws1/d014.ts):globalThis[Symbol.for("onnxruntime")] = await import("onnxruntime-web")before importing transformers, wasm EP, 1 thread; foronnx-community/whisper-tinydecoder_model_merged_quantized.onnxcreate a session atdisabled/basic/extended/all; record success/error. If all load: transcribeen_aiproblemwith tiny.en q8 atbasicvs default (all), 3 warm runs each, wall-clock + text identity. - Step 2: If default fails → keep,
D-WS1c"still needed on ort-web 1.31.0-dev". If it loads and is not slower → remove the override (worker comment cites D-WS1c), run a q8 transcribe again through the harness with the worker's new options. Commit.
Task 4: WebGPU-affecting changes (D-022, D-025/D-026) — inspection only
- Step 1: Read 4.3.0/4.3.1/4.3.2 release notes and diff 4.2.0↔4.3.2
src/for WebGPU/fp16/Firefox/Safari changes; check ort-web 1.31 dist for Gecko/fp16 handling. - Step 2:
D-WS1dlisting each item as "needs owner's browser check" with what to try (explicit WebGPU on Firefox for D-026; medium fp16 for D-022; Safari 26 WebGPU). No code change. Commit.
Task 5: Verify and finish
- typecheck, fast suite, build green;
flock /tmp/whisper-heavy.lock bun test tests/live-real-model.test.tsgreen; record WER per clip in D-WS1a if changed from the bars. git statusclean; last commitgit rm docs/plans/001-1-transformers-upgrade.md.