interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / tests / amd-exec / fp8block_fast.md

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