Skip to content

Flaky onnx.spec.ts failure due to parallel @xenova/transformers cache race #1306

In review

Description

@ale18V

Problem

discojs/src/models/onnx.spec.ts intermittently fails in verify / test / discojs (pnpm exec vitest --run --project=discojs):

stderr | discojs/src/models/onnx.spec.ts > ONNXModel.predict > should generate the next token ID from a prompt
Error: Failed to load model because protobuf parsing failed.
    at new OnnxruntimeSessionHandler (.../onnxruntime-node@1.14.0/node_modules/onnxruntime-node/dist/backend.js:27:92)
Something went wrong during model construction (most likely a missing operation). Using `wasm` as a fallback.

FAIL discojs/src/models/onnx.spec.ts > ONNXModel.predict > should generate the next token ID from a prompt
TypeError: The worker script or module filename must be an absolute path or a relative path starting with './' or '../'. Received "blob:nodedata:..."

Example failure: https://github.com/epfml/disco/actions/runs/45631278165/job/139266851671 (on PR #1290).

Root cause

Both discojs/src/models/onnx.spec.ts and discojs/src/models/implementations/hellaswag.spec.ts call ONNXModel.init_pretrained("Xenova/gpt2") (AutoModelForCausalLM.from_pretrained("Xenova/gpt2")) concurrently in separate Vitest workers sharing the same @xenova/transformers on-disk cache directory.

Because @xenova/transformers does not coordinate/lock concurrent writes to the same cache file, onnx.spec.ts can read a partially downloaded .onnx file (protobuf parsing failed), triggering a fallback to onnxruntime-web's wasm backend which fails in Node on blob:nodedata:.... In the same CI run, hellaswag.spec.ts finished loading the exact same Xenova/gpt2 model ~0.6 s later and passed.

Proposed fix

  • Pre-fetch Xenova/gpt2 once before parallel Vitest workers start (e.g., via a Vitest globalSetup hook and/or CI cache step), or
  • Isolate @xenova/transformers env.cacheDir per worker so parallel specs cannot corrupt each other's downloads.

Activity

  1. added
    type-bug
    scope-discojs
    scope-ci
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope-ciscope-discojstype-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions