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 branch 'perf/pfattn-hip' into release/1.8-wip

YanissAmz7afd3addccc6
diff --cc exllamav3/modules/attention_fn/triton_paged.py
index 35543be,414b83d..e5badf2
--- a/exllamav3/modules/attention_fn/triton_paged.py
+++ b/exllamav3/modules/attention_fn/triton_paged.py
@@@ -709,13 -709,12 +709,19 @@@ _qc_prefill_two_pass_min_q = int(os.env
# EXL3_PF_FA2=0 restores the Triton kernel
_pf_fa2 = os.environ.get("EXL3_PF_FA2", "1") == "1" and torch.version.hip is None
+# The chunk runs as sub-calls of this many query rows (each over the keys up to its own last row, same bottom-right causal
+# mask, so every row sees the same keys in the same order; whole 1024-row sub-calls match one call bit for bit, a short
+# remainder may take FA2's split-kv schedule and differ in the last bits). One FA2 call over a
+# 4096-row chunk with a long past reaches 73-78 TFLOPS on an RTX 3090, 1024-row sub-calls 92 (2048: 87, 512: 81, 256: 84).
+# 0 = one call
+_pf_fa2_rows = int(os.environ.get("EXL3_PF_FA2_ROWS", "1024"))
+
+ # Query rows per slice of the prefill grid (single-split launches): the programs run slice by slice, each slice's rows over all heads
+ # before the next slice's. 0 = one wide q-block axis (the order before this knob). Same math per program, so bit-identical output.
+ # gfx1151, Qwen3.8-27B geometry (24 q / 4 kv heads, hd 256, 4096-row chunk): 1.26x at 4K past, 1.8x at 32K, 2.2x at 120K (the wide axis
+ # runs 10 TFLOPS at 120K, 256-row slices 21). Default on for ROCm only (CUDA not measured)
+ _pf_row_slice = int(os.environ.get("EXL3_PF_ROW_SLICE", "256" if torch.version.hip else "0"))
+
def _prefill_fa2_contig(q, kd, vd, past, n_kvh, head_dim, scale, out):
from torch.nn.attention import sdpa_kernel, SDPBackend
from torch.nn.attention.bias import causal_lower_right