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
Comments: describe the code instead of internal experiment labels
YanissAmzf5c3d4b32258
diff --git a/exllamav3/architecture/glm5_next_mtp.py b/exllamav3/architecture/glm5_next_mtp.pyindex bacc922..8dd848a 100644--- a/exllamav3/architecture/glm5_next_mtp.py+++ b/exllamav3/architecture/glm5_next_mtp.py@@ -236,8 +236,8 @@ class Glm5NextMTPModel(Model):unquantized weight from a sidecar file (key "<prefix>.layers.<n>.eh_proj.weight",[out, in] = [H, 2H], bf16/fp16, e.g. from the HF checkpoint viatools/glm/mtp_eh_sidecar.py). td205 stores eh_proj at mtp_bits = 2; on real MTP inputs- its output has cos ~0.78 vs the bf16 weight, which costs ~0.1 of draft acceptance- (acceptaudit2). The fp16 weight is 64 MiB, read once per draft forward.+ its output has cos ~0.78 vs the bf16 weight, which costs ~0.1 of draft acceptance.+ The fp16 weight is 64 MiB, read once per draft forward."""path = path if path is not None else os.getenv("EXL3_MTP_EH_FP16", "")if not path or path == "0":diff --git a/exllamav3/exllamav3_ext/hc_mix.cu b/exllamav3/exllamav3_ext/hc_mix.cuindex c893707..f89bebd 100644--- a/exllamav3/exllamav3_ext/hc_mix.cu+++ b/exllamav3/exllamav3_ext/hc_mix.cu@@ -581,7 +581,7 @@ void hc_mix_norm_1pass_kernel/*-hc_pf_apply_mix_norm_1pass (pffuse1, GLM prefill, EXL3_PF_HC_FUSE): residual apply of site A+hc_pf_apply_mix_norm_1pass (GLM prefill, EXL3_PF_HC_FUSE): residual apply of site Afused with the hc_mix_norm_1pass of the NEXT site B. The (R, H, D) stream stack is writtenonce (by the apply) and read once from HBM (by the finalize); the partials phase re-readsthe just-written row L2-hot.@@ -1838,7 +1838,7 @@ void hc_applycuda_check(cudaPeekAtLastError());}-// Prefill apply+mix_norm fusion (pffuse1, EXL3_PF_HC_FUSE): site-A hc_apply with comb+// Prefill apply+mix_norm fusion (EXL3_PF_HC_FUSE): site-A hc_apply with comb// followed by the site-B hc_mix_norm_1pass, one launch. Single-chunk regime only// (grid (1, R)); the caller sizes partials (R, 1, M + 1).void hc_pf_apply_mix_normdiff --git a/exllamav3/exllamav3_ext/hc_mix.cuh b/exllamav3/exllamav3_ext/hc_mix.cuhindex 172478a..bbc8663 100644--- a/exllamav3/exllamav3_ext/hc_mix.cuh+++ b/exllamav3/exllamav3_ext/hc_mix.cuh@@ -64,7 +64,7 @@ void hc_applyconst c10::optional<at::Tensor>& comb);-// Prefill apply+mix_norm fusion (pffuse1, EXL3_PF_HC_FUSE, default off)+// Prefill apply+mix_norm fusion (EXL3_PF_HC_FUSE, default off)void hc_pf_apply_mix_norm(at::Tensor x,diff --git a/exllamav3/exllamav3_ext/quant/exl3_dec.cu b/exllamav3/exllamav3_ext/quant/exl3_dec.cuindex bf06d26..623ce7c 100644--- a/exllamav3/exllamav3_ext/quant/exl3_dec.cu+++ b/exllamav3/exllamav3_ext/quant/exl3_dec.cu@@ -286,7 +286,7 @@ __device__ __forceinline__ void tile_dot(const uint32_t* w, const f16x2* xp, flo#endif}-// verifyrow1 (EXL3_GEMV_R_DEC1): R-row twin of pair_dot/tile_dot. Each weight pair is decoded ONCE+// (EXL3_GEMV_R_DEC1): R-row twin of pair_dot/tile_dot. Each weight pair is decoded ONCE// and applied to every row (tile_dot per row re-decodes the whole tile per row, which made each// extra verify row cost ~7 % of the dense gemv time in pure ALU). Per row, the fdot2 operands, the// accumulator and the order of accumulation are exactly tile_dot's, so the output is bit-identical.@@ -402,13 +402,13 @@ __device__ __forceinline__ void lane_gemv(const u32x4* tiles, size_t tstride, co}}-// R-row variant (REPORT-16): each tile is loaded once (identical RING pipeline to lane_gemv), then+// R-row variant: each tile is loaded once (identical RING pipeline to lane_gemv), then// applied to `nrows` independent input rows in the exact same per-row tile_dot/pair_dot arithmetic// lane_gemv would run for a batch-1 call on that row -- so row j of acc is bit-identical to what a// batch-1 lane_gemv(..., xs_rows[j], n, acc_row_j) call would produce. xp is scoped inside the row// loop (not hoisted per-row), so only one row's 8 xp registers are live at a time; acc[MOE_R_MAX][16]// (only the first `nrows` rows used) is the only cost that scales with rows.-// RM (REPORT-28): compile-time row bound. The row loop used to run to the runtime nrows, which+// RM: compile-time row bound. The row loop used to run to the runtime nrows, which// indexes acc[j] dynamically and pushes the whole accumulator array to scratch memory; unrolled to// RM with a uniform `j < nrows` guard, acc stays in VGPRs. Arithmetic per row is unchanged.// RING_ (default ring_of<KB2>) only sets how many tiles are in flight; the per-tile arithmetic and@@ -445,7 +445,7 @@ __device__ __forceinline__ void lane_gemv_r(const u32x4* tiles, size_t tstride,}}-// verifyrow1: lane_gemv_r with the decode shared across rows (pair_dot_r). Same ring, same loads.+// lane_gemv_r with the decode shared across rows (pair_dot_r). Same ring, same loads.template <int KB2, int CB, int RM, int RING_ = 0>__device__ __forceinline__ void lane_gemv_r1(const u32x4* tiles, size_t tstride, const half* const* xs_rows, int n, float acc[][16]){@@ -1027,7 +1027,7 @@ void moe_down_kernel(MoeArgs a, int kbs)// -------------------------------------------------------------------------------------------------// R-row union MoE (REPORT-16): verify-window MoE, R<=8 rows sharing one launch. Each *unique*+// R-row union MoE: verify-window MoE, R<=8 rows sharing one launch. Each *unique*// expert across the R rows' top-k selections is decoded exactly once (grid.y = unique-expert// index u, not row) and its lane_gemv accumulation is run once per row assigned to it, in the// exact per-lane arithmetic order (tile_dot/pair_dot, same acc[16] sequence) a batch-1@@ -1314,7 +1314,7 @@ void moe_down_kernel_r(MoeArgsR a, int kbs, int ctr_b_off)}}-// Device-side unique-expert / assignment table for the R-row union MoE (REPORT-28): no host sync.+// Device-side unique-expert / assignment table for the R-row union MoE: no host sync.// Generic in E, topk (<= 64) and R (<= MOE_R_MAX). Slot i = row * topk + k. A slot "leads" when no// earlier slot selected the same expert; leader i gets u = number of leaders before it, and// assign[u * MOE_R_MAX + c] lists every slot with that expert in slot order (same as the host build).@@ -2235,7 +2235,7 @@ void exl3_dec_gemv_strided}// -------------------------------------------------------------------------------------------------// R-row dense GEMV (REPORT-17): each weight tile is decoded once (identical RING pipeline to+// R-row dense GEMV: each weight tile is decoded once (identical RING pipeline to// batch-1's gemv_kernel) and applied to up to `rpb` rows via lane_gemv_r, in the exact per-row// arithmetic order (tile_dot/pair_dot/block_reduce/arrive) a batch-1 exl3_dec_gemv call would// use for that row -- so row j's output is bit-identical to a fresh batch-1 call, PROVIDED ktw@@ -2435,7 +2435,7 @@ static void dec_gemv_r_implint rpb = std::max(1, std::min(R, GEMV_R_ROW_BUDGET / ktw));const int rpb_cap = env_int("EXL3_GEMV_R_RPB", 0);if (rpb_cap > 0) rpb = std::min(rpb, rpb_cap);- // mimoident2 (MiMo, R 5..8 verify, bitwise independent of rpb): the 8-row kernel variant wins at R 5-6+ // (MiMo, R 5..8 verify, bitwise independent of rpb): the 8-row kernel variant wins at R 5-6// but loses at R 7-8 (131 vs 123 ms per verify forward, spills); from R 7 on run two 4-row chunks (grid.y = 2).else if (R >= 7 && rpb > 4 && env_int("EXL3_GEMV_R_RPB78", 4) > 0) rpb = env_int("EXL3_GEMV_R_RPB78", 4);@@ -2478,7 +2478,7 @@ static void dec_gemv_r_implconst dim3 grid(blocks, (R + rpb - 1) / rpb);EXL3_DEC_DISPATCH_CB(mcg ? 1 : 2, EXL3_DEC_DISPATCH_RM(rpb, EXL3_DEC_DISPATCH_KB2(kb2,{- // verifyrow1: EXL3_GEMV_R_DEC1=1 decodes each tile once for all rows (bit-identical)+ // EXL3_GEMV_R_DEC1=1 decodes each tile once for all rows (bit-identical)if (RM > 1 && env_int("EXL3_GEMV_R_DEC1", 0) == 1){ auto kfn = gemv_kernel_r<KB2, CB, RM, true>; kfn<<<grid, THREADS, 0, stream>>>(xp, jobs, sp, cp); }else@@ -2714,7 +2714,7 @@ void exl3_dec_moe_sharedcuda_check(cudaPeekAtLastError());}-// R-row union MoE, REPORT-16. See the comment above MoeArgsR. Builds the unique-expert /+// R-row union MoE. See the comment above MoeArgsR. Builds the unique-expert /// assignment table on the host (R * topk <= 80 entries, negligible next to the GEMVs) and runs// gu + down + combine. x: [R, H] fp16, out: [R, H] fp32, selected/weights: [R, topk].void exl3_dec_moe_union@@ -2794,7 +2794,7 @@ void exl3_dec_moe_union}else{- // REPORT-28: table built on device, grid.y = max possible U, padded slots exit at once+ // Table built on device, grid.y = max possible U, padded slots exit at onceconst int64_t experts_d = experts;TORCH_CHECK(topk <= 64, "exl3_dec_moe_union: device table needs topk <= 64");U = (int) std::min<int64_t>((int64_t) R * topk, experts_d);diff --git a/exllamav3/exllamav3_ext/quant/exl3_dec.cuh b/exllamav3/exllamav3_ext/quant/exl3_dec.cuhindex 1cc3b8f..b7b5952 100644--- a/exllamav3/exllamav3_ext/quant/exl3_dec.cuh+++ b/exllamav3/exllamav3_ext/quant/exl3_dec.cuh@@ -9,7 +9,7 @@// a 512-column strip, so one launch covers what the generic path does in three.//// K (bits per weight) in {2, 2.5, 3, 4, 5, 6}. `mcg` selects the codebook for all matrices of a-// launch (uniform per layer): false = mul1, true = mcg (GLM-5.3-Flash packs, see REPORT-22).+// launch (uniform per layer): false = mul1, true = mcg (GLM-5.3-Flash packs).// The two templates decode bit-identically to their codebook's reference decode; only the// summation order differs from the reconstruct+hgemm path.@@ -62,7 +62,7 @@ void exl3_dec_gemv_multibool mcg = false);-// R-row dense GEMV (REPORT-17): y[R, N] = x[R, K] @ W, one launch, each weight tile decoded once+// R-row dense GEMV: y[R, N] = x[R, K] @ W, one launch, each weight tile decoded once// and applied to every row -- bit-exact vs R independent exl3_dec_gemv calls PROVIDED the caller// doesn't touch EXL3_DEC_KTW/EXL3_DEC_MIN_BLOCKS/EXL3_DEC_KBS differently between the two (same// pick_ktw/kbs_of call as batch-1). x must be contiguous [R, K]; no strided (x_gstride) form yet.@@ -165,7 +165,7 @@ void exl3_dec_moe_sharedbool mcg);-// R-row union MoE (REPORT-16), R<=8: x [R,H] fp16, out [R,H] fp32, selected/weights [R,topk].+// R-row union MoE, R<=8: x [R,H] fp16, out [R,H] fp32, selected/weights [R,topk].// Each unique expert across the R rows' selections is decoded once and applied to every row that// picked it, in the exact batch-1 exl3_dec_moe per-lane arithmetic order (row r bit-identical to// a fresh batch-1 call). act: fp16 [R*topk, I], down_part: fp32 [R*topk, H] workspaces.diff --git a/exllamav3/exllamav3_ext/quant/quantize.cu b/exllamav3/exllamav3_ext/quant/quantize.cuindex c519baa..82a19c6 100644--- a/exllamav3/exllamav3_ext/quant/quantize.cu+++ b/exllamav3/exllamav3_ext/quant/quantize.cu@@ -137,8 +137,8 @@ enum { QT_BASE = 0, QT_OPTIMIZED = 1, QT_RDNA = 2 };// falls back to base where it has no instance); EXL3_QT_OPTIMIZED=1/0 keeps its old meaning.// On ROCm the grouped kernel is the default for K = 2..3, the dense specialization for K = 4..5.// All are measured bit-identical to the base kernel on gfx1151. K = 4 routes to dense because the-// grouped kernel only matches base there while dense is ~2.5-3x base (REPORT-10; K = 2..3 and-// K = 5 measured in REPORT-09/REPORT-10).+// grouped kernel only matches base there while dense is ~2.5-3x base (measured for K = 2..3+// and K = 5 as well).static int quantize_tiles_mode(int major, int minor, int K, int cb, int L){if (const char* env = std::getenv("EXL3_QT_KERNEL"))diff --git a/exllamav3/generator/generator.py b/exllamav3/generator/generator.pyindex 05f52cd..cd8377e 100644--- a/exllamav3/generator/generator.py+++ b/exllamav3/generator/generator.py@@ -230,7 +230,7 @@ class Generator:self.ngram_match_min = ngram_match_minself.dynamic_draft = dynamic_draft_tokens and self.num_draft_tokens > 0self.record_draft_stats = record_draft_stats- # REPORT-28 cost-model gate: skip the drafter forward (and the R-row verify) whenever the+ # cost-model gate: skip the drafter forward (and the R-row verify) whenever the# measured speculative rate would not beat plain decode. Opt-in: EXL3_SPEC_GATE=1self.spec_gate = SpecGate() if (draft_model is not None andos.environ.get("EXL3_SPEC_GATE", "0") != "0") else None@@ -1287,7 +1287,7 @@ class Generator:"positions": positions,"recurrent_history": draft_tokens is not None,"pinned_staging": True,- # REPORT-17: marks a real DFlash verify forward (R rows, target model), as opposed to+ # marks a real DFlash verify forward (R rows, target model), as opposed to# any other multi-row call with rows in the same 2..MAX_BSZN range -- prefill routes# 2-8 tokens to plenty of individual MoE experts, and the draft model's own forward# has draft_tokens is None too. The four R-row fast paths (block_sparse_mlp.py's MoE@@ -1977,7 +1977,7 @@ def _pt():class SpecGate:"""- Cost-model gate for speculative decoding (REPORT-28). Keeps EMAs of the plain step time, the+ Cost-model gate for speculative decoding. Keeps EMAs of the plain step time, thespeculative round time and the tokens a round yields, and speculates only whiletokens_per_round / t_round >= 1 / t_plain. In plain mode it probes one speculative round after`probe` plain steps; a failed probe doubles the interval (up to probe_max), a successful onediff --git a/exllamav3/modules/attention_fn/dsa_triton.py b/exllamav3/modules/attention_fn/dsa_triton.pyindex bd77923..5f175cc 100644--- a/exllamav3/modules/attention_fn/dsa_triton.py+++ b/exllamav3/modules/attention_fn/dsa_triton.py@@ -37,7 +37,7 @@ from ...util.tensor import g_tensor_cache# compile in debug mode, so force TRITON_DEBUG before any compilationdsa_debug_bounds = os.environ.get("EXL3_DSA_DEBUG_BOUNDS", "0") != "0"-# dsaglue1: gates only. dsa_glue_expand additionally runs the eager chain and raises on any+# gates only. dsa_glue_expand additionally runs the eager chain and raises on any# bitwise mismatch. Read once (it sits on the per-layer decode path).dsa_glue_check = os.environ.get("EXL3_DSA_GLUE_CHECK", "0") == "1"@@ -851,7 +851,7 @@ def _dsa_attn_split_fast_kernel(PIPE: tl.constexpr = 0, # issue the next tile's index -> page -> row chain earlyQK_DYN: tl.constexpr = 1,):- """decattn2 (EXL3_DEC_DSA_FAST): _dsa_attn_split_dt_kernel with a shorter dependent-load+ """EXL3_DEC_DSA_FAST: _dsa_attn_split_dt_kernel with a shorter dependent-loadchain. REBAL: every program first reads the row's whole index vector (one K_pad-wide load)and splits [0, last valid + 1) instead of k_len: at 4K the selection holds 1024 validentries of 2048, so each program walks half the tiles. Exact for any -1 pattern (a@@ -1471,7 +1471,7 @@ def dsa_attn(est = (win_len if has_window else 0) + \(k_len if indices is not dummy_i else min(pool_len, (q_pos0 + R) // max(compress_rate, 1)))n_splits = 16 if est > 256 else 8- # decattn2: EXL3_DEC_DSA_FAST split count (gathered latent decode only)+ # EXL3_DEC_DSA_FAST split count (gathered latent decode only)if fast_cfg is not None and fast_cfg[2] > 0 and indices is not dummy_i and out_latent:n_splits = fast_cfg[2]else:@@ -1506,13 +1506,13 @@ def dsa_attn(and not has_window and not dense_pool and indices is not dummy_i and not dbgand not dbg_pages and block_h == 16) else Noneif dt_cfg is not None and fast_cfg is not None and len(fast_cfg) == 10:- dt_cfg = fast_cfg[3:] # decattn2 preset carries its own BH,DT,BN,DK,NW,NS,QK+ dt_cfg = fast_cfg[3:] # the fast preset carries its own BH,DT,BN,DK,NW,NS,QKif dt_cfg is not None and (H % dt_cfg[0] or D_c % dt_cfg[1]or (H // dt_cfg[0]) * (D_c // dt_cfg[1]) != hb):dt_cfg = Nonewith torch.cuda.device(q.device):if dt_cfg is not None and fast_cfg is not None:- # decattn2: dt kernel with the valid-prefix split / pipelined index chain+ # dt kernel with the valid-prefix split / pipelined index chainbh, bdt, bn, bdk, nw, ns, qd = dt_cfg_dsa_attn_split_fast_kernel[(R * hb, n_splits)](q, ring, kv_chunk, pc_arg, pool_r.reshape(-1),@@ -1719,7 +1719,7 @@ def dsa_indexer_scores(def _dsa_dec_fast_cfg(R = 1):- """decattn2: EXL3_DEC_DSA_FAST (read per call, default 0 = off) = "REBAL,PIPE,SPLITS" for+ """EXL3_DEC_DSA_FAST (read per call, default 0 = off) = "REBAL,PIPE,SPLITS" for_dsa_attn_split_fast_kernel on the dt decode path (SPLITS 0 = launcher default);"REBAL,PIPE,SPLITS,BH,DT,BN,DK,NW,NS,QK" also overrides the dt tile config (EXL3_DSA_DEC_CFG);"1" = the preset below. Needs the dt path (EXL3_DSA_DEC_DT=1, the default)."""@@ -1727,7 +1727,7 @@ def _dsa_dec_fast_cfg(R = 1):if v == "0":return Noneif v == "1":- # test box microbench (scratch/decattn2/report.md): at R >= 2 (MTP verify, ~94 % of the+ # test box microbench : at R >= 2 (MTP verify, ~94 % of the# served decode calls) BH 32 x DT 256 halves the redundant QK of the 64 x 128 dt tile,# 12 splits + pipelined index chain + num_stages 2: 0.091 -> 0.057 ms. R = 1: no# variant beats dt (all within +-5 %), so R = 1 keeps it@@ -1754,7 +1754,7 @@ def _dsa_glue_expand_kernel(s_pool, s_out,P: tl.constexpr, DO_TAIL: tl.constexpr, BLOCK: tl.constexpr = 128,):- """dsaglue1: one program per (row, 128-col block) of the DSA indexer pool expand.+ """one program per (row, 128-col block) of the DSA indexer pool expand.Fuses the decode/verify torch glue after dsa_topk (mla_attn._indexer_topk_kpool):pool_idx * P + arange(P) expand, the >= 0 where-mask, the out copy, and the@@ -1784,7 +1784,7 @@ def _dsa_glue_expand_kernel(def dsa_glue_expand(pool_idx, out_slab, P, q_pos0, do_tail):- """dsaglue1: fused pool-expand + tail-append for one _indexer_topk_kpool slab.+ """fused pool-expand + tail-append for one _indexer_topk_kpool slab.pool_idx (rows, k_sel) int32 top-k pool ids; out_slab (rows, k_pad) int32 sliceof the -1-filled selection; q_pos0 = host_seqlens[b] + r0. Returns the expanddiff --git a/exllamav3/modules/attention_fn/mla_triton.py b/exllamav3/modules/attention_fn/mla_triton.pyindex 6585512..b0adb4b 100644--- a/exllamav3/modules/attention_fn/mla_triton.py+++ b/exllamav3/modules/attention_fn/mla_triton.py@@ -1312,7 +1312,7 @@ def _unfold_cfg(R: int, v_head_dim: int):if _pf_fast():bm, bk, bn, st, nw = _PF_UNFOLD[_row_bucket(R)]return min(bm, block_m), bk, min(bn, v_head_dim), st, nw- # Default = one V tile, 2 stages, k tile halved until it fits. REPORT-28: split-V restores the+ # Default = one V tile, 2 stages, k tile halved until it fits. Split-V restores the# full 128 k tile at D_v 256 but measured 1.6-1.9x slower; the best decode tile ("64,256,1,8",# 99 vs 116 us/call, bit-exact) moved full-model decode by -0.2% (noise), so it is not defaultreturn block_m, 128, v_head_dim, 2, 4diff --git a/exllamav3/modules/attn.py b/exllamav3/modules/attn.pyindex 7ea8d27..75ca72f 100644--- a/exllamav3/modules/attn.py+++ b/exllamav3/modules/attn.py@@ -749,7 +749,7 @@ class Attention(Module):v = outs[2] if len(outs) > 2 else kreturn self.finish_qkv(q, k, v, None, bsz, q_len, params)- # DFlash verify (R rows, REPORT-17): same fused launch as the bsz==1 case above,+ # DFlash verify (R rows): same fused launch as the bsz==1 case above,# generalized to R rows via exl3_dec_gemv_r_multi -- see sliding_attn.py's identical# branch for why the fused multi-matrix call (not per-Linear dec_gemv_r) is required for# bit-exactness (shared strips_total -> shared ktw/kbs with the batch-1 launch). This isdiff --git a/exllamav3/modules/block_graph.py b/exllamav3/modules/block_graph.pyindex c47e044..5e5cec1 100644--- a/exllamav3/modules/block_graph.py+++ b/exllamav3/modules/block_graph.py@@ -71,7 +71,7 @@ BLOCK_GRAPH_DRAFT = _env_int("EXL3_BLOCK_GRAPH_DRAFT", 0)# static input. A block's graph updates it in place, so the next graphed block finds its# input already in place: no copy-in, no output clone (2 copyBuffer launches per block).# Runtime-mutable; call purge() after toggling (captured graphs bake in the buffer address).-from .quant.exl3 import VERIFY_FUSE as _VF # verifyfuse1: fused and unfused verify never share a graph+from .quant.exl3 import VERIFY_FUSE as _VF # fused and unfused verify never share a graphBG_KNOBS = {"shared_x": os.environ.get("EXL3_BG_SHARED_X", "1") != "0"}_shared_x: dict = {}@@ -139,7 +139,7 @@ class _BlockGraphSlot:def _verify_union_dev_ok(x: torch.Tensor, params: dict, draft: bool = False) -> bool:"""R-row DFlash/MTP verify through exl3_dec_moe_union with the device-built unique table- (EXL3_DEC_MOE_UNION_DEV=1, REPORT-28): no host sync, so the block is capturable. The host+ (EXL3_DEC_MOE_UNION_DEV=1): no host sync, so the block is capturable. The hosttable path (UNION_DEV=0) copies the picks to the CPU and must stay eager."""rows = x.shape[0] * x.shape[1]return ((BLOCK_GRAPH_DRAFT >= 2 if draft else BLOCK_GRAPH_VERIFY) and@@ -214,7 +214,7 @@ class BlockGraphRunner:attn = self.block.attnmlp = self.block.mlp# Batch-1 decode MoE (exl3_dec_router + exl3_dec_moe, GLM-5.3: E = 288, K 2): both launch- # sync-free on device tables, so a rows == 1 block is capturable (REPORT-31)+ # sync-free on device tables, so a rows == 1 block is capturabledec_moe_ok = BLOCK_GRAPH_DEC_MOE and getattr(mlp, "support_dec_moe", False) and \x.dim() >= 2 and (x.shape[0] * x.shape[1] == 1 or _verify_union_dev_ok(x, params, draft))if not isinstance(mlp, BlockSparseMLP) or \diff --git a/exllamav3/modules/block_sparse_mlp.py b/exllamav3/modules/block_sparse_mlp.pyindex 2ea332f..1dd31ae 100644--- a/exllamav3/modules/block_sparse_mlp.py+++ b/exllamav3/modules/block_sparse_mlp.py@@ -812,7 +812,7 @@ class BlockSparseMLP(BlockSparseMLP_CPU, Module):)# Codebook: exl3_dec_moe takes one flag for all three projections (the kernel is# templated on the codebook, not per projection), so the layer needs a uniform one.- # mul1 and mcg both decode (REPORT-21); anything else leaves the fused path off.+ # mul1 and mcg both decode; anything else leaves the fused path off.if cbs[0] == cbs[1] == cbs[2] and cbs[0] in ((True, False), (False, True)):self.dec_moe_mcg = bool(cbs[0][0])self.support_dec_moe = self.support_dec_moe and self.dec_moe_mcg is not None@@ -821,7 +821,7 @@ class BlockSparseMLP(BlockSparseMLP_CPU, Module):self.dec_moe_act = g_tensor_cache.get(self.device, (self.num_experts_per_tok, self.intermediate_size_padded), torch.half, "dec_moe_act")self.dec_shf_setup()- # R-row union MoE (REPORT-16/17, exl3_dec_moe_union): shared, per-device+ # R-row union MoE (exl3_dec_moe_union): shared, per-device# workspace (like dec_workspace) sized for the worst case (MAX_BSZN rows, this# layer's topk/H/I) and reused across layers -- forward calls are stream-ordered# so a later layer never races an earlier one's still-in-flight kernel.@@ -847,7 +847,7 @@ class BlockSparseMLP(BlockSparseMLP_CPU, Module):for multi in (self.multi_gate, self.multi_up, self.multi_down)) and self.multi_gate.K == self.multi_up.K# Codebook: mpw_gemm is templated on it and takes one flag for all three projections- # (REPORT-22), so the layer needs a uniform codebook. Unknown (neither mul1 nor mcg,+ #, so the layer needs a uniform codebook. Unknown (neither mul1 nor mcg,# or mixed) leaves the path off.wmma_cbs = {(m.mul1, m.mcg) for m in (self.multi_gate, self.multi_up, self.multi_down)}if len(wmma_cbs) == 1:@@ -1353,7 +1353,7 @@ class BlockSparseMLP(BlockSparseMLP_CPU, Module):if os.environ.get("BSZ_DEBUG"):print(f"[bsz_debug] layer={self.key} bsz={bsz} union={os.environ.get('EXL3_DEC_MOE_UNION')}")bc_sh_exp = False- # REPORT-28: R-row union MoE with the unique-expert table built on device (no host sync),+ # R-row union MoE with the unique-expert table built on device (no host sync),# fed by the batched router -- independent of EXL3_DEC_MOE_UNION's bit-exact per-row loopsunion_dev = os.environ.get("EXL3_DEC_MOE_UNION_DEV", "0") != "0"# V2 selects the device-built unique-expert table without enabling the legacy@@ -1506,11 +1506,11 @@ class BlockSparseMLP(BlockSparseMLP_CPU, Module):return resfinal_hidden_states = self.dec_moe_out.view(eshape)- # R-row union decode (REPORT-16/17, exl3_dec_moe_union), DFlash verify: bit-exact vs- # bsz independent batch-1 exl3_dec_moe calls under shared routing (REPORT-16 Sec 1) --+ # R-row union decode (exl3_dec_moe_union), DFlash verify: bit-exact vs+ # bsz independent batch-1 exl3_dec_moe calls under shared routing --# each unique expert across the bsz rows' picks is decoded once and applied to every row# that picked it in the exact batch-1 per-row arithmetic order. Opt-in (default off):- # REPORT-16 measured no clear speed win yet at R=1 or R=6-8 (host-side unique/assign+ # Measured: no clear speed win yet at R=1 or R=6-8 (host-side unique/assign# build dominates), only R=2..5; EXL3_DEC_MOE_UNION=1 to use it anyway (e.g. to get a# bit-exact verify path even before that's fixed).elif (@@ -2089,7 +2089,7 @@ class BlockSparseMLP(BlockSparseMLP_CPU, Module):literal batch-1 exl3_dec_router_norm launch (same kernel, same args, just row j's data),so row j of the returned y and of dec_routed's (selected, weights) is bit-identical towhat plain batch-1 decode would produce stepping through row j alone -- this is what- REPORT-16 Sec 6 found missing: that report's row-invariance probe exercised+ an earlier row-invariance probe missed: it exercisedexl3_dec_router (unfused), not the exl3_dec_router_norm/dec_norm_route path real decodeactually takes, which is why it saw a k-order mismatch and (for one cell) a 1.22e-4weight mismatch -- neither is possible here, since this never runs a second, independent@@ -2104,7 +2104,7 @@ class BlockSparseMLP(BlockSparseMLP_CPU, Module):# dec_norm_route's raw-buffer return is consumed immediately by the caller either way.return self.dec_norm_route(norm, xa[0], r[0], params)# R>1 (DFlash verify): gated by the same flag as the union MoE kernel it feeds, so- # EXL3_DEC_MOE_UNION=0 reproduces the exact pre-REPORT-17 behavior (generic norm+router,+ # EXL3_DEC_MOE_UNION=0 reproduces the exact earlier behavior (generic norm+router,# dedup MoE) for a clean A/B against it -- R sequential kernel launches here is a real# per-layer cost even though it's bit-exact, not a free win to force on unconditionally.# Also refuse above MAX_BSZN: prefill calls this with R = chunk size (hundreds+), wherediff --git a/exllamav3/modules/mla_attn.py b/exllamav3/modules/mla_attn.pyindex 00cecda..ad66f36 100644--- a/exllamav3/modules/mla_attn.py+++ b/exllamav3/modules/mla_attn.py@@ -40,7 +40,7 @@ assert _score_tile % 256 == 0 and _score_tile > 0# call instead of running the per-tile top-k merge below. Prefill remains tiled.EXL3_DSA_DEC_NOTILE = _os.environ.get("EXL3_DSA_DEC_NOTILE", "1") == "1"-# dsaglue1: fuse the decode/verify DSA indexer torch glue (pool expand + tail+# fuse the decode/verify DSA indexer torch glue (pool expand + tail# append, ~15 launches/layer, ~0.73 ms/round) into one Triton kernel. Default off.EXL3_DSA_GLUE_FUSE = _os.environ.get("EXL3_DSA_GLUE_FUSE", "0") == "1"@@ -933,7 +933,7 @@ class MLAttention(Module):pool_idx = torch.where(run_scr > -float("inf"), run_idx, run_idx.new_full((), -1))- # Expand pools to raw token indices (dsaglue1: one kernel when set;+ # Expand pools to raw token indices (one kernel when set;# single-slab only so the tail offset is this slab's expand width)if EXL3_DSA_GLUE_FUSE and seqlen <= 256:from .attention_fn.dsa_triton import dsa_glue_expanddiff --git a/exllamav3/modules/mlp.py b/exllamav3/modules/mlp.pyindex 47f25db..eb8d6d2 100644--- a/exllamav3/modules/mlp.py+++ b/exllamav3/modules/mlp.py@@ -437,7 +437,7 @@ class MLP(Module):def _vf_plain_exl3(l, dim: int) -> bool:- """verifyfuse1: a Linear whose forward is exactly inner.forward (no pad/trim/lora/scales/bias)+ """a Linear whose forward is exactly inner.forward (no pad/trim/lora/scales/bias)and whose inner LinearEXL3 can run exl3_dec_gemv_r."""return (getattr(l, "quant_type", None) == "exl3" and getattr(l.inner, "dec_ok", False) and@@ -749,7 +749,7 @@ class GatedMLP(Module):for s in r:- # verifyfuse1: R-row verify, gate+up in ONE exl3_dec_gemv_r_multi launch (Hadamards+ # R-row verify, gate+up in ONE exl3_dec_gemv_r_multi launch (Hadamards# inside) instead of 2 x (had_in + exl3_gemv + had_out); down goes to gemv_r via# LinearEXL3.forward. Same activation call as the unfused branch below.if (diff --git a/exllamav3/modules/quant/exl3.py b/exllamav3/modules/quant/exl3.pyindex 961cffc..1b5d6b6 100644--- a/exllamav3/modules/quant/exl3.py+++ b/exllamav3/modules/quant/exl3.py@@ -10,7 +10,7 @@ from ...util import profile_optMAX_BSZN_GEMV_R = 8 # must match MOE_R_MAX in exllamav3_ext/quant/exl3_dec.cu# K >= this runs R batch-1 launches instead of one gemv_r launch (A/B knob; 99 = never loop)DEC_GEMV_R_LOOP_MIN_K = int(os.environ.get("EXL3_DEC_GEMV_R_LOOP_MIN_K", "99"))-# verifyfuse1: EXL3_VERIFY_FUSE=1 routes every R-row (1 < R <= 8) dense EXL3 linear of the MTP/DFlash+# EXL3_VERIFY_FUSE=1 routes every R-row (1 < R <= 8) dense EXL3 linear of the MTP/DFlash# verify forward to exl3_dec_gemv_r (both Hadamards inside, 1 launch) instead of had_in + exl3_gemv +# had_out (3 launches), and fuses the shared-expert gate+up pair into one gemv_r_multi launch# (mlp.py). Rows stay bit-exact vs R batch-1 dec_gemv calls (the R=1 plain-decode math). R=1 untouched.@@ -229,7 +229,7 @@ def dec_workspace(device: torch.device):return ws-# specrow1: wide-N R-row GEMV (lm_head, N=248320: R*kbs*N partial sums > DEC_SCRATCH_FLOATS even at R=2) used to fall back to+# wide-N R-row GEMV (lm_head, N=248320: R*kbs*N partial sums > DEC_SCRATCH_FLOATS even at R=2) used to fall back to# R batch-1 launches, each re-reading the whole weight (R x 1.36 ms). A dedicated scratch lets one gemv_r launch carry all rows# (same kernel, same per-row reduction order, so bit-exact). Counters are shared (R * ceil(N/512) <= 3880 <= 4096 for R <= 8).# Mutable at run time for one-load A/B: set WIDE_R["on"].@@ -262,7 +262,7 @@ def dec_moe_supported(inner) -> bool:"""True when a LinearEXL3 can feed the fused routed-MoE decode (exl3_dec_moe / _union).Same as dec_supported() except that both codebooks qualify: the MoE kernels decode the mcg- codebook as well as mul1 since REPORT-21 (GLM-5.3-Flash's published packs are all mcg), while+ codebook as well as mul1 (GLM-5.3-Flash's published packs are all mcg), whilethe dense exl3_dec_gemv route stays mul1-only."""return (@@ -414,7 +414,7 @@ class LinearEXL3:if rows <= AUTO_RECONSTRUCT_THRESHOLD or self.config.infer_params.no_reconstruct:if rows == 1 and self.dec_ok and not params.get("moe_valu"):return self.dec_gemv(x, out_dtype)- # R-row DFlash verify (REPORT-17): same kernel family as dec_gemv, one weight+ # R-row DFlash verify: same kernel family as dec_gemv, one weight# tile decode shared across rows -- see exl3_dec_gemv_r's docstring for why this# is bit-exact vs R independent dec_gemv calls. Opt-in (EXL3_DEC_MOE_UNION, the# same flag dec_norm_route_r/the union MoE branch use, so one flag controls the@@ -465,7 +465,7 @@ class LinearEXL3:def dec_gemv_r(self, x: torch.Tensor, rows: int, out_dtype):- """R-row decode GEMV (exl3_dec_gemv_r, REPORT-17): one launch, each weight tile decoded+ """R-row decode GEMV (exl3_dec_gemv_r): one launch, each weight tile decodedonce and applied to every row -- bit-exact vs R independent dec_gemv calls, see thekernel's own docstring. Reuses the global dec_workspace() scratch/counters: this callnever runs concurrently (same stream) with a bsz==1 dec_gemv call reading the samediff --git a/exllamav3/modules/quant/fp16.py b/exllamav3/modules/quant/fp16.pyindex 71f95f2..c31c0ec 100644--- a/exllamav3/modules/quant/fp16.py+++ b/exllamav3/modules/quant/fp16.py@@ -6,7 +6,7 @@ import os as _os_f32_via_f16 = _os.environ.get("EXL3_HIP_F32OUT_VIA_F16", "1") != "0" and bool(torch.version.hip)_f32_via_f16_min_rows = int(_os.environ.get("EXL3_HIP_F32OUT_VIA_F16_MIN_ROWS", "32"))# gfx1151 decode: fp16-out torch.matmul at M <= 8 lands on a single-workgroup hipBLAS tile (GLM-5.3-# indexer wk/weights_proj: 108-154 us for 1 MB, REPORT-31); ext.hgemm takes the multi-CU skinny+# indexer wk/weights_proj: 108-154 us for 1 MB); ext.hgemm takes the multi-CU skinny# split-K GEMV first (M <= 8, N <= 128) and falls back to the same GEMM otherwise_hip = bool(torch.version.hip)_f16_small_m_hgemm = _os.environ.get("EXL3_HIP_F16_SMALL_M_HGEMM", "1") != "0" and bool(torch.version.hip)diff --git a/exllamav3/modules/sliding_attn.py b/exllamav3/modules/sliding_attn.pyindex f71dbaa..f90c0c8 100644--- a/exllamav3/modules/sliding_attn.py+++ b/exllamav3/modules/sliding_attn.py@@ -735,7 +735,7 @@ class SlidingAttention(Module):g = outs[3] if len(outs) > 3 else Nonereturn self.finish_qkv(outs[0], outs[1], outs[2], g, bsz, q_len, params)- # DFlash verify (R rows, REPORT-17): same fused launch as the bsz==1 case above, generalized+ # DFlash verify (R rows): same fused launch as the bsz==1 case above, generalized# to R rows via exl3_dec_gemv_r_multi -- same trellis/suh/svh/K list and order as# exl3_dec_gemv_multi, so pick_ktw/kbs_of see the same strips_total and pick the identical# ktw/kbs the batch-1 launch uses. That's required for the block-reduce partition (and so the@@ -1109,7 +1109,7 @@ class SlidingAttention(Module):# window run reaches the end of the buffer) and attend over the pagesbt, cache_seqlens = self._decode_state_prep(rsg, k_states, v_states, seqlen)- # DFlash verify (R rows, REPORT-17): a single paged_attn_triton_decode call over all+ # DFlash verify (R rows): a single paged_attn_triton_decode call over all# R rows at once tiles/splits the KV span from the batch's (single) cache_seqlens and# q_len, which is not necessarily the same tiling a batch-1 call would use for each# row's own (shorter) span -- unverified, and the one dimension this session's kerneldiff --git a/exllamav3/vendor/fla/hip/kda_fused_h_hip.py b/exllamav3/vendor/fla/hip/kda_fused_h_hip.pyindex 09d90a3..0494f47 100644--- a/exllamav3/vendor/fla/hip/kda_fused_h_hip.py+++ b/exllamav3/vendor/fla/hip/kda_fused_h_hip.py@@ -69,16 +69,16 @@ def chunk_kda_fwd_h_fused_hip(q, k, v, gk, beta, Akk, Aqk, scale, initial_state=assert t.is_contiguous()pf = os.environ.get("EXL3_KDA_PF_SPLIT", "0") if not defs else ""if pf == "2":- # kdapf2: spill-free build (0 VGPR spills vs 462): sched barriers (SB), opaque lane+ # spill-free build (0 VGPR spills vs 462): sched barriers (SB), opaque lane# indices (OPQ), pinned WMMA accumulators (OPV), uniform o-store base (ADR), no LSR,# plus PH1=4 PF=1 next-chunk register prefetch. Bitwise-identical to defs="".# Microbench T=4096 HV=64 (test box): 8.70 -> 5.40 ms (-38 %). Default off.defs = "BRL=1 UNI=1 OPQ=15 OPV=11 SB=15 ADR=1 PH1=4 PF=1 -mllvm -disable-lsr"elif pf == "1":- # kdapf1: BRL (branchless f2bf, single basic block) + UNI (wave-uniform rows).+ # BRL (branchless f2bf, single basic block) + UNI (wave-uniform rows).# Bitwise-identical to defs="" (sweep T=4096: 10.979 -> 8.615 ms/layer, -21.5 %),# default off. Name kept per brief; the 2-WG split (lever a) was ruled NO-GO by- # construction (w/tril/vn couple all halves; see scratch/kdapf1/NOTES.md).+ # construction (w/tril/vn couple all halves).defs = "BRL=1 UNI=1"fn = _load(defs)if o is None:diff --git a/tools/glm/dec1_ab.py b/tools/glm/dec1_ab.pyindex 0506ebb..9c4bda7 100644--- a/tools/glm/dec1_ab.py+++ b/tools/glm/dec1_ab.py@@ -1,4 +1,4 @@-# verifyrow1 model A/B: EXL3_GEMV_R_DEC1 off/on/on/off at MTP R=2/3/4, one load, served SPEED_ENV.+# model A/B: EXL3_GEMV_R_DEC1 off/on/on/off at MTP R=2/3/4, one load, served SPEED_ENV.# Per (prompt, R): 4 runs of 128 greedy tokens; decode t/s + ms/round; ids must be identical across# arms (kernel is bit-exact). Unique prompt per rep. Usage: python tools/glm/dec1_ab.py <out.json>import os, sys, ast, json, time, statistics, torchdiff --git a/tools/glm/decattn2_ab.py b/tools/glm/decattn2_ab.pyindex ff0370d..0bd9870 100644--- a/tools/glm/decattn2_ab.py+++ b/tools/glm/decattn2_ab.py@@ -1,4 +1,4 @@-"""decattn2: EXL3_DEC_DSA_FAST A/B on the served GLM config (serve.py SPEED_ENV + MTP n1, MTP_FUSE_CATCHUP=2).+"""EXL3_DEC_DSA_FAST A/B on the served GLM config (serve.py SPEED_ENV + MTP n1, MTP_FUSE_CATCHUP=2).One load. Arms: off (flag 0) / on (flag = $DECATTN2_ON, default "1"). Adapted from mla-fast tools/glm/mlafast_ab.py (a1debac4).Phase A (target only): greedy 32 ids x 3 prompts + teacher-forced decode-path NLL (3 x 4K prompt, 128 forced tokens).Phase B (MTP generator as served): greedy 32 ids x 3, then 4K decode interleaved off/on/on/off..., 128 tokens.diff --git a/tools/glm/decattn2_mb.py b/tools/glm/decattn2_mb.pyindex 0e6460d..2165ee2 100644--- a/tools/glm/decattn2_mb.py+++ b/tools/glm/decattn2_mb.py@@ -1,4 +1,4 @@-"""decattn2 microbench: served dt DSA decode split vs variants, GLM decode shapes (bench_dsa_split.build).+"""microbench: served dt DSA decode split vs variants, GLM decode shapes (bench_dsa_split.build).Each arm = env overrides applied before the call (dsa_triton reads them per call).Prints median / amortized ms and relL2 vs the torch reference per (ctx, R).usage: python tools/glm/decattn2_mb.py [--ctx 4096,32768] [--rows 1,2] [--reps 200]diff --git a/tools/glm/decattn2_probe.py b/tools/glm/decattn2_probe.pyindex d3ad0a6..ed6343d 100644--- a/tools/glm/decattn2_probe.py+++ b/tools/glm/decattn2_probe.py@@ -1,4 +1,4 @@-"""decattn2 probe: which DSA decode kernel does the served GLM config hit, at which R, and what+"""probe: which DSA decode kernel does the served GLM config hit, at which R, and whatdo the real top-k indices look like at 4K (valid count, are the -1 tail-only)?Served env: serve.py SPEED_ENV + MTP (num_draft_tokens=1, MTP_FUSE_CATCHUP=2).Usage: python decattn2_probe.py <model> <corpus> <out.json>"""diff --git a/tools/glm/round_decomp.py b/tools/glm/round_decomp.pyindex d951512..45e95a7 100644--- a/tools/glm/round_decomp.py+++ b/tools/glm/round_decomp.py@@ -27,7 +27,7 @@ torch.set_grad_enabled(False)ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))sys.path.insert(0, ROOT); sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))os.environ.setdefault("EXL3_MOE_UNION_V2", "1")-if os.environ.get("RD_SPEED_ENV", "0") != "0": # verifyfuse1: served SPEED_ENV (serve.py), as the lane runs+if os.environ.get("RD_SPEED_ENV", "0") != "0": # served SPEED_ENV (serve.py), as the lane runsimport ast_src = open(os.path.join(ROOT, "tools/glm/serve.py")).read()for k, v in next(ast.literal_eval(n.value) for n in ast.parse(_src).bodydiff --git a/tools/glm/row_split.py b/tools/glm/row_split.pyindex 0becb50..e2e67db 100644--- a/tools/glm/row_split.py+++ b/tools/glm/row_split.py@@ -1,4 +1,4 @@-# verifyrow1: marginal verify-row cost by op. One load, several MTP arms (ndt -> verify R=ndt+1),+# marginal verify-row cost by op. One load, several MTP arms (ndt -> verify R=ndt+1),# interleaved (RS_NDTS, default 1,2,3,3,2,1), each arm wrapped in an arm_<i>_R<r> marker span so# row_split_floor.py --arm slices the one rocprofv3 trace per arm. Derived from round_decomp.py:# glm-mtp D1-1 rounddecomp: decompose ONE served MTP round (ndt 1, verify R=2) into@@ -30,7 +30,7 @@ torch.set_grad_enabled(False)ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))sys.path.insert(0, ROOT); sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))os.environ.setdefault("EXL3_MOE_UNION_V2", "1")-if os.environ.get("RD_SPEED_ENV", "0") != "0": # verifyfuse1: served SPEED_ENV (serve.py), as the lane runs+if os.environ.get("RD_SPEED_ENV", "0") != "0": # served SPEED_ENV (serve.py), as the lane runsimport ast_src = open(os.path.join(ROOT, "tools/glm/serve.py")).read()for k, v in next(ast.literal_eval(n.value) for n in ast.parse(_src).body@@ -252,7 +252,7 @@ for i, ndt in enumerate(NDTS):UNIQ = collections.defaultdict(list)for ph_, rows_, sel, _w in SELS:UNIQ[f"{ph_}|R{rows_}"].append(int(torch.unique(sel).numel()))- if os.environ.get("RS_SAVE_PICKS"): # verifyrow1: union picks + routing weights, for the top-k trim study+ if os.environ.get("RS_SAVE_PICKS"): # union picks + routing weights, for the top-k trim studytorch.save([(ph_, r_, s_.cpu(), w_.cpu()) for ph_, r_, s_, w_ in SELS if ph_.startswith("verify_fwd")],f"{os.environ['RS_SAVE_PICKS']}_{label}.pt")A_ = dict(label=label, ndt=ndt, R=ndt + 1, rounds=nr, accept=acc,diff --git a/tools/glm/row_split_floor.py b/tools/glm/row_split_floor.pyindex e87f226..734f619 100644--- a/tools/glm/row_split_floor.py+++ b/tools/glm/row_split_floor.py@@ -111,7 +111,7 @@ def main():kern.sort(); marks.sort()KS = [k[0] for k in kern]def in_round(rs, re_):- # verifyrow1: kernels overlapping [rs, re_) via bisect (the trace holds all arms)+ # kernels overlapping [rs, re_) via bisect (the trace holds all arms)i = max(0, bisect.bisect_left(KS, rs) - 64)j = bisect.bisect_left(KS, re_)return [k for k in kern[i:j] if k[1] > rs]@@ -120,7 +120,7 @@ def main():GRID = 256EV = J["events"]; want = [x[0] for x in EV]raw = [m[3] for m in marks]- # verifyrow1: greedy alignment -- the trace also holds unrelated complex64 fills (grid capped+ # greedy alignment -- the trace also holds unrelated complex64 fills (grid capped# at 96*256 for big buffers, e.g. during the per-arm prefills), so skip any mark that is not# the next expected id.mk = []; j = 0diff --git a/tools/glm/serve.py b/tools/glm/serve.pyindex 186bbeb..b5eef72 100644--- a/tools/glm/serve.py+++ b/tools/glm/serve.py@@ -31,36 +31,36 @@ SPEED_ENV = {"EXL3_BLOCK_GRAPH_MLA": "2","EXL3_HC_FN_HALF_PF": "1","EXL3_HC_1PASS_PF": "1",- # 26/09 WINs: decattn2 decode +4.6 % 4K; chunk4096/chunk4096b prefill -7.3 % pf4k.+ # 26/09 gains: DSA decode attention +4.6 % at 4K; prefill chunking -7.3 % at 4K."EXL3_DEC_DSA_FAST": "1","EXL3_MIDCHUNK_CKPT": "2","EXL3_PREFILL_BIG_TAIL": "1","EXL3_BIG_TAIL_DENSE": "1",- "EXL3_PREFILL_BIG_CHUNK_MAXPOS": "32768", # mem512k1: plain chunks beyond 32K depth, lower peak memory at 512K ctx- # 27/09 acceptaudit2 WIN: unquantized MTP eh_proj (td205 stores it at 2 bpw, cos 0.79):+ "EXL3_PREFILL_BIG_CHUNK_MAXPOS": "32768", # plain chunks beyond 32K depth, lower peak memory at 512K ctx+ # 27/09: unquantized MTP eh_proj (td205 stores it at 2 bpw, cos 0.79):# served accept +0.077 +- 0.008 (n=24), target ids 24/24 equal, serve_accept decode +4.8 %.# The pack ships the sidecar as mtp_eh_proj.st; loaded by default (see apply_eh_sidecar_default()).- # 27/09 verifyfuse1 WIN: R-row verify linears in one launch (Hadamards in-kernel):+ # 27/09: R-row verify linears in one launch (Hadamards in-kernel):# served R=2 round -3.04 +- 0.20 ms, +6.7 % t/s; R=1 bitwise, R=2 greedy 64/64."EXL3_VERIFY_FUSE": "1",- # 27/09 round2 WIN: one router launch per verify + wide MoE combine; with R=3 (--num-draft 2)+ # 27/09: one router launch per verify + wide MoE combine; with R=3 (--num-draft 2)# served +6.42 +- 1.34 % vs R=2 base (12 prompts/arm, greedy ids 128/128 x 3 equal)."EXL3_DEC_ROUTER_ROWS": "2","EXL3_MOE_COMBINE_WIDE": "1",- # 27/09 moedec1 WIN: R=3 union MoE with RM=3 instead of RM=4 (tighter registers/LDS+ # 27/09: R=3 union MoE with RM=3 instead of RM=4 (tighter registers/LDS# when every expert serves at most 3 rows); served R=3 round -1.08 ms, +1.46 +- 0.06 % t/s# (one box, one load, n=12/arm paired), greedy ids 12x128/128 identical, kernel bitwise."EXL3_MOEDEC1_RM3": "1",- # kbsgate 71655909: NLL n=64 mean +0.092 % (CI incl 0), median -0.003 %, dPPL -0.04 % -> within GOAL PPL <= +0.1 %; union MoE -3 %.+ # NLL n=64 mean +0.092 % (CI incl 0), median -0.003 %, dPPL -0.04 % -> within GOAL PPL <= +0.1 %; union MoE -3 %."EXL3_MOEDEC1_KBS_A": "3","EXL3_GEMV_R_DEC1": "1",- # 27/09 dsaglue1 + stackbench3 WIN (one box, one load, n=27/arm paired): decode 29.53 -> 30.04 t/s,+ # 27/09: DSA indexer glue fused (n=27/arm paired): decode 29.53 -> 30.04 t/s,# +1.74 +- 0.43 %; greedy ids 3x64 and MTP accept identical. (round2's stack saw -0.08 % at n=12.)"EXL3_DSA_GLUE_FUSE": "1",- # 27/09 pffuse1 + stackbench3 WIN: prefill mHC apply + next mix_norm fused; 16K 574.3 -> 579.8- # (+0.95 +- 0.07 %), pffuse1 4K +1.46 +- 0.48 % (n=10). Decode neutral. Needs the rebuilt ext.+ # 27/09: prefill mHC apply + next mix_norm fused; 16K 574.3 -> 579.8+ # (+0.95 +- 0.07 %), 4K +1.46 +- 0.48 % (n=10). Decode neutral. Needs the rebuilt ext."EXL3_PF_HC_FUSE": "1",- # 27/09 moegemm WIN: mpw2x MoE grouped GEMM (no register spill, 224 VGPR): prefill 579.8 -> 598.2+ # 27/09: mpw2x MoE grouped GEMM (no register spill, 224 VGPR): prefill 579.8 -> 598.2# t/s 4K (+3.24 +- 0.19 %, n=6), 16K +2.62 +- 0.24 % (n=4); ids identical, logits bitwise at 4K."EXL3_MPW2X": "2","EXL3_MLA_PF_FAST": "1",@@ -798,7 +798,7 @@ def main() -> None:if os.environ.get("EXL3_SERVE_WARMUP", "1") != "0":print(f"serve: warm-up {warmup(engine, template):.1f} s", flush=True)print(mem_line("warm"), flush=True)- if os.environ.get("EXL3_SERVE_EMPTY_CACHE", "1") == "1": # mem512k1 lever (a): drop the allocator's inactive slack+ if os.environ.get("EXL3_SERVE_EMPTY_CACHE", "1") == "1": # lever (a): drop the allocator's inactive slackimport torchtorch.cuda.empty_cache()print(mem_line("emptied"), flush=True)diff --git a/tools/glm/sv_probe.py b/tools/glm/sv_probe.pyindex 3ab50db..44e86d1 100644--- a/tools/glm/sv_probe.py+++ b/tools/glm/sv_probe.py@@ -1,4 +1,4 @@-"""servedverify1 probe: first-call cost root cause + served-path decode A/B, one load.+"""probe: first-call cost root cause + served-path decode A/B, one load.Loads GLM exactly as tools/glm/serve.py (ResidentEngine, SPEED_ENV, MTP n1f2+v2) and drivesengine.generate() with chat-templated prompts, as the HTTP layer does.diff --git a/tools/glm/verifyfuse_ab.py b/tools/glm/verifyfuse_ab.pyindex 412ffd0..cecf9a5 100644--- a/tools/glm/verifyfuse_ab.py+++ b/tools/glm/verifyfuse_ab.py@@ -1,4 +1,4 @@-"""verifyfuse1: EXL3_VERIFY_FUSE A/B on the served GLM config (serve.py SPEED_ENV + MTP n1f2, UNION_V2).+"""EXL3_VERIFY_FUSE A/B on the served GLM config (serve.py SPEED_ENV + MTP n1f2, UNION_V2).One load, arms switched at run time (VERIFY_FUSE["on"] + block_graph.purge()).R1: plain generator (no draft) greedy 32 ids x 3 prompts -> must be bitwise (flag only acts on R > 1)R2: MTP generator greedy 64 ids x 3 prompts + accept -> greedy-ids gatediff --git a/tools/glm/verifyfuse_chains.py b/tools/glm/verifyfuse_chains.pyindex adbae1a..853aec0 100644--- a/tools/glm/verifyfuse_chains.py+++ b/tools/glm/verifyfuse_chains.py@@ -1,4 +1,4 @@-# verifyfuse1: rank GPU-side gaps inside verify_fwd_R2 by kernel and by chain, from a D1-1 rounddecomp trace.+# rank GPU-side gaps inside verify_fwd_R2 by kernel and by chain, from a D1-1 rounddecomp trace.# usage: verifyfuse_chains.py <run.rocprof dir> <round_decomp.json> [phase]import csv, glob, json, re, sys, collectionsd, jf = sys.argv[1], sys.argv[2]; PH = sys.argv[3] if len(sys.argv) > 3 else "verify_fwd_R2"diff --git a/tools/glm/verifyfuse_mb.py b/tools/glm/verifyfuse_mb.pyindex f008bb0..9077db4 100644--- a/tools/glm/verifyfuse_mb.py+++ b/tools/glm/verifyfuse_mb.py@@ -1,4 +1,4 @@-# verifyfuse1 microbench: R-row dense EXL3 GEMV at GLM verify shapes, no model load.+# microbench: R-row dense EXL3 GEMV at GLM verify shapes, no model load.# A = served R=2 path (bc.run_alloc / exl3_gemv: had_in + exl3_gemv + had_out, 3 launches)# B = exl3_dec_gemv_r (input/output Hadamards inside, 1 launch; bit-exact vs R batch-1 dec_gemv)# B2 = exl3_dec_gemv_r_multi for shared gate+up (1 launch for 2 matrices)diff --git a/tools/mimo/serve.py b/tools/mimo/serve.pyindex 036ff21..9d8e729 100644--- a/tools/mimo/serve.py+++ b/tools/mimo/serve.py@@ -222,7 +222,7 @@ class ResidentEngine:spec_gate: bool = False, ctx: int | None = None,reset_gate_per_request: bool = False,dynamic_draft: bool = True, draft_confidence: float = 0.6):- # Lossless speculation (mimoident1): every verify row uses the exact R=1 arithmetic, so+ # Lossless speculation: every verify row uses the exact R=1 arithmetic, so# speculative output equals plain greedy output (20/20 prompts). Costs about 5 % chat and# 12 % code tok/s. EXL3_MIMO_LOSSLESS=0 restores the fast, not bit-identical verify.# Set before the exllamav3 import. Catch-up fusion stays automatic (on with the union MoE).@@ -230,7 +230,7 @@ class ResidentEngine:for k, v in (("EXL3_VERIFY_ATTN_LOOP", "1"), ("EXL3_VERIFY_GEMV_R", "1"),("EXL3_DEC_MOE_UNION", "1")):os.environ.setdefault(k, v)- # v2mimochk1: the one-launch wide-N verify GEMV (specrow1, lm_head) is a Qwen win but costs MiMo+ # the one-launch wide-N verify GEMV (lm_head) is a Qwen win but costs MiMo# about 7 % tok/s (35.6/31.0/42.3 -> 33.2/28.9/39.5). Off by default here; the caller's env wins.os.environ.setdefault("EXL3_VERIFY_WIDE_R", "0")import torchdiff --git a/tools/qwen/spec_bench.py b/tools/qwen/spec_bench.pyindex 5008879..722eddc 100644--- a/tools/qwen/spec_bench.py+++ b/tools/qwen/spec_bench.py@@ -19,7 +19,7 @@ from spec_prompts import EXTRAimport spec_policyfrom exllamav3.modules import moe_fusedfrom exllamav3.modules.quant import exl3 as qexl3-# specrow1: arm plain0 = plain greedy with the previous engine config (mf7 MoE kernel, lm_head loop, no GEMV_R_DEC1), every other arm = current config+# arm plain0 = plain greedy with the previous engine config (mf7 MoE kernel, lm_head loop, no GEMV_R_DEC1), every other arm = current configCUR = (os.environ.get("EXL3_GEMV_R_DEC1", "0"), qexl3.WIDE_R["on"], moe_fused.MF9["variant"])def set_cfg(old):os.environ["EXL3_GEMV_R_DEC1"], qexl3.WIDE_R["on"], moe_fused.MF9["variant"] = ("0", False, 0) if old else CUR