Archived
libr4d: R4D_ATTN_FP8 also for the fp8_v4 and k6_v4 caches
fp8_v4's K is E4M3 already and goes to LDS as raw bytes, as on the fp8 cache. k6_v4's K and the int4 V of both layouts are widened to the value times its group scale (as for the f16 legs) and rounded once to e4m3 at staging. The launcher reads R4D_ATTN_FP8 for all three fp8-family caches. The eight new prefill instantiations spill no registers. Measured with radiance 1.10.0, fp8_v4 KV, otherwise as above (KL against the fp8-KV reference with R4D_ATTN_FP8=0): - R4D_ATTN_FP8=0 with fp8_v4 matches the shipped libr4d (mean KL 0.006713 in both) - 3: mean KL 0.0073, p99.9 0.89, max 5.2, top-1 98.3 % - prompt 200K: 2,609-2,611 -> 3,073-3,091 t/s; 5 x 200K joint prefill 2,403 -> 2,834 t/s; decode unchanged
This commit is contained in:
1 parent
cdc0ae26df
commit
51db508f91
2 files changed
+42
-10
No files matched your search
@@ -57,9 +57,9 @@ static int prefill_launch(const R4DArgs* a, hipStream_t s) {
|
||||
if (a->q_heads / a->kv_heads != A_GQA) return -2;
|
||||
constexpr int BQ = (P_NWARPS * 16) / A_GQA;
|
||||
dim3 grid((a->q_len + BQ - 1) / BQ, a->kv_heads, a->num_seqs);
|
||||
// R4D_ATTN_FP8: 0 = f16 (default), 1 = O_QK8, 2 = O_PV8, 3 = both; fp8 KV without V4/K6 only.
|
||||
// R4D_ATTN_FP8: 0 = f16 (default), 1 = O_QK8, 2 = O_PV8, 3 = both; fp8, fp8_v4 and k6_v4 KV.
|
||||
int fp8mode = 0;
|
||||
if constexpr (KVP == 0 && XOPT == 0) {
|
||||
if constexpr (KVP == 0) {
|
||||
static const int m = [] { const char* e = getenv("R4D_ATTN_FP8"); return e ? atoi(e) : 0; }();
|
||||
fp8mode = m;
|
||||
}
|
||||
@@ -67,10 +67,10 @@ static int prefill_launch(const R4DArgs* a, hipStream_t s) {
|
||||
hipLaunchKernelGGL((r4d_attn_prefill_kernel<P_NWARPS, P_TILE, A_HEAD_DIM, A_GQA, A_BLOCK_SIZE, \
|
||||
KVP, OPTX>), \
|
||||
grid, dim3(P_NWARPS * 32), 0, s, *a)
|
||||
if constexpr (KVP == 0 && XOPT == 0) {
|
||||
if (fp8mode == 3) P_LAUNCH(P_OPT | O_QK8 | O_PV8);
|
||||
else if (fp8mode == 2) P_LAUNCH(P_OPT | O_PV8);
|
||||
else if (fp8mode == 1) P_LAUNCH(P_OPT | O_QK8);
|
||||
if constexpr (KVP == 0) {
|
||||
if (fp8mode == 3) P_LAUNCH(P_OPT | XOPT | O_QK8 | O_PV8);
|
||||
else if (fp8mode == 2) P_LAUNCH(P_OPT | XOPT | O_PV8);
|
||||
else if (fp8mode == 1) P_LAUNCH(P_OPT | XOPT | O_QK8);
|
||||
else P_LAUNCH(P_OPT | XOPT);
|
||||
} else {
|
||||
P_LAUNCH(P_OPT | XOPT);
|
||||
|
||||
Reference in new issue
Block a user