onnxruntime
1e9aee07 - [WebGPU] Zero-initialize writable device allocator buffers (#32063)

Commit
2 days ago
[WebGPU] Zero-initialize writable device allocator buffers (#32063) ### Description - Zero-initialize writable WebGPU device-allocator buffers while leaving read-only initializer and internal WebGPU allocations unchanged. - Clear reused pooled buffers directly in `BufferManager::Create` in command order, and enable Dawn lazy resource clearing for fresh buffers. - Track session-run activity so allocator clears are batched during `Session::Run`, but submitted before allocation returns outside `Run`; shared allocator clears are always submitted immediately. - Keep allocation clears out of captured graph commands because graph replay reuses buffers allocated before replay. - Keep dispatch-window limit enforcement in `WebGpuContext` and add regressions for allocation submission policy, graph capture, and profiled dispatch batching. ### Motivation and Context Fixes #28974. Reused device-allocator buffers can retain data from prior model execution. Writable session and shared allocations must therefore be zero-initialized when handed out. Reused buffers are explicitly cleared before use, while newly created buffers rely on Dawn's lazy-clear guarantee. Clearing and submission are separate policies. During `Session::Run`, the clear remains ordered in the current command encoder and is submitted with the surrounding dispatch batch. Outside `Run`, including through the shared allocator exposed to users, the clear is submitted before allocation returns so subsequent queue work observes it. Allocator clears are allocation-time initialization rather than graph work. They are encoded in normal command order but are not stored in `CapturedCommandInfo` or repeated by `ReplayGraph()`, whose inputs and outputs are allocated in advance. ### Testing - Incremental Release build of `onnxruntime_provider_test` - `WebGpuContextTest.*` - `WebGpuDispatchBatchingTests.*` - `GraphCaptureTests.TestReleaseCapturedGraph` - `InferenceSessionTests.TestGraphCapture` All 16 focused tests pass.
Author
Parents
Loading