pykeio / ort

Fast ML inference & training for Rust with ONNX Runtime
https://ort.pyke.io/
Apache License 2.0
797 stars 91 forks source link

WASM: `External initializers are not enabled in this build` #192

Closed decahedron1 closed 4 months ago

decahedron1 commented 4 months ago
          Hi

@decahedron1

Build and load of wasm module in the browser is successful.

But when inferencing the model, I face following error:

panicked at libtashkeel-wasm\src\lib.rs:23:34:
called `Result::unwrap()` on an `Err` value: InferenceError("Failed to run model using onnxruntime via ort. Caused by Failed to create ONNX Runtime session: Deserialize tensor attn_layers.0.ccm.layernorm.bias failed.External initializers are not enabled in this build

I'm using an ort model.

Originally posted by @mush42 in https://github.com/pykeio/ort/issues/75#issuecomment-2081213832

decahedron1 commented 4 months ago

@mush42 Are you able to upload the converted .ort model?

decahedron1 commented 4 months ago

Should be fixed by https://github.com/pykeio/ort/commit/80be2068296b04e8ae0a442d4b9c2d635362d07e

mush42 commented 4 months ago

@decahedron1 Here's the model. It is a quantized model using neural compressor. model.zip

decahedron1 commented 4 months ago

Can you confirm that https://github.com/pykeio/ort/commit/80be2068296b04e8ae0a442d4b9c2d635362d07e fixed this issue by setting ort as a git dependency:

[dependencies]
ort = { git = "https://github.com/pykeio/ort.git", rev = "80be2068296b04e8ae0a442d4b9c2d635362d07e" }
mush42 commented 4 months ago

@decahedron1 I confirm that the commit fixes the issue.

mush42 commented 4 months ago

@decahedron1 If possible, make a new rc release.

mush42 commented 4 months ago

My model is now live at: https://mush42.github.io/libtashkeel/

mush42 commented 4 months ago

Do you have any idea of what has been added to nightly to make ort work in wasm-unknown-unknown?

Just came by this: https://github.com/Liamolucko/find_wasm_import

decahedron1 commented 4 months ago

No idea. My best guesses are https://github.com/rust-lang/rust/pull/124036 or the LLVM 18 upgrade (which should land in v1.78 stable, releasing tomorrow).

mush42 commented 4 months ago

OK.

Whatever it is, it seams to add around 5-6 MB to the .wasm module bundle.

Using stable, my build is around 6 MB when compiled with stable, jumped to 12 MB when compiled with nightly.