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.

Merge perf/roofigpu-dqwin (ROCm iGPU levers) into 1.8.4

YanissAmz73abfd039fec
diff --cc exllamav3/modules/attention_fn/qdec_cuda.py
index 5339e74,22b40eb..006be6a
--- a/exllamav3/modules/attention_fn/qdec_cuda.py
+++ b/exllamav3/modules/attention_fn/qdec_cuda.py
@@@ -15,9 -17,8 +17,9 @@@ import trito
_SRC = os.path.join(os.path.dirname(__file__), "cu", "qdec.cu")
_SRC_ROWS = os.path.join(os.path.dirname(__file__), "cu", "qdec_rows.cu") # many-row kernel (verify steps), see qdec_rows.cu
_COMMON = os.path.join(os.path.dirname(__file__), "cu", "qdec_common.cuh")
- ROWS_MODE = os.environ.get("EXL3_QDEC_ROWS", "1") # 0: no many-row kernel, 1: only where qdec.cu cannot, 2: always
+ ROWS_MODE = knob("EXL3_QDEC_ROWS", "1") # 0: no many-row kernel, 1: only where qdec.cu cannot, 2: always
_CACHE = os.path.expanduser(os.environ.get("EXL3_QDEC_CACHE", "~/.cache/exl3_qdec"))
+TQ_QDEC_MAX_NTHD = int(os.environ.get("EXL3_QDEC_TQ_NTHD", "384")) # TurboQuant: largest row tiles x head dim qdec.cu takes without spilling
_kernels = {}
@@@ -175,9 -178,9 +182,9 @@@ def pick_nw_st(cfg)
c = dict(cfg)
if cfg.get("rows_kernel"):
c.update(nw=rows_nw(cfg["hd"]))
- for st in ((int(os.environ["EXL3_QDEC_RST"]),) if os.environ.get("EXL3_QDEC_RST") else (3, 2, 1)):
+ for st in ((int(knob("EXL3_QDEC_RST")),) if knob("EXL3_QDEC_RST") else (3, 2, 1)):
c.update(st=st)
- if geometry(c)["shared"] <= 99 * 1024:
+ if geometry(c)["shared"] <= 99 * 1024 - static_smem(c):
return c["nw"], st
raise QdecUnsupported("no ring configuration fits")
narrow = cfg["hd"] == 128 and cfg["kb"] + cfg["vb"] <= 8
diff --cc exllamav3/modules/attn.py
index 7368841,220098e..8ca1758
--- a/exllamav3/modules/attn.py
+++ b/exllamav3/modules/attn.py
@@@ -1400,19 -1397,9 +1403,19 @@@ class Attention(Module)
cs_host = params.get("cache_seqlens")
if isinstance(cs_host, torch.Tensor) and cs_host.device.type == "cpu" and cs_host.numel():
max_kv_len = int(cs_host.max())
+ # TurboQuant cache: the many-row kernel (cu/qdec_rows.cu) serves every row count 1..32 as one program per kv
+ # head (verified against the dequantized reference, relerr 0.7-1.9e-3), so the R verify rows run as ONE batched
+ # call like the quantized cache does through the BC graph path. The per-row loop below is a bitwise
+ # row-invariance device and costs R x the attention time (128K MTP verify: 49.3 ms/step of 98.0 vs 12.0 of
+ # 59.0 for the quant cache). EXL3_TQ_VERIFY_LOOP=1 keeps the loop.
+ tq_batch = False
+ if 1 < seqlen <= MAX_BSZN_GEMV_R and ov is None and os.environ.get("EXL3_TQ_VERIFY_LOOP", "0") == "0":
+ from ..cache import CacheLayer as _CLv
+ _lyr = cache if isinstance(cache, _CLv) else cache.layers[self.layer_idx, params.get("layer_instance") or 0]
+ tq_batch = bool(getattr(_lyr, "tq", False))
if (
- 1 < seqlen <= MAX_BSZN_GEMV_R and non_causal_spans is None and
+ 1 < seqlen <= MAX_BSZN_GEMV_R and non_causal_spans is None and not tq_batch and
- os.environ.get("EXL3_VERIFY_ATTN_LOOP", "0") != "0"
+ knobs.knob_on("EXL3_VERIFY_ATTN_LOOP", "0")
):
# Row-invariant verify: the R-row paged decode tiles the KV span from the batch's single
# cache_seqlens/q_len, a different float order than R batch-1 calls. Run the exact
diff --cc tools/depth/depth_profile.py
index d704423,5ca474c..16a8fc2
--- a/tools/depth/depth_profile.py
+++ b/tools/depth/depth_profile.py
@@@ -92,10 -121,7 +122,10 @@@ def _main()
config = Config.from_directory(args.model)
model = Model.from_config(config)
qkw = dict(layer_type=CacheLayer_quant, k_bits=args.cache_bits, v_bits=args.cache_bits) if args.cache_bits < 16 else {}
+ if args.kv_mode == "tq" and args.cache_bits < 16:
+ from exllamav3.cache.tq import CacheLayer_tq
+ qkw["layer_type"] = CacheLayer_tq
- cache = Cache(model, max_num_tokens=cap, max_history=max(3, R), max_batch_size=1, **qkw)
+ cache = Cache(model, max_num_tokens=cap, max_history=max(3, Rmax), max_batch_size=1, **qkw)
model.load(device="cuda:0", progressbar=False)
RES["load_s"] = round(time.time() - t0, 1)
RES["avail_after_load_gb"] = round(avail_gb(), 1)