Skip to content

fix(gpu): overflow-safe simulator launch, layout and transfer checks (#812) - #1404

Merged
godofecht merged 2 commits into
mainfrom
fix/812-dispatch-dimension-validation
Oct 7, 2026
Merged

godofecht merged 2 commits into
mainfrom
fix/812-dispatch-dimension-validation

Conversation

@godofecht

@godofecht godofecht commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Part of #812 (host-side launch and layout validation). Rebuilt as one commit on main e2205a79.

Change

  • grid_1d, grid_2d, grid_3d in lib/stdlib/gpu_sim.flow: return an empty LaunchConfig for zero or negative sizes, blocks over 1024 threads, or a launch count past i32. Ceil division is (n - 1) / b + 1.
  • host_alloc_f32, device_alloc_f32, the host/device copies and layout_1d/2d/3d reject lengths that would overflow or copy past the destination.
  • docs/project/vgpu-parity.md: a short section, rewritten plainly.

The draft's test sat in tests/core, which no runner executes as a suite (and corpus_parity would need a golden row). It is now tests/runtime/test_gpu_launch_validation.flow.

Proof

  • tests/runtime/test_gpu_launch_validation.flow: passes; with main's gpu_sim.flow it aborts (exit 134, i32 overflow trap).
  • The existing tests/core/test_gpu_sim*.flow programs keep their corpus results (none appear in the corpus mismatch list).

Gates

test-lang 274/0, test-runtime 35/0. corpus_parity --check on Darwin reports 1015 < floor 1033; the mismatches are effects fixtures exiting 134 under strict effects and stdout drifts in examples, none in files this PR touches.

Remaining for #812

The typed render/compute pass graph, hazard checks and Metal/WebGPU fluid and ocean kernels are #1407.

@godofecht
godofecht force-pushed the fix/812-dispatch-dimension-validation branch from 2bed62b to 6c262bd Compare October 7, 2026 12:51
@godofecht godofecht changed the title fix(gpu): overflow-safe simulator dispatch, layouts and transfers (#812) fix(gpu): overflow-safe simulator launch, layout and transfer checks (#812) Oct 7, 2026
@godofecht
godofecht marked this pull request as ready for review October 7, 2026 12:52
@godofecht
godofecht added this pull request to the merge queue Oct 7, 2026
@godofecht
godofecht removed this pull request from the merge queue due to a manual request Oct 7, 2026
@godofecht
godofecht force-pushed the fix/812-dispatch-dimension-validation branch from 6c262bd to 923bb7e Compare October 7, 2026 17:51
@godofecht
godofecht added this pull request to the merge queue Oct 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 7, 2026
@godofecht
godofecht enabled auto-merge October 7, 2026 19:22
@godofecht
godofecht force-pushed the fix/812-dispatch-dimension-validation branch from 923bb7e to da6c3be Compare October 7, 2026 19:23
godofecht added a commit that referenced this pull request Oct 7, 2026
The goldens job ran only on compiler or workflow changes, but the MLIR
corpus names programs under examples, tests, lib and benchmarks, and the
crossing pages read wasm/ and tools/gpu. A pull request touching those
skipped the job and only the merge queue found the failure (#1404).

A new goldens path filter covers all of it, and tools/ci_gating (run in
the Doc links job) fails when a corpus program or a surface the job reads
is outside the filter, or the job is not gated on it. Any .flow change
also runs the parity gates, since parse coverage and fmt_check read every
tracked .flow file.
@godofecht
godofecht added this pull request to the merge queue Oct 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 7, 2026
…812)

grid_1d/2d/3d computed (n + b - 1) / b and multiplied block counts
without bounds, so a large extent or block size overflowed i32 and
trapped. They now return an empty LaunchConfig for nonpositive sizes,
blocks over 1024 threads or a count past i32, and use (n - 1) / b + 1.
The f32 buffer allocators, host/device copies and layout helpers reject
lengths that would overflow or copy past the destination.

tests/runtime/test_gpu_launch_validation.flow aborts (exit 134) with
main's gpu_sim.flow and passes here.
The flowc MLIR goldens job failed in the merge queue on 12 corpus
programs that import gpu_sim.flow. parity_mlir --record, keeping only
those 12 rows and the new tests/runtime/test_gpu_launch_validation.flow.
@godofecht
godofecht force-pushed the fix/812-dispatch-dimension-validation branch from da6c3be to 4bdf87f Compare October 7, 2026 22:47
@godofecht
godofecht enabled auto-merge October 7, 2026 22:47
@godofecht
godofecht added this pull request to the merge queue Oct 7, 2026
Merged via the queue into main with commit 20ceebe Oct 7, 2026
28 checks passed
godofecht added a commit that referenced this pull request Oct 7, 2026
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 added a commit that referenced this pull request Oct 8, 2026
…kernels (#814)

parity_mlir --record on main plus #1404 and #1403, keeping the rows for
programs this PR changes (gpu_memory, its stub, the mnist and depth
examples, the memory bounds test) and its new gpu_tensor module and
tests.
godofecht added a commit that referenced this pull request Oct 8, 2026
…kernels (#814)

parity_mlir --record on main plus #1404 and #1403, keeping the rows for
programs this PR changes (gpu_memory, its stub, the mnist and depth
examples, the memory bounds test) and its new gpu_tensor module and
tests.
@godofecht
godofecht deleted the fix/812-dispatch-dimension-validation branch October 12, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant