Skip to content

Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.

GDN-HF / KDA-HF: forward substitution with the column held in registers

YanissAmz0f328669997a
diff --git a/exllamav3/vendor/fla/hip/gdn_hf.hip b/exllamav3/vendor/fla/hip/gdn_hf.hip
index 737a6b2..96345c6 100644
--- a/exllamav3/vendor/fla/hip/gdn_hf.hip
+++ b/exllamav3/vendor/fla/hip/gdn_hf.hip
@@ -219,13 +219,15 @@ extern "C" __global__ void gated_delta_chunk_gate_wmma(
#pragma unroll
for (int r = 0; r < 8; ++r) lf_s[2 * r + hi][l16] = P[r];
GC_WAVE_SYNC();
- if (hi == 0) { // in place, lane l16 = column c: lf_s[i][c] <- T[i][c] = (i == c) + sum_{j < i} L[i][j] T[j][c]
- // (row i of L is read before it is overwritten; T[j][c] is this lane's own earlier store)
-#pragma unroll 1
- for (int i = 0; i < 16; ++i) { // rolled: unrolled, the 120 LDS loads are hoisted into VGPRs (occupancy 6 -> 5)
+ if (hi == 0) { // lane l16 = column c: T[i][c] = (i == c) + sum_{j < i} L[i][j] T[j][c], column c held in registers
+ float tc[16]; // (same fmaf order as a rolled loop over an in-place LDS tile: bitwise the same T)
+#pragma unroll
+ for (int i = 0; i < 16; ++i) {
float a = i == l16 ? 1.f : 0.f;
- for (int j = 0; j < i; ++j) a = fmaf(lf_s[i][j], lf_s[j][l16], a);
- lf_s[i][l16] = a;
+#pragma unroll
+ for (int j = 0; j < i; ++j) a = fmaf(lf_s[i][j], tc[j], a);
+ asm volatile("" : "+v"(a)); // a materialized in fp32: no fma -> f16 fusion (v_fma_mix) at the store
+ tc[i] = a;
t_s[i][l16] = (_Float16)a;
}
}
diff --git a/exllamav3/vendor/fla/hip/kda_hf.hip b/exllamav3/vendor/fla/hip/kda_hf.hip
index 71ac986..a6182c6 100644
--- a/exllamav3/vendor/fla/hip/kda_hf.hip
+++ b/exllamav3/vendor/fla/hip/kda_hf.hip
@@ -209,13 +209,15 @@ extern "C" __global__ void kda_chunk16_wmma(
#pragma unroll
for (int r = 0; r < 8; ++r) lf_s[2 * r + hi][l16] = P[r];
GC_WAVE_SYNC();
- if (hi == 0) { // in place, lane l16 = column c: lf_s[i][c] <- T[i][c] = (i == c) + sum_{j < i} L[i][j] T[j][c]
- // (row i of L is read before it is overwritten; T[j][c] is this lane's own earlier store)
-#pragma unroll 1
- for (int i = 0; i < 16; ++i) { // rolled: unrolled, the 120 LDS loads are hoisted into VGPRs (occupancy 6 -> 5)
+ if (hi == 0) { // lane l16 = column c: T[i][c] = (i == c) + sum_{j < i} L[i][j] T[j][c], column c held in registers
+ float tc[16]; // (same fmaf order as a rolled loop over an in-place LDS tile: bitwise the same T)
+#pragma unroll
+ for (int i = 0; i < 16; ++i) {
float a = i == l16 ? 1.f : 0.f;
- for (int j = 0; j < i; ++j) a = fmaf(lf_s[i][j], lf_s[j][l16], a);
- lf_s[i][l16] = a;
+#pragma unroll
+ for (int j = 0; j < i; ++j) a = fmaf(lf_s[i][j], tc[j], a);
+ asm volatile("" : "+v"(a)); // a materialized in fp32: no fma -> f16 fusion (v_fma_mix) at the store
+ tc[i] = a;
t_s[i][l16] = (_Float16)a;
}
}