CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
CUDApp / om / conv2d / README.md
| 1 | # Seeded implicit conv2d |
| 2 | |
| 3 | Public API: `src/omega_gpu_conv2d_api.h`. `omega_gpu_conv2d_plan(shape,launch,plan)` admits and maps one launch; `omega_gpu_conv2d_codegen(shape,program,code,capacity,kernel)` emits the complete kernel; `omega_gpu_conv2d(shape,image,filter,output)` is the session/memory shell. Status values: OK 0, BAD_ARGS 1, REFUSED 2, CODEGEN 3, CHIP 4. |
| 4 | |
| 5 | Inputs and outputs are contiguous NCHW (layout 0) or NHWC (layout 1). Filters are always contiguous OIHW `[CO, CI/groups, KH, KW]`. This is cross-correlation with explicit independent top/bottom/left/right zero padding. Strides and dilations are positive. No bias, fused activation, scaling or SAME-padding convention. Dtypes follow `omega_gpu_dnn_types.h`: 0 f32, 1 bf16, 2 IEEE f16. Both operands use the selected storage; arithmetic and output are f32. |
| 6 | |
| 7 | All positive dimensions/strides/dilations/groups are at most 65535; padding is 0..65535. Input and output channels must be divisible by groups. Empty output geometry is refused. Each input/filter/output element count and launch count must be below 2^30. The planner checks these before any device session access. Caller buffers must cover the returned byte counts; plan does not validate memory provenance. |
| 8 | |
| 9 | ## Composition |
| 10 | |
| 11 | `om/gemm-any/gemm_ir.om` contains the one seeded scalar reduction, `gs_dot`, shared by dense F32 GEMM and convolution. Existing cfg8 tensor PACK/MAIN and public GEMM APIs are preserved. Default F32 no longer uses handwritten C FFMA generation. That implementation exists only behind default-OFF `CUDAPP_MIGRATION_PENDING_C_GEMM_BUILDER` as a differential oracle. |
| 12 | |
| 13 | Conv computes virtual-image and filter addresses inside the emitted kernel. One launch covers one batch/output-channel/output-row, with 128-thread tiles across output width. The seeded planner supplies every launch count, offset and grid dimension. Kernel loops over KH, KW, CI/groups and invokes the common scalar reduction. Invalid image coordinates read a valid location but mask its bits to positive zero before arithmetic; invalid output lanes never store. No host or global im2col is produced. Temporary device memory consists only of the original input/filter, f32 output and code. |
| 14 | |
| 15 | The scalar implementation is a correctness path, not a tuned tensor-convolution performance claim. Existing tensor GEMM remains available and unchanged. Generic checked replay and native half conversion use the shared integration seams without alternate trust paths. |
| 16 | |
| 17 | ## MODELED arithmetic |
| 18 | |
| 19 | WolframLanguageEvaluator query: |
| 20 | |
| 21 | ``` |
| 22 | {Reduce[h+pt+pb-d (r-1)-1>=0 && s>=1,h,Integers], |
| 23 | FullSimplify[Floor[(h+pt+pb-d (r-1)-1)/s]+1], |
| 24 | Table[{k,N[(k/2^24)/(1-k/2^24),16]},{k,{1,9,27,45,81,135}}], |
| 25 | FullSimplify[(c*kh*kw+y*kw+x)==((c*kh+y)*kw+x)]} |
| 26 | ``` |
| 27 | |
| 28 | Result: admitted integer geometry requires `s>=1` and `h>=1-d-pb-pt+d*r`; output extent is `1+Floor[(-1+d+h+pb+pt-d*r)/s]`; filter flattening identity is True. F32 FMA forward-error bounds gamma_K for K=1,9,27,45,81,135 are respectively 5.96046483281045e-8, 5.36442090748478e-7, 1.60932799886799e-6, 2.68221620915707e-6, 4.82799953627362e-6, 8.04669179340554e-6. These are MODELED, not measured chip accuracy. Tests compare against independent naive double convolution with `gamma_K * sum(abs(products)) + 2^-126` for finite test inputs. |
| 29 | |
| 30 | ## Focused host gates |
| 31 | |
| 32 | After source generation with the pinned compiler and bridge: |
| 33 | |
| 34 | ``` |
| 35 | bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 make -j3 test-gpu-conv2d test-gpu-conv2d-gemm-f32 |
| 36 | bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 env OMEGA_OMC=/home/drakestapleton/work/cudastack/omega-mv/seed/out/omc OMEGA_BRIDGE=/home/drakestapleton/work/cudastack/omega-bridge make -j3 test-gpu-conv2d-mutants |
| 37 | ``` |
| 38 | |
| 39 | The first target runs the complete generated IR in warpSIM, both layouts and all storage types, batch/group/depthwise, stride/pad/dilation, 1x1/3x3 and odd width/channel/spatial tails. Independent wrong-group reference must disagree. In addition to the empty-device namespace, host session link wrappers abort on any device access under `--sim`, including admission mutants. Only the explicit memory-only `--shell-contract` mode permits fake sessions: positive controls cover NULL-open/zero-allocation and nonNULL-open/one-failed-allocation semantics. Dense F32 runs emitted seeded and migration-C oracle kernels separately against double reference and compares output digests. Five source mutants must compile then fail numeric behavior; a separately compiled direct-open mutant must die with SIGABRT. Existing C3 focused regression gates remain required by integration and use the same namespace isolation plus `gpu_conv2d_guard.c` abort wrappers. No full suite, GPU or performance qualification is implied. See `CHIP.md` for the separately authorized operator-only hardware runbook. |
| 40 | |
| 41 | ## Exercised private host evidence |
| 42 | |
| 43 | Implementation commit before final documentation: `9a2efca`; compiler source |
| 44 | `omega-mv@e5b32567`, omc SHA256 |
| 45 | `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`. |
| 46 | No chip qualification is asserted. |
| 47 | |
| 48 | Final device-isolated focused command (exit 0): |
| 49 | |
| 50 | ``` |
| 51 | bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 env OMEGA_OMC=/home/drakestapleton/work/cudastack/omega-mv/seed/out/omc OMEGA_BRIDGE=/home/drakestapleton/work/cudastack/omega-bridge make -j3 test-gpu-conv2d test-gpu-conv2d-gemm-f32 test-gpu-conv2d-mutants build/gpu_conv2d_chip_test |
| 52 | ``` |
| 53 | |
| 54 | Observed final lines: |
| 55 | |
| 56 | ``` |
| 57 | conv2d host+warp-sim: PASS (1454 checks, 0 failures) |
| 58 | conv2d host+warp-sim: PASS (27 checks, 0 failures) |
| 59 | dense F32 digest 93efbbc6b4debf83 |
| 60 | conv2d host+warp-sim: PASS (1290 checks, 0 failures) |
| 61 | conv2d source mutants: PASS (5 compiled, 5 behaviorally killed) |
| 62 | conv2d direct-open mutant: PASS (SIGABRT before device access) |
| 63 | ``` |
| 64 | |
| 65 | The chip executable was compiled only, never executed. The five numerical |
| 66 | mutations were product/FMA operation, image stride, dilation, padding mask and |
| 67 | filter spatial flattening. Each compiled before its numeric mismatch. |
| 68 | |
| 69 | Retained C3 focused command (exit 0), with abort guards on both default and |
| 70 | migration-oracle binaries: |
| 71 | |
| 72 | ``` |
| 73 | bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 make -j3 CC='cc tests/gpu_conv2d_guard.c -Wl,--wrap=omega_gpu_session_open,--wrap=omega_gpu_session_lock,--wrap=omega_gpu_session_unlock,--wrap=omega_gpu_session_free,--wrap=omega_gpu_session_alloc' test-gpu-gemm-any test-gpu-gemm-any-differential |
| 74 | ``` |
| 75 | |
| 76 | Observed: |
| 77 | |
| 78 | ``` |
| 79 | GEMM ANY SIM SWEEP PASS (286 distinct shapes, 2288 multiplies, 2552824 output words, bitwise model + per-K bound) |
| 80 | GEMM ANY HOST/SIM/MUTANTS PASS |
| 81 | GEMM ANY C/OMEGA SIM-EQUAL PASS (not byte-identical kernels) |
| 82 | ``` |
| 83 | |
| 84 | Generated unit check (exit 0; generation only, not a device/test command): |
| 85 | |
| 86 | ``` |
| 87 | taskset -c 10-14 nice -n 10 env OMEGA_OMC=/home/drakestapleton/work/cudastack/omega-mv/seed/out/omc OMEGA_BRIDGE=/home/drakestapleton/work/cudastack/omega-bridge sh om/units.sh --check |
| 88 | PASS portable Omega units regenerate byte for byte |
| 89 | ``` |
| 90 | |
| 91 | The full suite is NOT_RUN by this lane; the integrator owns its single attempt. |
| 92 | Hardware, performance, merge and deployment remain NOT_RUN/not performed. |