Skip to content

fix(embedding): resolve ONNX dtype from model declaration or cache - #393

Merged
EyJunge1 merged 2 commits into
tickernelz:mainfrom
yihuishou:onnx_quantify
Oct 10, 2026
Merged

EyJunge1 merged 2 commits into
tickernelz:mainfrom
yihuishou:onnx_quantify

Conversation

@yihuishou

Copy link
Copy Markdown
Contributor

pipeline() without an explicit dtype resolves device=cpu on Node/Bun, and cpu is missing from transformers.js DEFAULT_DEVICE_DTYPE_MAPPING, so it falls back to fp32 and requests onnx/model.onnx. Quantized-only repos do not ship that file, so the local lookup 404s, the remote fallback runs, and offline hosts fail warmup with 'fetch failed'.

Resolve the dtype in two tiers before calling pipeline(): first the repo's own transformers.js_config.dtype declaration, then a probe of the cached ONNX variants in descending precision. When neither applies, dtype is omitted and transformers.js keeps its existing defaults.

Summary

Test plan

  • Exercised the change locally (or N/A for docs/meta-only)
  • Noted any follow-up or known limitations

Checklist

  • Branch is based on main (do not open PRs from commits already on main)
  • bun test passes (or N/A)
  • bun run typecheck passes (or N/A)
  • bun run check passes (format + lint + typecheck; or N/A)
  • Docs / README updated when behavior or contribution process changes

yihuishou and others added 2 commits October 9, 2026 12:28
pipeline() without an explicit dtype resolves device=cpu on Node/Bun, and cpu
is missing from transformers.js DEFAULT_DEVICE_DTYPE_MAPPING, so it falls back
to fp32 and requests onnx/model.onnx. Quantized-only repos do not ship that
file, so the local lookup 404s, the remote fallback runs, and offline hosts
fail warmup with 'fetch failed'.

Resolve the dtype in two tiers before calling pipeline(): first the repo's own
transformers.js_config.dtype declaration, then a probe of the cached ONNX
variants in descending precision. When neither applies, dtype is omitted and
transformers.js keeps its existing defaults.
Expand the cache probe to the full transformers.js suffix map, skip
pipeline dtype overrides when config uses a per-file object map, and
cover resolveLocalOnnxDtype with unit tests.
@EyJunge1
EyJunge1 merged commit df22336 into tickernelz:main Oct 10, 2026
13 checks passed
EyJunge1 added a commit to EyJunge1/opencode-mem that referenced this pull request Oct 10, 2026
Prefer CONFIG.embeddingDtype over resolveLocalOnnxDtype from tickernelz#393 so
explicit config still wins after the upstream merge.
@EyJunge1 EyJunge1 mentioned this pull request Oct 10, 2026
2 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants