fix(huggingface-transformers): align HFT_Device tests with auto-resolve semantics#595
fix(huggingface-transformers): align HFT_Device tests with auto-resolve semantics#595sroussey wants to merge 1 commit into
Conversation
…ve semantics The HFT_Device unit tests asserted that resolveHftPipelineDevice returns undefined on the server for missing/browser-only inputs, but the source deliberately normalizes those inputs to "auto" so transformers.js delegates EP selection to onnxruntime-node. The tests were carried over from the deleted HFT_Pipeline.ts and never updated; downstream builder/main (commit dd2acdc, "webgpu" -> "auto") confirms the auto-resolve path is the intended runtime behavior. - Update HFT_Device.test.ts to expect "auto" for undefined / wasm / webgpu on the server, matching source. - Rename the second case to "normalizes browser-only devices to auto on the server" to reflect the new assertions. - Add a JSDoc note on resolveHftPipelineDevice explaining the server normalization to "auto" and the onnxruntime-node EP delegation. Co-Authored-By: Claude <noreply@anthropic.com>
|
CI status update (initial check, this PR): Two job failures ( The failing tests are This PR's scope was purely to align the Recommend handling the EP-selection issue in a separate fix on
The other PR jobs ( Generated by Claude Code |
Problem
resolveHftPipelineDevice(inproviders/huggingface-transformers/src/ai/common/HFT_Device.ts) deliberately normalizes server-sideundefined/"wasm"/"webgpu"inputs to"auto"so transformers.js can delegate EP selection to onnxruntime-node. The accompanying unit tests inpackages/test/src/test/ai-provider-hft/HFT_Device.test.tsshipped in 0.3.18/0.3.19 assertingtoBeUndefined()for those same cases — the tests were carried over from the deletedHFT_Pipeline.tsand never updated. The test/source mismatch shipped as a latent bug.Decision
Source is the spec; rewrite the tests. Downstream consumer
builderflipped"webgpu"→"auto"in commitdd2acdcbecause the auto-resolve path is the intended runtime behavior. The source matches the downstream consumer's runtime intent, so the source stays and the tests are corrected.Files changed
packages/test/src/test/ai-provider-hft/HFT_Device.test.ts"passes auto through on the server":resolveHftPipelineDevice(undefined)now asserts.toBe("auto")instead of.toBeUndefined().it("strips browser-only devices on the server", ...)toit("normalizes browser-only devices to auto on the server", ...), with both assertions changed to.toBe("auto").providers/huggingface-transformers/src/ai/common/HFT_Device.tsresolveHftPipelineDevicewith a one-line note that on the server, missing/browser-only inputs normalize to"auto"(which transformers.js delegates to onnxruntime-node for EP auto-selection).Verification
bunx vitest run packages/test/src/test/ai-provider-hft/HFT_Device.test.tsbun run build:types(turbo, 36 packages)No source semantics changed; only the tests and JSDoc were corrected to reflect the existing runtime behavior already in use by the downstream
builderconsumer.Generated by Claude Code