- Notifications
You must be signed in to change notification settings - Fork964
[WIP] Deno browser WASM/WebGPU support#1344
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 ourterms of service andprivacy 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?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
@@ -142,7 +142,7 @@ export const env = { | |||
remoteHost: 'https://huggingface.co/', | |||
remotePathTemplate: '{model}/resolve/{revision}/', | |||
allowLocalModels: !(IS_BROWSER_ENV || IS_WEBWORKER_ENV), | |||
allowLocalModels: !(IS_BROWSER_ENV || IS_WEBWORKER_ENV || IS_DENO_RUNTIME), |
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.
Deno doesn't support relative URLs, so this is necessary... even if we have filesystem access
.replace( | ||
`"object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node&&"renderer"!=process.type`, | ||
"false", | ||
) | ||
.replace( | ||
`typeof globalThis.process?.versions?.node == 'string'`, | ||
"false", | ||
) |
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.
Very hacky, but is a current workaround, otherwise we get errors related toworker_threads
not being prefixed withnode:
cc@fs-eire if you have a better idea.
HuggingFaceDocBuilderDev commentedJun 20, 2025
The docs for this PR livehere. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
} else if (apis.IS_NODE_ENV) { | ||
ONNX = ONNX_NODE.default ?? ONNX_NODE; | ||
} else if (apis.IS_NODE_ENV && (ONNX = ONNX_NODE.default ?? ONNX_NODE)?.InferenceSession) { |
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.
Handles an edge case where it is a node-like environment (e.g., Deno), but we are running in an environment where onnxruntime-node is not bundled (but onnxruntime-wasm is)
Turns out, this is also necessary to ensure v0.dev operates correctly, otherwise we get this error:
|
could you try replace "worker_threads" to "node:worker_threads"? |
Unfortunately, I've tried that and it doesn't fix the issue: Deno:
v0:
|
An experimental branch/PR to test running Transformers.js in Deno's WASM and WebGPU runtimes. This is a bit hacky, but it works... at least for now!
You can test this out by building this PR, and hosting the js files locally.
NOTE: This is different to running with the native EP (#1306), which will enable WebGPU support in Deno, via ONNXRuntime's Native WebGPU EP implementation.
There are some bugs/limitations with the current runtime (based onwgpu), e.g.,
but WASM works well 👍
cc@crowlKats for viz