Stream: git-wasmtime

Topic: wasmtime / issue #7925 Add component adaptor for wasi-nn


view this post on Zulip Wasmtime GitHub notifications bot (Feb 13 2024 at 13:38):

danbev opened issue #7925:

Feature

Add component adaptor for wasi-nn (wasi_ephemeral_nn).

Benefit

Currently when trying to use wasm-tools component new with a core wasm module leads to the following error:
```console
$ wasm-tools component new -vvv ./target/wasm32-wasi/release/inf_wasi.wasm \
--adapt wit-lib/wasi_snapshot_preview1.reactor.wasm \
-o target/inf-wasi-component.wasm
...

error: failed to encode a component from module

Caused by:
0: module requires an import interface named wasi_ephemeral_nn
`` My thinking here is that adding an adapter similar to wasi_snapshot_preview1 but for wasi_ephemeral_nn` would enable the component to be created.

Implementation

I don't have any suggestions here but if I can get some guidance I'd be willing to try to implement this.

Alternatives

N/A

view this post on Zulip Wasmtime GitHub notifications bot (Feb 13 2024 at 17:26):

pchickey commented on issue #7925:

I don't think a component adapter is the path to go for wasi-nn. The component adapter was created to solve a very specific problem: we needed to create components out of modules that had some of their imports created in difficult to modify (especially before standardization is complete) upstream source trees such as wasi-libc and rust's std libraries. Because we couldn't upgrade those module imports to use e.g. a wit-bindgen! macro to generate component imports, we created an adapter to go between them, but in practice the adapter is very difficult to maintain because it needs to be written in a subset of Rust that doesn't result in any table or data sections existing in the linked module, and also the adapter is in the process of becoming obsolete, now that WASI 0.2 is stabilized, because we are actively upstreaming the changes in libc and std to use wit-bindgen component bindings directly.

Wasi-nn doesnt have those problems, that I am aware of: users of wasi-nn have much easier paths to upgrading their imports of wasi-nn from the (now legacy) witx abi module imports to wit-bindgen component imports. Have you tried to upgrade your wasi-nn user code in that way?

view this post on Zulip Wasmtime GitHub notifications bot (Feb 14 2024 at 06:31):

danbev closed issue #7925:

Feature

Add component adaptor for wasi-nn (wasi_ephemeral_nn).

Benefit

Currently when trying to use wasm-tools component new with a core wasm module leads to the following error:
```console
$ wasm-tools component new -vvv ./target/wasm32-wasi/release/inf_wasi.wasm \
--adapt wit-lib/wasi_snapshot_preview1.reactor.wasm \
-o target/inf-wasi-component.wasm
...

error: failed to encode a component from module

Caused by:
0: module requires an import interface named wasi_ephemeral_nn
`` My thinking here is that adding an adapter similar to wasi_snapshot_preview1 but for wasi_ephemeral_nn` would enable the component to be created.

Implementation

I don't have any suggestions here but if I can get some guidance I'd be willing to try to implement this.

Alternatives

N/A

view this post on Zulip Wasmtime GitHub notifications bot (Feb 14 2024 at 06:31):

danbev commented on issue #7925:

@pchickey Thanks for the detailed explanation about the adapter, I appreciate it!

users of wasi-nn have much easier paths to upgrading their imports of wasi-nn from the (now legacy) witx abi module imports to wit-bindgen component imports. Have you tried to upgrade your wasi-nn user code in that way?

I actually have not tried that which is a little embarrassing. I just ran into the error and it looked like the same issue I had seen before and I assumed it would have to be handled in the same way. I'll upgrade wasi-nn and try that out. Thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Feb 14 2024 at 17:13):

pchickey commented on issue #7925:

Don't be embarrassed, this stuff is brand new and there are nowhere near enough docs. Happy to help.


Last updated: Oct 23 2024 at 20:03 UTC