[HIP] copy_f32: device-side f32 copy for depth-block snapshot / bank rollback
k_copy_f32 (dst=src, n elements): enables device-side depth-block snapshot and core-loop bank rollback in the batched forward, eliminating the M=1 host D2H/H2D round-trips (layer.rs block snapshot + bank rollback). Exact (test copy_f32_exact). Additive — decode default unchanged. Foundation for the device-resident depth-block arena [n_blocks,B,h] that attn_res_mix reads directly (already M>1). Verified: hip GPU 32 green, workspace CPU -D warnings green, 6 Lean 0 sorryAx.
This commit is contained in:
1 parent
48de65d395
commit
3a2ad4da49
2 files changed
+39
No files matched your search
@@ -664,6 +664,23 @@ extern "C" int vetta_vec_add(const float* a, const float* b, float* y, size_t n,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ---- k_copy_f32: device-side f32 copy (dst=src), for depth-block snapshot ----
|
||||
// and bank rollback in the batched forward (no host D2H/H2D round-trip).
|
||||
__global__ void k_copy_f32(const float* __restrict__ src, float* __restrict__ dst, size_t n) {
|
||||
size_t i = (size_t)blockIdx.x * blockDim.x + threadIdx.x;
|
||||
if (i < n) dst[i] = src[i];
|
||||
}
|
||||
|
||||
extern "C" int vetta_copy_f32(const float* src, float* dst, 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_copy_f32<<<grid, nt, 0, s>>>(src, dst, n);
|
||||
HIP_CHECK(hipGetLastError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ---- k_router_gemv: y[N] = x_f32[K] @ w_bf16[N,K]^T, f32 accumulate --------
|
||||
// Exact strata B=1 router (launch_f32_linear): the router reads the F32 mlpin
|
||||
// (NOT bf16-rounded) against the bf16 gate weight promoted to f32. Rounding the
|
||||
|
||||
Reference in new issue
Block a user