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.

nc2 S6: 4-slot mode-2 KDA checkpoints (EXL3_NC2_CKPT4) so an 8K prompt runs as one 8192-row chunk

Yaniss71511fbac74a
diff --git a/exllamav3/generator/job.py b/exllamav3/generator/job.py
index 7149bfb..d09e56f 100644
--- a/exllamav3/generator/job.py
+++ b/exllamav3/generator/job.py
@@ -1288,8 +1288,11 @@ class Job:
p for p in range((seq.kv_position // PAGE_SIZE + 1) * PAGE_SIZE, seq.kv_position + chunk, PAGE_SIZE)
if self.is_checkpoint_boundary(pos = p)
]
- if len(interior) > 1:
- chunk = interior[1] - seq.kv_position
+ # EXL3_NC2_CKPT4: the CK4 kernel build side-writes up to 4 rows = 3 interior boundaries + the last full
+ # page (EXL3_PF_NO_TAIL), so an 8K prompt under EXL3_PREFILL_BIG_CHUNK=8192 runs as one chunk
+ keep = 3 if os.environ.get("EXL3_NC2_CKPT4", "0") == "1" else 1
+ if len(interior) > keep:
+ chunk = interior[keep] - seq.kv_position
elif big > chunk and big % chunk == 0 and remaining > big + chunk:
chunk = big
prefill_end = seq.kv_position + chunk
diff --git a/exllamav3/modules/gated_delta_net.py b/exllamav3/modules/gated_delta_net.py
index 6d9ddf4..e182db0 100644
--- a/exllamav3/modules/gated_delta_net.py
+++ b/exllamav3/modules/gated_delta_net.py
@@ -1317,6 +1317,8 @@ class GatedDeltaNet(Module):
cdim = self.conv_kernel_size
# EXL3_PF_NO_TAIL=1: the job also asks for the prompt's last full page, so up to 2 rows (kernel side-writes 2)
max_rows = 2 if os.environ.get("EXL3_PF_NO_TAIL", "0") == "1" else 1
+ if self.kda and os.environ.get("EXL3_NC2_CKPT4", "0") == "1":
+ max_rows = 4 # CK4 kernel build (vendor/fla/hip/kda_fused_h_hip.py): 8192-row chunks
if len(rows) > max_rows or any(r % 64 or not cdim <= r < seqlen for r in rows):
return None
cks = [{
diff --git a/exllamav3/vendor/fla/hip/kda_fused_h.hip b/exllamav3/vendor/fla/hip/kda_fused_h.hip
index cbfbda9..7b35a27 100644
--- a/exllamav3/vendor/fla/hip/kda_fused_h.hip
+++ b/exllamav3/vendor/fla/hip/kda_fused_h.hip
@@ -156,12 +156,20 @@ __device__ uint32_t kda_prof[4096 * 9];
#define PFW 0 // 1..4: a 9th wave touches chunk c+1's rows (L2 / MALL prefetch) after barrier PFW of chunk c
#endif
+#ifndef CK4
+#define CK4 0
+#endif
+
extern "C" __global__ __launch_bounds__(PFW ? 288 : 256) void kda_fused_h_o(
const uint16_t* __restrict__ q, const uint16_t* __restrict__ k, const uint16_t* __restrict__ v,
const float* __restrict__ gk, const uint16_t* __restrict__ beta, const uint16_t* __restrict__ Akk,
const uint16_t* __restrict__ Aqk, uint16_t* __restrict__ o, const float* __restrict__ h0,
float* __restrict__ ht, float scale, int T, int H, int HV, float* __restrict__ hc, int ckpt_chunk,
- float* __restrict__ hc2, int ckpt_chunk2)
+ float* __restrict__ hc2, int ckpt_chunk2
+#if CK4
+ , float* __restrict__ hc3, int ckpt_chunk3, float* __restrict__ hc4, int ckpt_chunk4
+#endif
+ )
{
__shared__ __attribute__((aligned(16))) uint16_t sW[BT * LDR]; // w [token][kdim]
__shared__ __attribute__((aligned(16))) uint16_t sX[KD * LDT]; // kb^T [kdim][token], then qg [token][kdim]
@@ -579,6 +587,21 @@ extern "C" __global__ __launch_bounds__(PFW ? 288 : 256) void kda_fused_h_o(
#pragma unroll
for (int r = 0; r < 8; ++r)
hc2[(int64_t) i_nh * KD * VD + (16 * kt + 2 * r + half) * VD + col] = h[kt][r];
+#if CK4
+ // third and fourth checkpoints (EXL3_NC2_CKPT4: 8192-row chunks), same store as above
+ if (hc3 && i_t + 1 == ckpt_chunk3)
+ #pragma unroll
+ for (int kt = 0; kt < 8; ++kt)
+ #pragma unroll
+ for (int r = 0; r < 8; ++r)
+ hc3[(int64_t) i_nh * KD * VD + (16 * kt + 2 * r + half) * VD + col] = h[kt][r];
+ if (hc4 && i_t + 1 == ckpt_chunk4)
+ #pragma unroll
+ for (int kt = 0; kt < 8; ++kt)
+ #pragma unroll
+ for (int r = 0; r < 8; ++r)
+ hc4[(int64_t) i_nh * KD * VD + (16 * kt + 2 * r + half) * VD + col] = h[kt][r];
+#endif
}
#if PROF
diff --git a/exllamav3/vendor/fla/hip/kda_fused_h_hip.py b/exllamav3/vendor/fla/hip/kda_fused_h_hip.py
index 4bcedcb..4b1c8e1 100644
--- a/exllamav3/vendor/fla/hip/kda_fused_h_hip.py
+++ b/exllamav3/vendor/fla/hip/kda_fused_h_hip.py
@@ -75,6 +75,13 @@ def chunk_kda_fwd_h_fused_hip(q, k, v, gk, beta, Akk, Aqk, scale, initial_state=
# default off. Name kept per brief; the 2-WG split (lever a) was ruled NO-GO by
# construction (w/tril/vn couple all halves).
defs = "BRL=1 UNI=1"
+ # ckpt: one dict or a list of up to 2 (EXL3_PF_NO_TAIL adds the prompt's last full page); up to 4 with the CK4 build
+ # (EXL3_NC2_CKPT4: an 8192-row chunk carries 3 interior checkpoints + the last full page)
+ cks = [] if ckpt is None else (list(ckpt) if isinstance(ckpt, (list, tuple)) else [ckpt])
+ nslot = 4 if len(cks) > 2 else 2
+ assert len(cks) <= nslot
+ if nslot == 4:
+ defs = (defs + " CK4=1").strip()
fn = _load(defs)
if o is None:
o = torch.empty_like(v)
@@ -88,13 +95,10 @@ def chunk_kda_fwd_h_fused_hip(q, k, v, gk, beta, Akk, Aqk, scale, initial_state=
P(Akk.data_ptr()), P(Aqk.data_ptr()), P(o.data_ptr()), P(0 if h0 is None else h0.data_ptr()),
P(final_state.data_ptr() if output_final_state else 0), ctypes.c_float(scale), ctypes.c_int(T),
ctypes.c_int(H), ctypes.c_int(HV)]
- # ckpt: one dict or a list of up to 2 (EXL3_PF_NO_TAIL adds the prompt's last full page)
- cks = [] if ckpt is None else (list(ckpt) if isinstance(ckpt, (list, tuple)) else [ckpt])
- assert len(cks) <= 2
cks = [c for c in cks if 0 < c["chunk"] <= (T + 63) // 64]
for c in cks:
assert c["s"].dtype == torch.float32 and c["s"].is_contiguous() and c["s"].shape == (B, HV, K, V)
- for i in range(2):
+ for i in range(nslot):
c = cks[i] if i < len(cks) else None
args += [P(0 if c is None else c["s"].data_ptr()), ctypes.c_int(-1 if c is None else c["chunk"])]
params = (ctypes.c_void_p * len(args))(*[ctypes.cast(ctypes.byref(a), ctypes.c_void_p) for a in args])