Repository navigation
feat(webgpu): execute chained Flow kernels over persistent device resources (#814) - #1408
Merged
Merged
Conversation
This was referenced Oct 6, 2026
godofecht
force-pushed
the
feat/814-webgpu-kernel-chain
branch
from
October 7, 2026 13:28
25484a3 to
737ab4c
Compare
godofecht
marked this pull request as ready for review
October 7, 2026 13:28
godofecht
enabled auto-merge
October 7, 2026 17:03
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 7, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 7, 2026
…on and explicit readback (#814)
…on and explicit readback (#814)
…eadback and failures (#814)
…and workgroup bounds (#814)
…and workgroup bounds (#814)
…pes and oversized workgroups (#814)
…tensor dimensions (#814)
Two Flow kernels from tools/gpu --crossing-manifest failed on a real WebGPU device (Deno, Metal backend). Flow reflects every output as read_write, and the host treated read_write as a read of uninitialised memory, so no chain with a fresh output could run. Only read bindings now need prior contents. The uniform block went to writeBuffer as a bare ArrayBuffer, which Deno rejects; it now goes as a Uint8Array view. The mock device now refuses a bare ArrayBuffer as the real one did, the test stage helper uses the read_write access Flow emits, and a new test uses the exact reflection shape the compiler writes.
wiki_nav failed with 'gpu/persistent-compute.md is in no nav section'.
webgpu-host.js now re-exports runFlowKernelChain from ./gpu-kernel-chain.mjs, but the crossing builder copied only the host, so a built page failed its module import and the gpu crossing goldens failed in the merge queue (7 cases). The builder copies every '} from "./NAME"' module next to the host. Goldens updated: the new host, gpu-kernel-chain.mjs, and one more 'wrote' line for gpu pages.
godofecht
force-pushed
the
feat/814-webgpu-kernel-chain
branch
from
October 7, 2026 20:53
1348752 to
15bb37a
Compare
godofecht
enabled auto-merge
October 7, 2026 20:53
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.
Part of #814. Does not close it. The WebGPU counterpart of #1406.
Change
runFlowKernelChain(wasm/crossing_assets/gpu-kernel-chain.mjs, same file undersite/wasm-crossings/gpu/, exported fromwebgpu-host.js) runs several Flow-generated@gpukernels in one command buffer over persistent GPU buffers and maps only the requested outputs. It checks bindings, aliasing, uniform layout, dispatch and workgroup limits, read-before-write and readback of unwritten resources, and fails on WGSL compile errors.docs/gpu/persistent-compute.mddescribes it.Fixed in this rebase, found by running two Flow kernels on a real adapter:
read_write(WGSL has no write-only storage buffer). The host treatedread_writeas a read of uninitialised memory, so any chain with a fresh output was refused. Onlyreadbindings now need prior contents.queue.writeBufferas a bareArrayBuffer, which Deno's WebGPU rejects. It now goes as aUint8Array.The mock tests had used an access mode (
write) the compiler never emits and a mock that accepted a bareArrayBuffer, so they passed against the broken host. The mock is now as strict as the real device, the stage helper usesread_write, and a new test uses the exact reflection shape the compiler writes.tests/scripts/webgpu_hosts.flowruns everytests/webgpu/*.test.mjswithnode --testfrom./flow test-scripts, skipping when node is absent, so these tests have a runner.Evidence
Rebased onto main e2205a7.
scale2thenadd_one, emitted by./flow tool tools/gpu/main.flow --crossing-manifestfrom a two-kernel Flow file, run throughrunFlowKernelChainin Deno 2.7 (--unstable-webgpu, Metal backend on Apple silicon) over 1,000 elements:execution=webgpu-device, 0 mismatches against2x + 1. Before the fix the same run failed withFlow GPU resource read before write: b, then withdata must be an ArrayBuffer or ArrayBufferView.node --test tests/webgpu/kernel-chain.test.mjs: 9/9. Against the previous host, 4 fail../flow test-scripts webgpu_hosts: passes../flow tool tests/cli/run.flow: 152 passed, 2 failed (jit_hello,test_mlir: golden drift on main). Shell and Python ratchets pass.test-langandtest-runtimewere not run: no Flow source they compile changed.The real-device script is a one-off and is not committed, since CI has no GPU. MNIST and depth through this host remain open on #814.
Merge notes
#1405 and #1407 also add an export line at the top of
webgpu-host.js(and itswasm/crossing_assetscopy). Keep all three lines when resolving. Theirtests/webgpu/*.test.mjsfiles are picked up bywebgpu_hosts.flowwithout changes.