Stream: git-wasmtime

Topic: wasmtime / issue #15348 Proposing a host-side design for ...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 18 2026 at 15:51):

zzj-5341 opened issue #15348:

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.

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

  1. Resource ownership. The out-of-tree wasi-webgpu-wasmtime bindings take a host-provided ResourceTable and a reference to an Arc<wgpu_core::global::Global>. The prototype currently uses instance-local integer handles. For a component-resource version, I’m considering putting an Arc to 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 that ResourceTable::push requires Send + 'static, is this the expected pattern for independently droppable handles? If a guest never calls resource.drop and the host doesn’t remove the entry, does it remain until the table is dropped? Would you use ResourceTable::set_max_capacity to bound total table entries in that case and account for GPU memory separately? Host bindings · ResourceTable

  2. 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 Arc held 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 with Store::into_data to 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

  3. 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 that ResourceLimiter limits 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

view this post on Zulip Wasmtime GitHub notifications bot (Nov 18 2026 at 18:25):

alexcrichton commented on issue #15348:

As this seems like mostly a design question you might also be interested in our Zulip channel for related discussion. Otherwise do you have any specific questions here? This is a lot of text to sift through with a lot of information about things that maintainers aren't necessarily experts on, so if you're asking for a design review of your architecture you're asking for a lot of effort to be spent to do so. That's unlikely to happen most likely, but if you have specific questions that can be answered here or on Zulip.


Last updated: Nov 19 2026 at 20:05 UTC