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.

Qwen: keep o_proj's fp16 output in attention / GDN blocks by default

YanissAmz983be412872d
diff --git a/exllamav3/modules/attn.py b/exllamav3/modules/attn.py
index 7744659..b41c67b 100644
--- a/exllamav3/modules/attn.py
+++ b/exllamav3/modules/attn.py
@@ -664,6 +664,11 @@ class Attention(Module):
if x is None:
return None # kv_only, see decode_flash_attn
+ # EXL3_NC2_ATTN_F16 (default off): the block asked for fp16 y (pfe_y_half) and o_proj returned it; keep it
+ # instead of the fp32 widen to self.out_dtype (the residual apply / ablit project_widen widen in-kernel)
+ if out_dtype is None and x.dtype == torch.half and params.get("pfe_y_half") and \
+ os.environ.get("EXL3_NC2_ATTN_F16", "0") == "1":
+ return x
return to2(x, out_dtype, self.out_dtype)
diff --git a/tools/qwen/serve.py b/tools/qwen/serve.py
index 1bf0500..165b14b 100644
--- a/tools/qwen/serve.py
+++ b/tools/qwen/serve.py
@@ -566,6 +566,9 @@ SERVE_ENV = (("EXL3_HOST_LEAN", "1"), ("EXL3_HOST_CUTS", "1"), # batched verif
("EXL3_MOE_FUSED", "1"), ("EXL3_MOE_VALU", "1"), ("EXL3_VERIFY_ATTN_LOOP", "1"),
("EXL3_VERIFY_GEMV_R", "1"), ("EXL3_GEMV_R_DEC1", "1"), ("EXL3_MTP_FUSE_CATCHUP", "0"),
("EXL3_PLE_HIP", "1"), ("EXL3_DQ_HIP", "1"), ("EXL3_GR_HIP", "1"), ("EXL3_GDN_FUSE", "1"), ("EXL3_PF_SKIP", "1"),
+ # the attention / GDN blocks keep o_proj's fp16 output (the residual apply widens in-kernel) and the ablit projection
+ # reads the fp16 x directly, as on GLM: bit-identical, one-load A/B 6/6 + 6/6 + 6/6 logits equal.
+ ("EXL3_NC2_ATTN_F16", "1"), ("EXL3_NC2_ABLIT_F16", "1"),
# 4096-row prefill chunks (one MoE pass per 4096 rows, no 2048 + 2048 + tail split below 4097 tokens) and the
# draft prefill run chunk by chunk with the target prefill (K/V and indexer planes only). EXL3_PF_DEFER=1 defers it behind the
# first token instead; that lands the whole draft prefill (2.4 s at 256K) inside the first decode steps. 0 for either goes back.