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.
Python amdapple-siliconcudadeepseekexl3exllamav3glminferencellmllm-inferencelocal-llmnvidiaopenai-apiquantizationqwenrocmstrix-halo
KVWIN: per-sequence attention params (row-invariant multi-job step) keep their own recurrent state; a state/batch mismatch with a bound ring is an error, not a silent skip
YanissAmzdc7f7f15e6d0
diff --git a/exllamav3/cache/kvwin.py b/exllamav3/cache/kvwin.pyindex 2c5c6cd..f4261f9 100644--- a/exllamav3/cache/kvwin.py+++ b/exllamav3/cache/kvwin.py@@ -231,8 +231,11 @@ def make_ctx(cache_layer_state: KVWinLayerState | None, params: dict, device, bsif st is None or not st.active:return Noners = params.get("recurrent_states")- if not rs or len(rs) != bsz or "recurrent_slots" not in params:- return None+ if not rs or "recurrent_slots" not in params:+ return None # plain batched forward without job states: the pool alone+ if len(rs) != bsz:+ # a call that writes the pool without the ring would leave the window stale for the next steps+ raise RuntimeError(f"EXL3_KVWIN: {len(rs)} recurrent states for a batch of {bsz} sequences")from ..util.tensor import get_for_devicereturn KVWinCtx(st, get_for_device(params, "recurrent_slots", device))diff --git a/exllamav3/modules/attn.py b/exllamav3/modules/attn.pyindex 73f54c6..d182090 100644--- a/exllamav3/modules/attn.py+++ b/exllamav3/modules/attn.py@@ -148,6 +148,12 @@ def split_params_by_sequence(params: dict, bsz: int) -> list[dict]:p.pop("dev_cache", None)p["block_table"] = params["block_table"][b:b + 1]p["cache_seqlens"] = params["cache_seqlens"][b:b + 1]+ # the sequence's own recurrent state (and slot): the KVWIN ring of the attention layer lives in it+ rs = params.get("recurrent_states")+ if rs and len(rs) == bsz:+ p["recurrent_states"] = rs[b:b + 1]+ if torch.is_tensor(params.get("recurrent_slots")):+ p["recurrent_slots"] = params["recurrent_slots"][b:b + 1]if positions is not None:p["positions"] = p["cache_seqlens"] if positions is params["cache_seqlens"] else positions[b:b + 1]out.append(p)diff --git a/tests/test_kvwin.py b/tests/test_kvwin.pyindex eb2cf43..5cb00d0 100644--- a/tests/test_kvwin.py+++ b/tests/test_kvwin.py@@ -543,6 +543,24 @@ def test_midchunk_checkpoint_keeps_working_with_a_ring():assert Job.stash_midchunk(fake, {PAGE: {}}, 0) == 0 # still skipped when a GDN layer is missing+def test_per_sequence_params_keep_their_ring_state():+ """The row-invariant multi-job step runs attention per sequence on split params: each keeps its own state / slot."""+ from exllamav3.modules.attn import split_params_by_sequence+ from exllamav3.cache.kvwin import make_ctx+ st = KVWinLayerState(_FakeAttn(), 4, 0, 0)+ st.cfg = parse_spec("4:32"); st.alloc(torch.device(DEV))+ rs = [types.SimpleNamespace(slot = 3), types.SimpleNamespace(slot = 1)]+ params = {"block_table": torch.zeros((2, 4), dtype = torch.int32), "cache_seqlens": torch.tensor([5, 9], dtype = torch.int32),+ "recurrent_states": rs, "recurrent_slots": torch.tensor([3, 1], dtype = torch.int32)}+ parts = split_params_by_sequence(params, 2)+ for b in range(2):+ ctx = make_ctx(st, parts[b], torch.device(DEV), 1)+ assert ctx is not None and int(ctx.slots[0]) == rs[b].slot+ with pytest.raises(RuntimeError): # a state / batch mismatch must not silently skip the ring+ make_ctx(st, params, torch.device(DEV), 1)+ assert make_ctx(st, {}, torch.device(DEV), 2) is None++def test_off_is_bitwise_today():"""EXL3_KVWIN unset: attn_dispatch outputs (prefill / decode / verify rows, 4/6/8 bit) equal the tree before KVWIN bit for bit.KVWIN_BASE_TREE = checkout of the parent commit (default: the sibling worktree wt_empty27)."""