Skip to content

Conversation

@fs-eire
Copy link
Contributor

@fs-eire fs-eire commented Mar 21, 2025

This PR updates the logics to have a better customized wasmPaths setting. Specifically, the following changes were made:

  • (Safari) Fallback to non ASYNCIFY build of webassembly, because of an OOM issue: 🐛 v3 crashes on iOS and macOS devices due to increasing memory usage #1242

    • This fallback does not affect any existing feature, because WebGPU is not available on Safari yet anyway
  • Because of the fallback feature, we need to access file ort-wasm-simd-threaded.mjs and ort-wasm-simd-threaded.wasm, which is not in package @huggingface/transformers. point to onnxruntime-web.

  • only apply override to wasmPaths when env.backends.onnx.versions.web exists. The only situation that it does not exist is the nodejs build.

The feature need to be well tested.

@fs-eire fs-eire changed the title [WIP] customize the wasm paths customize the wasm paths Mar 21, 2025
@fs-eire fs-eire marked this pull request as ready for review March 21, 2025 17:48
@xenova
Copy link
Collaborator

xenova commented Apr 25, 2025

Thanks for this! I'll do some additional testing, and hopefully have this included with #1231.

@xenova
Copy link
Collaborator

xenova commented Apr 25, 2025

Superseded by #1231

@xenova xenova closed this Apr 25, 2025
@xenova xenova reopened this Apr 25, 2025
@xenova xenova changed the base branch from main to ort-improvements April 25, 2025 22:45
@xenova xenova merged commit bdaead0 into huggingface:ort-improvements Apr 25, 2025
xenova added a commit that referenced this pull request Jul 30, 2025
* ONNX Runtime improvements (experimental native webgpu; fix iOS) (#1231)

* 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 <26504141+xenova@users.noreply.github.com>

* customize the wasm paths (#1250)

* customize the wasm paths

* update implementation

* [internal] Add is_decoder option to session retrieval for preferred output location

* Update tests

* Formatting

* Bump ort versions

* Bump onnxruntime-node version

* Bump versions

* Bump ORT versions

* Bump versions

* Only check webgpu fp16 for non-node environments

* Fix

* Assume node supports webgpu

* Update ORT node support comment

* Relax test strictness

* Update conversion script versions

* Downgrade onnxslim

* cleanup

* Update package-lock.json

* Update onnxruntime versions

* Update post-build script

* Use built-in session release function

* Call garbage collection after each tokenizer test

* Do not double-throw error

* Fix race-condition in build process with file removal

* Update versions

* Bump jinja version

* [version] Update to 3.6.3

* Bump jinja version to support new features

* [version] Update to 3.6.3

* Add support for LFM2 models (#1367)

* Use prefix in lfm2 output location (#1369)

* Update package-lock.json

* Run `npm audit fix`

* Add special tokens in text-generation pipeline if tokenizer requires (#1370)

* Add special tokens in text-generation pipeline if tokenizer requires

* Fix logits processors tests

* Update bundles.test.js

* Update comment

* Formatting

* Add support for ModernBERT Decoder (#1371)

* Use from/to buffer instead of string

Actually fixes #1343

* Add support for Voxtral (#1373)

* Support longform voxtral processing (#1375)

* [version] Update to 3.7.0

* Add support for Arcee (#1377)

* Optimize tensor.slice() (#1381)

* Optimize tensor.slice()

The performance of executing `tensor.slice()` is super poor, especially for
the 'logits' tensor with large dimensions.

```
const logits = outputs.logits.slice(null, -1, null);`
```

This is because currently implementation of the `slice` method manually iterates
through each element and calculate indices which is a big time consuming if
the tensor shape is large.

For cases like `slice(null, -1, null)`, where the slicing operation is
contiguous along certain dimensions, which can be optimized by bulk copy
by using `TypeArray.subarray()` and `TypeArray.set()`.

* nit

* Add a few more tensor slice unit tests

---------

Co-authored-by: Joshua Lochner <26504141+xenova@users.noreply.github.com>

---------

Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com>
Co-authored-by: Wanming Lin <wanming.lin@intel.com>
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