Proposing a host-side design for sharing read-only GPU weights across Wasmtime component instances
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust, wasm
- 領域
- backend, embedded-iot, security
調査の方向性
Read the Wasmtime 46.0.3 ResourceTable, Store::into_data, and ResourceLimiter documentation linked in the issue, then review the linked wasi-webgpu-wasmtime host bindings. The issue asks whether existing host APIs support per-instance resource handles, completion tracking, and tenant-wide quotas, or where an API change is needed. Done means maintainers have enough concrete examples to assess the proposed embedding design; no specific code change or test is identified.
索引モデルが issue の本文から書いたものです。
説明
I’m working on a host embedding built on Wasmtime for mutually untrusted components that share a GPU. Wasm isolates instances, but giving each tenant a separate GPU address space can mean uploading the same read-only model weights more than once. A shared CUDA context lets the host keep one copy. Can an embedder use Wasmtime’s existing host APIs to control who can read it, track whose work has finished, and enforce each tenant’s quota? I’m using Wasmtime 46.0.3 with component-model enabled. I’d like to propose the host-side design outlined below: each instance gets its own read-only view of shared GPU weights, waits for work on its own logical stream, and draws from a quota shared by all instances of its tenant. Would this design be useful as a Wasmtime embedding example? I’d also welcome feedback on any part that needs changes to Wasmtime’s host APIs.
Two instances on one GPU
Assume instances A and B belong to different tenants. They use the same weights and have private inputs, intermediate buffers, and outputs. For this example, the embedder puts each instance in its own Store. A tenant can own several such stores.
- Releasing a view. A and B each hold a local handle to the weights. If A requests release of its handle while a kernel it submitted is still running, that kernel must retain access until it finishes. B must also remain able to use its own handle.
- Waiting on a stream. A submits work on one logical stream, B submits unrelated work, and A then waits on its stream. The target is the work A had submitted to that stream when the call began. B’s work and A’s later submissions fall outside that target. Contention can still delay A.
Host-side resource management
Object-level sharing. The host creates the read-only allocation and gives each authorized instance a local view. Private buffers stay with their owning instance. The host keeps the shared allocation alive while a view or an outstanding submission still references it.
Tenant quotas and logical streams. All instances of a tenant share limits on private GPU memory, unfinished work, and submission rate. Creating another instance or stream gives the tenant no additional allowance. The scheduler rotates among ready tenants and maps logical streams onto a bounded pool of CUDA streams, preserving submission order within each logical stream. Dispatch is non-preemptive.
Three checks before submission. The host restricts the GPU operations available through imports, checks the kernel and its arguments against an allowlist and manifest, then checks the caller’s permissions and the byte range for each object. These checks assume a trusted host, driver, and hardware, and approved kernels that follow their manifests. A fatal fault in the shared GPU context can affect both tenants.
Where I’d like advice from Wasmtime maintainers
-
Resource ownership. The out-of-tree
wasi-webgpu-wasmtimebindings take a host-providedResourceTableand a reference to anArc<wgpu_core::global::Global>. The prototype currently uses instance-local integer handles. For a component-resource version, I’m considering putting anArcto the same host-managed CUDA allocation in each store’s table, while exposing only read access to the guest. Removing an entry and dropping the returned value would release that store’s clone. Given thatResourceTable::pushrequiresSend + 'static, is this the expected pattern for independently droppable handles? If a guest never callsresource.dropand the host doesn’t remove the entry, does it remain until the table is dropped? Would you useResourceTable::set_max_capacityto bound total table entries in that case and account for GPU memory separately? Host bindings · ResourceTable -
Completion and teardown. Driver acceptance can precede GPU completion. On entry to a wait, I would capture the stream’s submission counter and wait through that target. An
Archeld outside A’s store would keep a host service alive. That service would retain each submission’s object references and pending-work charge. Alternatively, if I control teardown, I could consume the live store withStore::into_datato recover its host state. If A traps and the embedder drops its store, is keeping the service alive independently the recommended way to let accepted work finish, or is there a Wasmtime trap or teardown hook I should use? After the call returns, the service would hold only host-owned references and accounting data. Any borrow of A’s guest memory would end within the call. If completion cannot be confirmed, the service would retain the references and charges until it can confirm that the GPU context has been destroyed. Store::into_data -
Accounting across stores. I would put a shared tenant-budget handle (for example, an
Arc) in each of that tenant’s stores and charge GPU operations when a host function admits them. My reading is thatResourceLimiterlimits linear-memory and table growth and the numbers of instances, memories, and tables within a store. The embedder accounts for its own allocations. Is shared host state plus admission checks in the GPU host functions the expected boundary, or should another Wasmtime mechanism be involved? If any of these cases needs a change in Wasmtime, a concrete example of where the current API falls short would help narrow the request. Store data · ResourceLimiter
- 主要言語
- Rust
- スター
- 18.9k
- フォーク
- 2k
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 238
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bytecodealliance/wasmtime のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
bytecodealliance/wasmtime#15536 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
bytecodealliance/wasmtime#15455 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
wasi-preview1-component-adapter: fd_write does not invalidate cached InputStream, causing stale reads対応中かも @dpfens が 13 日前に担当しました。 オープンwasi
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
bytecodealliance/wasmtime#15296 ·
メンテナーはふだん 1 日以内に返信
-
bug wasm-proposal:exceptions wasmtime:debugging
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
bytecodealliance/wasmtime#14102 ·
メンテナーはふだん 1 日以内に返信
-
wasm-proposal:gc
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
bytecodealliance/wasmtime#13808 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
bytecodealliance/wasmtime の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Test connection's password prompt says the password is never saved, also for a keychain profileオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
area: settings bug Haiku review: no-score ui
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
MMFoundation/WallpaperMachine#346 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
rubys/roundhouse#2473 ·
-
bug mod: quantum info
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Qiskit/qiskit#17699 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信