Repository navigation
[WebGPU] Add buffer-region workspace preallocation - #32720
Draft
Chi Lo (chilo-ms) wants to merge 54 commits into
Draft
Chi Lo (chilo-ms) wants to merge 54 commits into
Chi Lo (chilo-ms) wants to merge 54 commits into
Conversation
Add an opt-in sequential static-workspace pilot that reuses one aligned buffer per device and routes MatMulNBits slot zero through it with dynamic fallback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cdd38fe6-fcf3-45c2-acea-b8e6206a7839
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cdd38fe6-fcf3-45c2-acea-b8e6206a7839
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cdd38fe6-fcf3-45c2-acea-b8e6206a7839
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cdd38fe6-fcf3-45c2-acea-b8e6206a7839
Use the cached fpA/intB tactic for fixed small-M shapes, while retaining conservative workspace declarations for cache misses and CUTLASS GEMM. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cdd38fe6-fcf3-45c2-acea-b8e6206a7839
Compare scratch and planned MatMulNBits execution with a controlled BFCArena strategy and verify that workspace overlap reduces second-run CUDA allocation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cdd38fe6-fcf3-45c2-acea-b8e6206a7839
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cdd38fe6-fcf3-45c2-acea-b8e6206a7839
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cdd38fe6-fcf3-45c2-acea-b8e6206a7839
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cdd38fe6-fcf3-45c2-acea-b8e6206a7839
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cdd38fe6-fcf3-45c2-acea-b8e6206a7839
Track live reserved allocations separately from BFC regions and report initialization slack and internal fragmentation in the workspace benchmark. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Increase the workspace benchmark sequence length to 1024 tokens and record refreshed RTX 5090 memory and latency results. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add Qwen 3.5 hybrid-cache and Qwen 2.5 7B benchmark profiles, and record their RTX 5090 memory and latency results. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add legacy workspace sizing and planned-workspace retrieval, allocator diagnostics, CUDA coverage, and HY-MT2 memory analysis. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use fixed-capacity aliased past/present buffers to approximate ORT GenAI generation and document the RTX 5090 results. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document the Qwen 2.5 1.5B ABBA rerun and distinguish stable memory findings from variable fresh-process latency. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Report trimmed means and stall rates, document the balanced Qwen 2.5 1.5B rerun, and record traced prefill/decode workspace usage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the matched 3-warmup, 130-sample no-shrink benchmark as the single source of truth and retain shrink only as allocator-attribution evidence. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add bounded non-windowed GQA workspace estimation, conservative cache-alias sizing, slot-0 runtime consumption with scratch fallback, and Qwen benchmark results. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add the fresh-process ORT GenAI benchmark, runtime workspace-consumption diagnostics, and separate Python benchmark results from the C++ provider report. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add compact three-configuration tables for TTFT, scenario latency, TPOT, and peak VRAM across both tested Qwen models. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Organize the compact results by model and define the dispatch paths, latency metrics, and workspace-planning configurations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Trace workspace patterns in training builds, cover oversized cached requests, and reset MatMulNBits instrumentation before early returns. Preserve CUDA plugin and no-fpA builds, Linux internal test exports, tensor-only profiling, and minimal-build size. Keep arena diagnostic outputs unchanged on failure. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the public frame output API and attach the memory profiler in the new regression. Avoid unsupported workspace validation in minimal builds and unnecessary formatting for literal diagnostic errors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the dynamic scratch fallback without unused workspace vtable entries. Match other unsupported experimental APIs by returning not-implemented directly in minimal builds, with documented behavior and output-preservation coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Serialize the complete statistics table through one loop instead of duplicating conversion and insertion at each field. Preserve all 11 keys, including ReservedBytes, and add output-shape regression coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add offset-aware provider buffer regions, multiple MatMulNBits workspace slots, and workspace-only memory-pattern planning when WebGPU activation patterns are disabled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Track WebGPU allocator high-water statistics and compare Qwen 2.5 1.5B workspace planning with process-local WDDM sampling. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Report three balanced Qwen 2.5 1.5B runs with allocator, WDDM, and latency metrics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add selectable Qwen profiles and report balanced Qwen 2.5 7B allocator, WDDM, and latency measurements. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the subgroup tile-size helper visible wherever its implementation is compiled and scope native-only workspace variables accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Make the Qwen benchmark sequence length configurable, capture WDDM residency after each warmup, and document long-context latency, memory, and capacity results. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extend the shared GenAI benchmark for WebGPU and add matched cache/planner controls with separate latency and whole-process/post-warmup memory measurements. Document the focused comparison and replace the superseded C++-only report. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack and merge target
Depends on #32071. The WebGPU-specific changes were restacked onto its updated head (
e964fed7b7), and current main at the time (34d838fbcd) was merged into this branch.This draft targets main. Until #32071 lands, the PR diff also includes its prerequisite workspace-planning changes; merge the parent first.
Summary
Integration notes
Conflict resolution preserves main's deferred pipeline dispatch, zero-initialized buffer reuse, and error propagation, along with #32071's diagnostic hooks and minimal-build exclusions. Workspace declarations use the current positional WorkspaceInputShape API. Plugin and minimal configurations retain dynamic scratch instead of requiring unavailable workspace interfaces.
Planning remains sequential and is disabled for multiple logical streams on one device. Ordinary WebGPU activation planning is unchanged. The base MatMulNBits kernel declares workspace for eligible DP4A and subgroup-prepack paths; this does not imply coverage of every MatMulNBits dispatch or fused operator.
Controlled WebGPU benchmark
The controlled benchmark report is the reference for these results. The superseded C++-only report has been removed to avoid presenting measurements with different cache settings and memory windows as equivalent.
Method: RTX 5090 Laptop GPU, Windows Release, Dawn Vulkan, driver 610.62. Both harnesses use
enableInt64=1, graph capture off, NHWC, and explicit disabled/bucket storage-buffer caching. Each scratch/planned configuration uses five warmups, three measured requests, and two order-balanced fresh processes per phase. Latency and memory run in separate processes. The focused matrix comprises 96 workers: 80 successful and 16 OOM.C++ measures a cached-prefill forward with repeated BOS tokens, one-token zero past cache, and full logits. GenAI uses seeded synthetic prompts and 128 generated tokens, with prefill and decode reported separately. Comparisons are controlled within each harness; these remain different workloads.
Latency
Values are scratch / planned, in seconds. GenAI decode covers the 127 tokens after the first generated token.
Memory
Values are scratch / planned, in MiB. A single external
nvidia-smistream per memory worker covers process launch through exit; the child-reported measurement window selects the post-warmup samples. Both harnesses therefore use the same device-wide counter. These are sampled maxima, not exact allocator high-water marks.Interpretation:
Validation
onnxruntime_test_allandonnxruntime_provider_test; the provider-test target was rebuilt for the controlled instrumentation.fc7463f156.These are targeted checks, not a full-suite run or proof of planned-workspace consumption on every GPU path. The report includes reproduction commands, exact timing boundaries, provider options, runtime provenance, and measurement limitations.