Proposing a host-side design for sharing read-only GPU weights across Wasmtime component instances
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 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 小时
- 30 天内合并 PR
- 238
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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
-
lane:collections todo:ticket
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 3 天内回复
-
bugfix
难度 2/5 1-3 小时 新手友好度 72/100
storytold/designcraft#3662 ·
维护者通常 1 天内回复
-
documentation
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
good first issue tooling
难度 2/5 1-3 小时 新手友好度 78/100
Nixitov/Riptide-Native#521 ·
维护者通常 1 天内回复