[RT][HIP] GPU executor core + first composed trunk forward verified on gfx1150
- rt::executor (feature `hip`): the bridge from the arena-validated plan to
GPU compute. ExecOp { op, reads, writes, params } + OpParams (concrete
shapes) + execute() dispatching the verified microkernels (embed, rms_norm,
gemm_bf16, flash_gqa, moe_router, vec_add, cast). Lowering CompiledPlans+IR
-> ExecOp lands with the packer; this core proves dispatch + composition.
- First COMPOSED GPU forward: embed gather -> rms_norm -> cast f32->bf16 ->
gemm(unembed), verified end-to-end vs a CPU oracle (<1e-4). The composition
test caught a real dtype-transition bug (f32 activation fed to a BF16 GEMM)
— fixed by adding the cast kernel the reference also inserts before matmul.
- kernels/hip: k_cast_f32_bf16 (f32 activation -> BF16 truncate) + C ABI +
wrapper. abi::vplan: CastF32Bf16 opcode (31 total).
- rt: optional hip dependency, feature-gated (default workspace stays
host-independent).
Verified: RUSTFLAGS="-D warnings" cargo test --workspace = 97/97 PASS;
lean proofs (4 files, 42 theorems) green; GPU parity 7/7 + composed trunk
forward 1/1 (--features hip). Principle recorded: parity-first baseline, then
our own measured improvements (Federico).
This commit is contained in:
1 parent
b99d3a7a6a
commit
87a66aee37
8 files changed
+196
-6
No files matched your search
@@ -321,4 +321,26 @@ extern "C" int vetta_vec_add(const float* a, const float* b, float* y, size_t n,
|
||||
k_vec_add<<<grid, nt, 0, s>>>(a, b, y, n);
|
||||
HIP_CHECK(hipGetLastError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ---- k_cast_f32_bf16: f32 activation -> BF16 (truncate) before GEMM --------
|
||||
// The residual stream is f32; trunk/expert GEMMs read BF16 activations (the
|
||||
// reference inserts k_f32_to_bf16/f16 before the matmul). Truncation matches
|
||||
// the bf16 weight storage; RNE rounding is a later precision refinement.
|
||||
|
||||
__global__ void k_cast_f32_bf16(const float* __restrict__ x, uint16_t* __restrict__ y,
|
||||
size_t n) {
|
||||
size_t i = (size_t)blockIdx.x * blockDim.x + threadIdx.x;
|
||||
if (i < n) y[i] = (uint16_t)(__float_as_uint(x[i]) >> 16);
|
||||
}
|
||||
|
||||
extern "C" int vetta_cast_f32_bf16(const float* x, uint16_t* y, size_t n,
|
||||
vetta_stream_t stream) {
|
||||
if (n == 0) return 0;
|
||||
const int nt = 256;
|
||||
const size_t grid = (n + nt - 1) / nt;
|
||||
hipStream_t s = stream ? (hipStream_t)stream : (hipStream_t)0;
|
||||
k_cast_f32_bf16<<<grid, nt, 0, s>>>(x, y, n);
|
||||
HIP_CHECK(hipGetLastError());
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user