tests/r4d_emu: the tiled LoRA rows -- matrix, real shapes, batch invariance, codes

The shared lora_cases matrix now runs the tiled rows beside the scalar ones,
handing a row the scratch its hook asks for. test_lora adds: the real shapes
(K 2048 / 5120 / 6144 / 17408, R 16 / 48 / 64 / 192, N 256 .. 12288, odd M,
S 1..4, bf16 / E4M3 / E5M2 / i8, aligned and unaligned rows), each a shrink
-> expand pair held to the f64 bound and to libref's bytes; a row alone vs
the same row inside M = 7 / 16 / 17 / 37 / 300 of random slots and base
rows, bit for bit, through aligned and unaligned buffers; a base-only M 2048
launch touching nothing; and every fp8 / i8 code widened exactly through a
one-hot pool. The emulator shim gains the fence, atomic and allocation calls
the split's arrival counters use.
This commit is contained in:
baKon committed 2026-10-16 20:52:09 -05:00
1 parent ec1e830c43
commit 487a9f4399
3 files changed
+514 -9

No files matched your search

+12
View File
@@ -6,6 +6,7 @@
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <vector>
@@ -99,6 +100,17 @@ int emu_cvt_pk_fp8(float a, float b, int old, bool hi);
#define __builtin_amdgcn_cvt_pk_fp8_f32(a, b, old, hi) emu_cvt_pk_fp8((a), (b), (old), (hi))
extern int emu_last_block; /* threads a block of the last grid had: which kernel ran */
/* Blocks run one after another on one OS thread, so a fence orders nothing that is not already in
* order and an atomic is a plain read-modify-write. Enough for the split-K arrival pattern
* (r4d_lora_bf16.hip): the last block of a group in launch order is the one that reduces. */
inline void __threadfence() {}
#define __HIP_MEMORY_SCOPE_AGENT 3
#define __hip_atomic_fetch_add(p, v, order, scope) emu_atomic_fetch_add((p), (v))
template <typename T> inline T emu_atomic_fetch_add(T* p, T v) { const T o = *p; *p = o + v; return o; }
/* The device allocations a unit makes for itself (counter blocks): host memory here. */
inline hipError_t hipMalloc(void** p, size_t n) { *p = std::calloc(n ? n : 1, 1); return *p ? 0 : 2; }
inline hipError_t hipMemsetAsync(void* p, int v, size_t n, hipStream_t) { std::memset(p, v, n); return 0; }
struct alignas(8) uint2 { unsigned x, y; };
struct alignas(16) uint4 { unsigned x, y, z, w; };
struct alignas(16) int4 { int x, y, z, w; };