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.

KVWIN: attention modules declare the ring state only when it can be used (ROCm default, or an explicit EXL3_KVWIN): with the CUDA default off the model builds exactly as before KVWIN

YanissAmzabcdde492ca2
diff --git a/exllamav3/cache/kvwin.py b/exllamav3/cache/kvwin.py
index de3651f..89611da 100644
--- a/exllamav3/cache/kvwin.py
+++ b/exllamav3/cache/kvwin.py
@@ -61,9 +61,12 @@ def default_platform() -> bool:
def env_capable() -> bool:
"""Attention modules are built before any cache exists, so they cannot know the cache bits yet: unless the switch
- is off, they declare the ring state (inert until a cache layer binds it, see KVWinLayerState.bind)."""
+ is off (or unset on a backend where the default is off), they declare the ring state (inert until a cache layer
+ binds it, see KVWinLayerState.bind)."""
spec = os.environ.get("EXL3_KVWIN")
- return spec is None or parse_spec(spec) is not None
+ if spec is None:
+ return default_platform() # CUDA, default off: no ring state declared, the model builds exactly as before KVWIN
+ return parse_spec(spec) is not None
def env_cfg(k_bits: int | None = None, v_bits: int | None = None) -> KVWinCfg | None:
diff --git a/tests/test_kvwin.py b/tests/test_kvwin.py
index 7eb374b..e41c36d 100644
--- a/tests/test_kvwin.py
+++ b/tests/test_kvwin.py
@@ -526,12 +526,15 @@ def test_default_is_rocm_only_until_cuda_is_cleared(monkeypatch, env, hip, expec
model = _FakeModel()
Cache(model, 8 * PAGE, layer_type = CacheLayer_quant, max_batch_size = 2, k_bits = 4, v_bits = 4)
assert model.attn.recurrent_layers[0].cfg == (parse_spec(expect) if expect else None)
+ assert kvwin.env_capable() is (hip if env is None else env not in ("0", "off", ""))
@pytest.mark.parametrize("env, capable", [(None, True), ("4:128", True), ("2:64", True), ("0", False), ("off", False), ("", False)])
def test_attention_declares_ring_state_unless_switched_off(monkeypatch, env, capable):
"""Attention modules are built before the cache (and its bits) exist: unless the switch is off they declare the ring state."""
+ from exllamav3.cache import kvwin
from exllamav3.cache.kvwin import env_capable
+ monkeypatch.setattr(kvwin, "default_platform", lambda: True)
if env is None: monkeypatch.delenv("EXL3_KVWIN", raising = False)
else: monkeypatch.setenv("EXL3_KVWIN", env)
assert env_capable() is capable