-
Notifications
You must be signed in to change notification settings - Fork 940
ONNX Runtime improvements #1306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
* customize the wasm paths * update implementation * allow using 'webgpu' in nodejs binding * update version of onnxruntime-node * Upgrade onnxruntime-web to same version as onnxruntime-node * Update list of supported devices --------- Co-authored-by: Joshua Lochner <[email protected]>
* customize the wasm paths * update implementation
@@ -28,11 +28,16 @@ import url from 'url'; | |||
|
|||
const VERSION = '3.5.2'; | |||
|
|||
const IS_PROCESS_AVAILABLE = typeof process !== 'undefined'; | |||
const IS_NODE_ENV = IS_PROCESS_AVAILABLE && process?.release?.name === 'node'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be true for Bun, which does not have webgpu support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The native EP doesn't rely on navigator.gpu
, so we can still run it in the same way:
import { pipeline } from "@huggingface/transformers";
// Create a feature-extraction pipeline
const extractor = await pipeline(
"feature-extraction",
"Xenova/all-MiniLM-L6-v2",
{ device: "webgpu" }
);
// Compute sentence embeddings
const sentences = ["Hello world", "This is an example sentence"];
const output = await extractor(sentences, { pooling: "mean", normalize: true });
console.log(output.tolist());
output:
$ bun run testing/bun.js
dtype not specified for "model". Using the default dtype (fp32) for this device (webgpu).
2025-06-19 16:19:03.276 bun[51733:2036459] 2025-06-19 16:19:03.276206 [W:onnxruntime:, session_state.cc:1276 VerifyEachNodeIsAssignedToAnEp] Some nodes were not assigned to the preferred execution providers which may or may not have an negative impact on performance. e.g. ORT explicitly assigns shape related ops to CPU to improve perf.
2025-06-19 16:19:03.276 bun[51733:2036459] 2025-06-19 16:19:03.276244 [W:onnxruntime:, session_state.cc:1278 VerifyEachNodeIsAssignedToAnEp] Rerunning with verbose output on a non-minimal build will show node assignments.
[
[
-0.03447728604078293, 0.031023163348436356, 0.006734936963766813, ...
], [
0.06765685230493546, 0.06349590420722961, 0.04871312156319618, ...
]
]
Add support for native webgpu EP