Repository navigation
fix(gpu): reject oversized transfers and f32 kernel counts before the backend (#814) - #1403
Merged
Merged
Conversation
This was referenced Oct 6, 2026
godofecht
force-pushed
the
fix/814-gpu-transfer-and-dispatch-bounds
branch
from
October 7, 2026 12:37
9fd7cf8 to
2b5e093
Compare
godofecht
marked this pull request as ready for review
October 7, 2026 12:38
7 of 8 tasks
godofecht
force-pushed
the
fix/814-gpu-transfer-and-dispatch-bounds
branch
from
October 7, 2026 16:28
2b5e093 to
ba1d634
Compare
godofecht
enabled auto-merge
October 7, 2026 17:03
godofecht
force-pushed
the
fix/814-gpu-transfer-and-dispatch-bounds
branch
from
October 7, 2026 17:12
d8c2ec5 to
ba1d634
Compare
godofecht
force-pushed
the
fix/814-gpu-transfer-and-dispatch-bounds
branch
from
October 7, 2026 17:57
ba1d634 to
50a8fb4
Compare
… backend (#814) The gpu_memory wrappers passed any positive byte count to the backend. They now reject a copy larger than either buffer's size, unknown allocation flags, typed allocation counts that overflow the byte size, and f32 kernel counts beyond any of the three buffers or the shader's 32-bit count. The Metal dispatch checks the native sizes again through flow_gpu_f32_launch_fits before it initialises compute, and shared-to-shared device copies use memmove. tests/runtime/test_gpu_memory_bounds.flow exits 12 with main's library (it accepts flags 99) and passes here.
flowc MLIR goldens fail on the three corpus programs that compile gpu_memory.flow. parity_mlir --record on main plus #1404, keeping only those rows and the new tests/runtime/test_gpu_memory_bounds.flow.
godofecht
force-pushed
the
fix/814-gpu-transfer-and-dispatch-bounds
branch
from
October 7, 2026 23:37
50a8fb4 to
0492e74
Compare
godofecht
enabled auto-merge
October 7, 2026 23:37
godofecht
added a commit
that referenced
this pull request
Oct 8, 2026
godofecht
added a commit
that referenced
this pull request
Oct 8, 2026
godofecht
added a commit
that referenced
this pull request
Oct 8, 2026
godofecht
added a commit
that referenced
this pull request
Oct 8, 2026
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 (GPU resource safety). Rebased as one commit on main
f313b641.Change
lib/stdlib/gpu_memory.flow: reject a copy larger than either buffer'ssize, unknown allocation flags, typed allocation counts that overflow the byte size, and f32 kernel counts beyond any of the three buffers or the shader's 32-bit count. All before the backend is called.runtime/gpu_memory.h:flow_gpu_f32_launch_fits, used by the Metal dispatch to check native sizes before compute init.runtime/gpu_metal.m: shared-to-shared device copy usesmemmove.Dropped from the draft:
tests/native/gpu_f32_bounds.c(no runner executes it). The Flow test moved from tests/lang to tests/runtime, because test-lang does not link the GPU runtime.Proof (macOS arm64, real Metal)
tests/runtime/test_gpu_memory_bounds.flow: passes; with main'sgpu_memory.flowit exits 12 (flags 99 accepted)../flow test-gpu: gpu_features and Metal codegen pass.examples/gpu/gpu_mul_backward.flow(real Metal f32 kernels): PASS.examples/gpu/gpu_memory_roundtrip.flow: PASS.Gates (on f313b64)
test-lang 274/0, test-runtime 36/0, test-gpu pass, tests/tools pass, tests/cli 152/2 (
jit_hello,test_mlir: known drift on this Mac).Merge note
#1406 changes the same bounds check in
runtime/gpu_metal.m. When it is rebased after this lands, the resolution keeps #1406's comment and callsflow_gpu_f32_launch_fitsbefore compute init.Remaining for #814
Model execution over shared GPU resources (MNIST / depth parity on Metal and WebGPU) is the work in #1406 and #1408.