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 / tests / amd-exec / fp8block_fast.md
| 1 | # Wide-load block-scaled FP8 GEMV |
| 2 | |
| 3 | `fp8gemv_b128f` is an additional kernel; the existing kernels are unchanged. |
| 4 | The production input is `backend/amd/gfx942/fp8gemv_b128f.isa`, consumed by |
| 5 | seeded Omega `hsaco.om`. The adjacent LLVM assembly is an independent encoding |
| 6 | oracle, not a production dependency. The ABI remains that of `fp8gemv_b128`. |
| 7 | |
| 8 | Each lane owns four consecutive columns in a 256-column chunk. The main loop |
| 9 | prefetches four W dwords and four x dwordx4 vectors per lane before waiting. |
| 10 | The two half-waves use their respective 128-column BF16 scales; each fetched |
| 11 | scale is reused for the lane's four products. Identical scale addresses within |
| 12 | a half-wave are coalesced, not claimed to be a single scalar memory instruction. |
| 13 | A lane computes a four-product partial, scales it into its running accumulator, |
| 14 | and performs one XOR32/16/8/4/2/1 reduction after all columns. Scalar predicated |
| 15 | loads handle the residual chunk without reading past K or the scale grid. |
| 16 | BF16 d16-hi destinations are zero-initialized: correctness does not depend on |
| 17 | whether hardware preserves or clears the unused register half. |
| 18 | |
| 19 | ## Numerical contract |
| 20 | |
| 21 | Moving the reduction outside the K loop changes floating-point summation order. |
| 22 | Bit identity with `fp8gemv_b128` is therefore **not** the contract for this fast |
| 23 | variant. The acceptance report records exact baseline/fast output-bit witnesses, |
| 24 | including real checkpoint rows. No tolerance was increased: the notebook uses |
| 25 | v11's unchanged `oracle`, `gamma`, and `mismatches` functions for both kernels. |
| 26 | The host acceptance evaluates the same bound against an exact rational sum: |
| 27 | |
| 28 | ``` |
| 29 | n = ceil(K/128) + 8 |
| 30 | gamma(n,u) = n*u / (1-n*u) |
| 31 | bound = (gamma(n,2^-24) + gamma(2*K+n,2^-53))*sum(abs(W*s*x)) + 2^-126 |
| 32 | ``` |
| 33 | |
| 34 | The separate exact Fraction oracle specifies every FMA and reduction rounding |
| 35 | in the fast kernel, and checks every byte of the resulting memory image. |
| 36 | This is tested numerical evidence, not a proof for arbitrary overflowing inputs |
| 37 | or a claim of model-level logit/token parity. OCP E4M3 decoding includes both |
| 38 | NaNs and signed zero; native gfx942 FNUZ is not used as the reference format. |
| 39 | |
| 40 | ## CPU acceptance |
| 41 | |
| 42 | Run from the repository root under an externally held free queen CPU-pool lock with `nice` and CPU affinity. Set `OMEGA_OMC`, `AMD_WEIGHTS` and `AMD_DOC_OUT` as in `fp8block.md`; run that document first to produce the baseline bundle. Use `python3` on the caller's PATH. Missing dependencies are NOT_RUN. |
| 43 | |
| 44 | ```sh |
| 45 | python3 tests/amd-exec/fp8block_fast.py \ |
| 46 | --omc "$OMEGA_OMC" \ |
| 47 | --weights "$AMD_WEIGHTS" \ |
| 48 | --out "$AMD_DOC_OUT/fp8block_fast" |
| 49 | ``` |
| 50 | |
| 51 | The run checks the compiler pin, deterministic seeded producer/executor and |
| 52 | objects, LLVM text/metadata/descriptor parity, all FP8 bytes, zero dimensions, |
| 53 | partial and wide-load boundary cases, and sampled checkpoint rows at every |
| 54 | requested real shape. Bounds mode records each buffer's last access. Rebuilt |
| 55 | per-row-scale, transposed-scale and dropped-tail controls must fail both exact |
| 56 | comparison and the unchanged v11 tolerance; shortened-span controls must exit 68. |
| 57 | Commands, source snapshots, checkpoint hashes and results are retained in the |
| 58 | new run directory. Failed run directories must not be reused or overwritten. |
| 59 | |
| 60 | After committing the tested sources, create a fresh notebook bundle under the |
| 61 | same CPU-lock discipline: |
| 62 | |
| 63 | ```sh |
| 64 | python3 tests/amd-exec/fp8block_fast_bundle.py \ |
| 65 | "$AMD_DOC_OUT/fp8block_fast" "$AMD_DOC_OUT/fp8block-fast-bundle" "$AMD_DOC_OUT/fp8block-bundle" |
| 66 | ``` |
| 67 | |
| 68 | The bundle checks committed source hashes and retains the baseline's exact |
| 69 | source head, object, table and acceptance evidence. See |
| 70 | [`fp8block_fast_notebook/README.md`](fp8block_fast_notebook/README.md) for the |
| 71 | notebook build and simulated-device acceptance. Only the relay can provide |
| 72 | hardware correctness or timing evidence. |