Repository navigation
Conversation
…sources Add stdlib/gpu_tensor.flow so Flow tensors and vgpu model cases consume the same GpuBuffer storage as ordinary @gpu kernels. Unified backends are zero-copy; private buffers and the stub use explicit conversions. Shape/dtype/access mismatches are rejected before dispatch. Wire the MNIST and depth-estimation examples through that path, emit Metal and WGSL from the same source, and compare against a host-Tensor reference. flow gpu test now runs numerical cases and checks goldens. Closes #814 Co-authored-by: Abhishek Shivakumar <[email protected]>
|
I fixed the two stale metadata/test blockers from CI run #2819 on this branch: |
…p staging coherent (#814)
Regenerated docs/library/stdlib-api.md, added the docs nav, coverage and stdlib-map entries and the LSP completion golden for the new module, and listed test_gpu_tensor and test_gpu_model in flow ml test. Carried from the older #1364 branch. One string.flow comment is reworded because the prose hook blocks the regenerated table line.
|
Closing in favour of #1406, which is this branch rebased onto current main. It keeps The docs index entries for |
Acceptance status (2026-10-06): partial; not a device-parity claim. Real Metal model kernels and a reusable reflected WebGPU multi-pass executor were added. WebGPU MNIST/depth hardware execution, real Flow test corpus and reconciliation with other open GPU PRs are not verified. We tested the actual WebGPU JS module in isolated V8 with mocked devices (9/9 validations) but not real WebGPU. CPU reference accuracy and WGSL emission alone DO NOT establish the requested backend parity. Do not merge/close #814 on this evidence.
Part of #814
Intent
Linked issue or roadmap item: #814 (vgpu P3)
What changed, and why is this the smallest useful change?
stdlib/gpu_tensor.flowis a shaped, typed view of the existingGpuBufferresource. Model execution and ordinary@gpukernels consume that storage in place, so MNIST and depth estimation do not grow a second inference stack. Unified backends are zero-copy; private buffers and the stub use explicit upload/download. Shape, dtype, access and resource kind are checked before dispatch.Overlap check
Overlap / dependency notes:
Sibling issues #811 (typed textures/geometry), #812 (render/compute graph) and #813 (conformance runner) stay on their own surfaces. This PR only adds tensor views over
GpuBuffer(already on main) and extendstools/gpu_testto run numerical cases. It does not add textures, samplers, vertex stages, orgpu framehazards. #813's runner is already on main; this wires the MNIST/depth cases it already lists.A prior unmerged attempt (782cdd5) added Python unit tests and
gpu_buffer_ptr; that is not reused. New tests are Flow.Evidence
Baseline before this change:
examples/gpu/vgpu/mnist.flowanddepth_estimation.flowwere stubs that printed a line.flow gpu testreportedNUMERICALwithout running them. HostTensorandGpuBufferwere separate stacks.Targeted proof that exercises the changed behaviour:
./flow run tests/stdlib/test_gpu_tensor.flow— alloc, require/layout, host conversion, same-storage ops, wrap rejects (exit 0)./flow run tests/stdlib/test_gpu_model.flow— MNIST-like and depth-like interop vs host Tensor; linear shape reject (exit 0)./flow run examples/gpu/vgpu/mnist.flowanddepth_estimation.flow—match 1against the host reference./flow gpu/./flow gpu --wgslon both examples — Metal and WGSL kernels./flow gpu test --suite vgpu --all-backends—NUMERICALfor mnist/depth on metal and webgpu./flow test-scripts gpu_tensor— 7 passed, 0 failed./flow test-scripts wiki_nav— 17 passed./flow tool gen_stdlib_docs --check— up to dateWhy that proof would detect the old failure or regression:
The old stubs never compared a GPU-resource path to a host Tensor. A missing bind check, a CPU round-trip between stages, or a shader emit failure fails these programs.
Repository gate(s) run:
The proofs above. No
compiler/srcchange, so no bootstrap regen.Generated/bootstrap state, if any:
docs/library/stdlib-api.mdregenerated. Bootstrap C unchanged.Risk
Compatibility, performance, security, lifetime, backend, or release implications:
New library module only. The GPU stub still reports
gpu_available() == false; tensors then use host staging of the same type.@gpukernels emit for Metal and WebGPU;flow runexecutes the portable ops on the shared storage (Cgpu_thread_id()remains thread 0). Typed textures stay with #811 (GPU_RES_TEXTUREis a reserved kind tag).docs/project/Questions.mdupdated if this needs a language-design decision.Compatibility
docs/project/CHANGELOG.md.New
gpu_tensorAPI is additive; CHANGELOG records it under Unreleased.Agent handoff
Cloud agent session for #814. Remaining hardware-dispatch of
@gpukernels on a live Metal/WebGPU device is the existingflow gpuemit path plus host bind; this PR does not add a separate runtime launcher.