Written with Claude (AI). Every switch is an environment variable, read once when llama-server starts. The patches are
on by default (the default is under each variable): to turn one off, set it to 0. GGML_LF_ALL=0 makes every switch you leave unset
default to off; the build then behaves like plain rdna-boosts, apart from the fixes 0005 and 0013. 0007 is
the exception: off unless you ask for it (it is lossy). Set the variables in the shell that starts the server (NAME=value before
the command in bash, $env:NAME = "value" in PowerShell).
(The sets in patches/r59/, patches/r50/ and patches/a55/ are the older ones: there every switch is off unless set.)
| variable | patch | values | what it does |
|---|---|---|---|
GGML_LF_KQ_BLAS(default fp8 when every GPU is a gfx1201; otherwise off) |
0001 K1 | fp8, f16, 0 |
Prefill matmuls of quantized weights (not MXFP4; dense layers, not MoE experts) through hipBLASLt. fp8: weights and activations in fp8, the fastest. f16: weights converted to f16, KLD at the floor. Batches of 384 tokens or more on weights of 20M elements or more, 1024 tokens or more on smaller weights (below that their fixed cost loses to MMQ). The default needs the built-in gfx1201 algorithm lists; on other GPUs set it explicitly (the choice is then timed at startup and can change between runs). |
GGML_LF_KQ_BLAS_FP8_KEEP(default 64) |
0001 K1 | a number; 0 = off |
K1 fp8 only: per input batch, the channels with the largest activations (up to 248, rounded up to a multiple of 8) get a second fp8 term for their weight and activation rounding errors, appended to the same GEMM. About half of the fp8 error above f16 goes away for about 1% of prefill speed. |
GGML_LF_DRAFT_UB(default 512) |
0001 K1 | a number; 0 = no cap |
Caps the draft model's ubatch (only ever lowers it). With -ub 2048, 512 saves about 0.7 GiB of VRAM. |
GGML_LF_FA_FP8(default on) |
0002 F8 | 1, 0 |
Prefill flash attention in fp8. Runs only on RDNA4, with -fa on and a q8_0 KV cache (-ctk q8_0 -ctv q8_0), on batches of 32 tokens or more over 512 or more KV cells. |
GGML_LF_MXFP4_DIRECT(default blaslt) |
0003 M4 | blaslt, 0 |
MXFP4 weights only: prefill converts them exactly to fp8 and runs 0001's fp8 GEMM. Batches of 64 tokens or more. (fp8 and f16 select older kernels, a little slower.) |
LLAMA_REASONING_GUARD(default on) |
0004 | 1, 0 |
When the model samples an end of turn inside its reasoning block, the block's end tag (</think>) is emitted instead and generation goes on, so the answer lands in the reply instead of the reasoning. Nothing before that point changes; it never shortens the reasoning, and a reply cut by max_tokens is left as it is. When it fires the model usually writes its answer again after the reasoning (leave room in max_tokens), and the log prints emitting the end tag. Needs a template whose reasoning end tag ends with one token (Qwen's </think>); otherwise the log says it is off. |
GGML_CUDA_MMVK(default 2) |
0006 mmvk | 0-4 |
Q4_K / Q5_K / Q6_K matmuls of 1 to 8 tokens (decode and speculative verification) run a kernel that keeps the activations in registers across several weight rows. 2: also launches the matmuls that read the same input (gate + up, q + k + v, DeltaNet qkv + z) as one kernel; 1: one launch each (same numbers, about 1% slower). 1 and 2 are on only when llama-server verifies speculative drafts (a draft model, MTP or an n-gram type): one-token decode alone is 1-1.6% faster on the stock kernel. 3 / 4 are the same, always. Silent on a GPU it does not run on (RDNA4 only). The server log prints mmvk on (...) or mmvk off (...). Not bit-identical to the stock kernel (float summation order); decode and verification give the same results as each other. |
GGML_CUDA_MMVK_EXT(default 1) |
0006 mmvk | bit mask | 1: groups may mix weight types. 2: IQ4_XS / IQ4_NL / MXFP4 through mmvk too (their stock kernel is already close to the bandwidth limit; normally leave it). |
LLAMA_SPEC_LENIENCE(default off, 1) |
0007 | a number between 0 and 1 | Lossy. With sampled drafts (llama.cpp's own --spec-draft-sampling probabilistic) and a request temperature above 0, a drafted token is accepted with probability min(1, p / (l·q)) instead of min(1, p / q); the rest of the verification is unchanged, so no token becomes more than 1/l times as likely as under the model. The request field spec_lenience sets it per request. Has no effect at temperature 0 or with greedy drafts. See the 2026-10-27 report for what 0.8663 did to speed and quality. |
GGML_GLU_INPLACE(default on) |
0008 | 1, 0 |
The graph allocator may give a GLU (SwiGLU, GEGLU, ...) the memory of its gate when nothing else reads the gate, so an FFN's gate, up and GLU output are not all live at once: 150 MiB less compute buffer at -ub 2048 on Qwen3.8-27B. Same output. |
GGML_CUDA_FA_BAND_SPLIT(default on) |
0009 | 1, 0 |
RDNA4: a draft-verification batch of 9 to 16 query rows (two slots of a unified KV cache verifying at once, or an n-gram draft longer than 7) runs its attention as two halves of at most 8 rows through the decode / verify kernel instead of the generic one. Each row gets the result a batch of 8 rows or fewer gives (not bit-identical to the generic kernel). Only with -fa on, from GGML_CUDA_FA_BAND_SPLIT_MIN_KV KV cells (default 8192; 0 = any length): below that the two launches cost more than they save. |
LLAMA_DFLASH_ADAPTIVE(default on) |
0012 | 1, 2, 0 |
DFlash2 drafts each sequence's own width (1 to --spec-draft-n-max) from running acceptance estimates; the output does not change. 2 also logs the width changes and, per request, the verifications per width. 0: the fixed width. LLAMA_DFLASH_ADAPTIVE_COST (0.035) and LLAMA_DFLASH_ADAPTIVE_JUMP (0.08) set the cost model. |
GGML_CUDA_GDN_NT(default on) |
0013 | 1, 0 |
The Gated DeltaNet verify kernel (qwen35 / qwen35moe, draft verification) reads the recurrent state and writes its per-token snapshots with non-temporal hints, so they do not push the next matmuls' weights out of the cache. Same values. |
LLAMA_RS_ANCHOR(default on) |
0013 v3 | 1, 0 |
qwen35 / qwen35moe with drafts: each slot keeps two recurrent-state planes (after its last batch, and the one that batch started from) and the batch's per-token replay factors instead of one full state per draft token; a partly rejected draft is replayed from the start state. Same output; about 1 GiB less VRAM with 2 slots (0.5 GiB with 1), slightly faster. Needs every recurrent layer on the CPU or a CUDA / ROCm GPU (otherwise the log says it is off). Before v3 (0013 v2) it was off unless set to 1. |
LLAMA_SPEC_NGRAM_SHADOW(default 24) |
0014 | a number; 0 = off |
Only with an n-gram type ahead of a model drafter (--spec-type ngram-mod,draft-dflash). The n-gram drafts are held back until they have predicted this many of the model's tokens in a row; then they are verified (up to --spec-ngram-mod-n-max) without DFlash2, until one misses. 0: the n-gram drafts always go first, as upstream. LLAMA_SPEC_NGRAM_SHADOW_EXACT=1 cuts them to 7 tokens, so the greedy output is the one without the n-gram type. |
LLAMA_SPEC_ALIGN(default on) |
0015 | 1, 0 |
Hybrid / recurrent models only: sequences that verify drafts in the same batch send drafts of one length (DFlash2's adaptive width aligns up to the others, up to --spec-draft-n-max; a longer draft is cut to the shortest), so the verify batch is not split into ubatches. From r154 rdna-boosts reads the same variable for its own alignment of draft-mtp-adaptive: 0 turns off both; with GGML_LF_ALL=0 and the variable unset, ours is off and the release's stays on. |
LLAMA_SPEC_ALIGN_CUT(default on) |
0015 v2 | 1, 0 |
The cut of the drafts of one call to the shortest one, and the raise of DFlash2's width to a draft another drafter already made, which it relies on. 0: unequal drafts are left to the ubatch split, as in the release (rdna-boosts measured the cut as a loss where an n-gram draft is short because of its content; here it removes a mismatch of two caps, a copying slot's 15-token n-gram draft next to DFlash2's block). |
0001-0003 do not touch decode and draft verification: their batches are below every minimum above. 0006 and 0009 are only for them. 0007 changes only how sampled drafts are accepted; 0012, 0014 and 0015 only what is drafted.
| parameter | why |
|---|---|
-ub 2048 -b 2048 |
K1 is fastest on large batches (2048), and needs at least 1024 tokens on small weights. The main model's compute buffer grows by about 1.1 MiB per ubatch token: lower it (e.g. 1536) if a long context does not fit. |
-fa on -ctk q8_0 -ctv q8_0 |
F8 runs only on a q8_0 KV cache with flash attention. |
--spec-type ngram-mod,draft-dflash --spec-ngram-mod-n-max 15 --spec-ngram-mod-n-min 8 |
Only for 0014: an n-gram type before DFlash2. Without it 0014 does nothing. |
--spec-draft-sampling probabilistic |
Only for 0007. llama.cpp's own parameter: sample the draft and verify it by rejection sampling (exact). Faster on sampled code / math at temperature 0.7-1.0, can be slower at low temperature: measure on your own workload. |
The whole command we run (draft model, n-gram drafts): README.
GGML_LF_ALL=0: every unset switch above defaults to off. A switch you set still wins (e.g. GGML_LF_ALL=0 GGML_LF_FA_FP8=1
turns on F8 alone).
| variable | values | what it does |
|---|---|---|
GGML_LF_KQ_BLAS_ALGOS |
unset, def.gfx1201v1, K1a2.<...>, tune, 0 |
K1 f16: how hipBLASLt algorithms are picked. Unset: the built-in gfx1201 list (def.gfx1201v1; other GPUs: tune). K1a2.<...>: reuse a table the log printed earlier. tune: time the candidates at startup (about 9 s; the choice, and so the output, can change between runs). 0: hipBLASLt's own first choice. The log prints the table in use as GGML_LF_KQ_BLAS_ALGOS=K1a2.<...>. |
GGML_LF_MXFP4_ALGOS |
unset, heur, timed |
The fp8 GEMM (K1 fp8 and M4). Unset: the built-in gfx1201 fp8 list. heur: hipBLASLt's first choice. timed: time the candidates on the first full batch (can change between runs). |
GGML_LF_KQ_BLAS_CHUNK_MB |
a number | Converts weights in pieces of that many MB. Saves only about 150 MB of VRAM; prefill gets slower (about 9% on Windows) and the output changes. Not recommended. |
| variable | what it does |
|---|---|
GGML_LF_KQ_BLAS_LOG=1, GGML_LF_MXFP4_LOG=1 |
Print each GEMM shape's algorithm choice (K1) / one line per weight tensor (M4). |
GGML_LF_KQ_BLAS_MIN_T (384), GGML_LF_FA_FP8_MIN_T (32), GGML_LF_FA_FP8_MIN_KV (512), GGML_LF_MXFP4_MIN_T (64) |
The minimum batch (tokens) or KV length each path takes; defaults in brackets. K1's applies to weights of 20M elements or more (smaller ones: at least 1024); 1024 gives 0001 v4's behaviour. |
GGML_LF_KQ_BLAS_DIRECT (on), GGML_LF_KQ_BLAS_CHECK (off) |
0001 v6: Q4_K / Q5_K / IQ4_XS weights converted without the LDS round trip (the same bytes); 0 uses the older kernels. CHECK=1 runs both on every conversion and logs differing bytes (diagnostics, slow). |
GGML_LF_KQ_BLAS_SHARE=0, GGML_LF_MXFP4_SHARE=0 |
Convert the activations for every matmul instead of once per input: same result, slower. |
GGML_LF_MXFP4_AMAX=row, GGML_LF_MXFP4_CONV=row |
Alternative kernels for the activation scale / the MXFP4 conversion: same result. |
GGML_LF_MXFP4_CFG, GGML_LF_MXFP4_SPLITK |
Experiments for M4's fp8 kernel. |
| variable | what it does |
|---|---|
GGML_CUDA_FA_STAGE_MAX_MB |
rdna-boosts: cap (MiB) of the flash-attention F16 staging copy, which only grows. Where F8 runs (every GPU RDNA4) and the variable is unset, 0002 sets it to 1: the batches F8 does not take (9-31 tokens) then read the q8_0 cache directly, same result and speed, and the copy (about 1.2 GB at 240K context; on Windows it ends up in shared memory) is never made. An explicit value still wins; 0 means no cap. |
GGML_LF_DFLASH_DEV |
rdna-boosts (F1), on by default: with a DFlash draft the target model's features stay on the GPU. 0 turns it off. |
HIPBLASLT_TENSILE_LIBPATH |
hipBLASLt's own: where its kernels are. See the build guides. |
HIP_VISIBLE_DEVICES |
HIP's own: which GPUs the program sees. K1's default needs every visible GPU to be a gfx1201 (see the Windows build guide). |
HSA_USERPTR_FOR_PAGED_MEM |
ROCm's own, Linux. We set it to 0: ROCm then allocates pinned host memory (hipHostMalloc, the ROCm_Host buffers) through the driver instead of as pageable pages registered with the GPU, which the kernel may swap out or move, stopping every GPU queue of the process until the page is back. See the README. Not needed on Windows. |
本文件由 Claude(AI)撰寫。所有開關都是環境變數,llama-server 啟動時讀一次。patch 預設都是開的(預設值寫在每個變數下方):要關哪一個,就把它設成 0。GGML_LF_ALL=0 會讓所有沒設的開關預設改成關;這時行為和原版 rdna-boosts 相同,只差 0005 與 0013 的修正。0007 是例外:不設就是關(它有損)。在啟動 server 的 shell 裡設定(bash 寫在指令前面 名稱=值,PowerShell 用 $env:名稱 = "值")。
(patches/r59/、patches/r50/、patches/a55/ 是舊版:那些版本不設就是關。)
| 變數 | patch | 值 | 作用 |
|---|---|---|---|
GGML_LF_KQ_BLAS(預設:所有 GPU 都是 gfx1201 時為 fp8,否則關) |
0001 K1 | fp8、f16、0 |
量化權重(MXFP4 除外;只有一般的矩陣乘,不含 MoE 專家)的 prefill 矩陣乘改走 hipBLASLt。fp8:權重與 activation 都轉 fp8,最快。f16:權重轉 f16,KLD 與底噪相同。權重 2000 萬元素以上的矩陣處理 384 token 以上的批次,較小的權重處理 1024 token 以上(再小時固定開銷輸給 MMQ)。預設值依賴內建的 gfx1201 演算法清單;其他顯卡請明確設定(這時會在啟動時實測挑選,結果可能每次不同)。 |
GGML_LF_KQ_BLAS_FP8_KEEP(預設 64) |
0001 K1 | 數字;0 為關 |
只對 K1 fp8:每個輸入批次挑出 activation 最大的通道(最多 248,取 8 的倍數),把這些通道的權重與 activation 的 fp8 捨入誤差,當成第二個 fp8 項接在同一次矩陣乘裡。fp8 比 f16 多出的誤差約減半,prefill 約慢 1%。 |
GGML_LF_DRAFT_UB(預設 512) |
0001 K1 | 數字;0 為不限 |
限制草稿模型的 ubatch(只會調小)。-ub 2048 時 512 約省 0.7 GiB 顯存。 |
GGML_LF_FA_FP8(預設開) |
0002 F8 | 1、0 |
prefill 的 flash attention 改用 fp8。只在 RDNA4、-fa on 且 KV 快取為 q8_0(-ctk q8_0 -ctv q8_0)時作用,批次 32 token 以上、KV 512 格以上。 |
GGML_LF_MXFP4_DIRECT(預設 blaslt) |
0003 M4 | blaslt、0 |
只對 MXFP4 權重:prefill 時把權重精確轉成 fp8,用 0001 的 fp8 矩陣乘。批次 64 token 以上。(fp8、f16 是較舊的 kernel,稍慢。) |
LLAMA_REASONING_GUARD(預設開) |
0004 | 1、0 |
模型在思考區裡抽到「結束回合」時,改成輸出思考區的結束標籤(</think>)並繼續生成,答案就會落在正文而不是思考區。在那之前的內容完全不變;不會縮短思考,被 max_tokens 截斷的回覆也照舊。觸發時模型通常會在思考之後把答案再寫一次(max_tokens 要留餘裕),log 會印 emitting the end tag。需要模板的思考結束標籤以單一 token 結尾(Qwen 的 </think>),否則 log 會說它沒開。 |
GGML_CUDA_MMVK(預設 2) |
0006 mmvk | 0~4 |
Q4_K/Q5_K/Q6_K 在 1~8 個 token 時的矩陣乘(decode 與推測解碼的驗證)改用 mmvk:activation 留在暫存器裡,給多列權重重複使用。2:讀同一個輸入的矩陣乘(gate+up、q+k+v、DeltaNet qkv+z)合併成一次發射;1:各自發射(數值相同,約慢 1%)。1、2 只在 llama-server 驗證推測解碼草稿時開(草稿模型、MTP 或 ngram):只有單 token decode 時原版 kernel 快 1~1.6%。3/4 相同但一律開。在不支援的 GPU 上不作用(只支援 RDNA4)。server log 會印 mmvk on (...) 或 mmvk off (...)。和原版 kernel 不逐位元相同(浮點加總順序不同);decode 與驗證彼此一致。 |
GGML_CUDA_MMVK_EXT(預設 1) |
0006 mmvk | 位元 | 1:合併發射可混合不同權重型別。2:IQ4_XS/IQ4_NL/MXFP4 也走 mmvk(這些型別的原版 kernel 已接近頻寬上限,平常不設)。 |
LLAMA_SPEC_LENIENCE(預設關, 1) |
0007 | 0 到 1 之間的數字 | 有損。 使用抽樣草稿(llama.cpp 自己的 --spec-draft-sampling probabilistic)且請求溫度大於 0 時,草稿字的接受機率從 min(1, p/q) 改成 min(1, p/(l·q));驗證的其餘部分不變,所以任何字的機率最多變成原本的 1/l 倍。請求欄位 spec_lenience 可逐請求設定。溫度 0 或 greedy 草稿時沒有作用。0.8663 對速度與品質的影響見 2026-10-27 報告。 |
GGML_GLU_INPLACE(預設開) |
0008 | 1、0 |
圖配置器可以讓 GLU(SwiGLU、GEGLU…)在 gate 沒有其他讀取者時直接寫進 gate 的記憶體,FFN 的 gate、up、GLU 輸出就不會同時存在:Qwen3.8-27B 在 -ub 2048 時計算緩衝區少 150 MiB。輸出相同。 |
GGML_CUDA_FA_BAND_SPLIT(預設開) |
0009 | 1、0 |
RDNA4:9~16 個查詢列的草稿驗證批次(unified KV 下兩個 slot 同時驗證,或 n-gram 草稿超過 7 個 token)把注意力切成兩半、每半最多 8 列,走 decode/驗證用的 kernel,而不是一般 kernel。每一列得到的結果和 8 列以下的批次相同(和一般 kernel 不逐位元相同)。只在 -fa on、KV 達 GGML_CUDA_FA_BAND_SPLIT_MIN_KV 格(預設 8192;0 為不限長度)時作用:更短時兩次發射的成本大於省下的。 |
LLAMA_DFLASH_ADAPTIVE(預設開) |
0012 | 1、2、0 |
DFlash2 依照持續更新的接受率估計,為每個序列各自選草稿寬度(1 到 --spec-draft-n-max);輸出不變。2 另外記錄寬度變化,以及每個請求在各寬度的驗證次數。0:固定寬度。成本模型用 LLAMA_DFLASH_ADAPTIVE_COST(0.035)與 LLAMA_DFLASH_ADAPTIVE_JUMP(0.08)設定。 |
GGML_CUDA_GDN_NT(預設開) |
0013 | 1、0 |
Gated DeltaNet 的驗證 kernel(qwen35/qwen35moe 的草稿驗證)讀遞迴狀態、寫每個 token 的快照時用 non-temporal 提示,不把接下來矩陣乘的權重擠出快取。數值相同。 |
LLAMA_RS_ANCHOR(預設開) |
0013 v3 | 1、0 |
qwen35/qwen35moe 搭配草稿時:每個 slot 只留兩個遞迴狀態平面(上一批之後的狀態、該批開始時的狀態)和該批每個 token 的重播因子,而不是每個草稿 token 一份完整狀態;草稿只接受一部分時,從開始時的狀態重播。輸出相同;2 slot 約省 1 GiB 顯存(1 slot 約 0.5 GiB),速度略快。所有遞迴層要放在 CPU 或 CUDA/ROCm GPU 上(否則 log 會說它關了)。v3 以前(0013 v2)不設成 1 就是關。 |
LLAMA_SPEC_NGRAM_SHADOW(預設 24) |
0014 | 數字;0 為關 |
只在模型草稿器前面有 n-gram 類型時作用(--spec-type ngram-mod,draft-dflash)。n-gram 草稿先不送出,等它連續猜中模型這麼多個 token 之後,才不經 DFlash2 直接送驗證(最多 --spec-ngram-mod-n-max 個),直到猜錯一次為止。0:n-gram 草稿一律優先,和上游相同。LLAMA_SPEC_NGRAM_SHADOW_EXACT=1 把它截到 7 個 token,greedy 輸出就和沒有 n-gram 類型時相同。 |
LLAMA_SPEC_ALIGN(預設開) |
0015 | 1、0 |
只對 hybrid/recurrent 模型:在同一批次裡驗證草稿的序列送出同樣長度的草稿(DFlash2 的自適應寬度往上對齊其他序列,最多到 --spec-draft-n-max;較長的草稿截到最短的長度),驗證批次就不會被拆成多個 ubatch。r154 起 rdna-boosts 也用同一個變數控制它自己對 draft-mtp-adaptive 的對齊:設 0 兩者都關;GGML_LF_ALL=0 且沒設這個變數時,我們的關、原版的照舊開。 |
LLAMA_SPEC_ALIGN_CUT(預設開) |
0015 v2 | 1、0 |
把同一輪的草稿截到最短的長度,以及它所依賴的「DFlash2 寬度往上對齊其他草稿器已出的草稿」。0:長度不同的草稿交給 ubatch 拆分處理,和原版相同(rdna-boosts 量到:n-gram 草稿因內容而短時,截短是損失;這裡截掉的是兩個上限造成的不等長,照抄 slot 的 15 個 token n-gram 草稿對上 DFlash2 的區塊)。 |
0001~0003 不影響 decode 與草稿驗證:它們的批次都低於上面的下限。0006 與 0009 只作用在這兩者。0007 只改變抽樣草稿的接受方式;0012、0014、0015 只改變草稿的內容。
| 參數 | 原因 |
|---|---|
-ub 2048 -b 2048 |
K1 在大批次(2048)最快;小權重至少要 1024 token。主模型的計算暫存區每個 ubatch token 約 1.1 MiB:長上下文放不下時可以降低(例如 1536)。 |
-fa on -ctk q8_0 -ctv q8_0 |
F8 只在 flash attention+q8_0 KV 快取上作用。 |
--spec-type ngram-mod,draft-dflash --spec-ngram-mod-n-max 15 --spec-ngram-mod-n-min 8 |
只有 0014 需要:n-gram 類型放在 DFlash2 前面。沒有它,0014 不會作用。 |
--spec-draft-sampling probabilistic |
只有 0007 需要。llama.cpp 自己的參數:草稿改為抽樣,以拒絕取樣驗證(無損)。溫度 0.7~1.0 的寫程式/數學變快,低溫時可能變慢:請用自己的工作負載實測。 |
我們實際使用的完整指令(草稿模型、n-gram 草稿):見 README。--spec-type、--spec-ngram-mod-n-max/-n-min 都是上游 llama.cpp 的參數(預設 64/48);rdna-boosts 會把長度夾到 15、最短也跟著變 15,不設的話只會用到剛好 15 個 token 的 n-gram 草稿,所以我們設最短 8。DFlash2 草稿模型只適用 Qwen3.8-27B(z-lab/Qwen3.8-27B-DFlash2-GGUF,Q4_K_M)。Windows 打包版附 run-server-sample.ps1,只要填模型路徑。
GGML_LF_ALL=0:上面所有沒設的開關預設改成關。有設的開關仍以設定為準(例如 GGML_LF_ALL=0 GGML_LF_FA_FP8=1 只開 F8)。
| 變數 | 值 | 作用 |
|---|---|---|
GGML_LF_KQ_BLAS_ALGOS |
不設、def.gfx1201v1、K1a2.<...>、tune、0 |
K1 f16 怎麼選 hipBLASLt 演算法。不設:內建的 gfx1201 清單(def.gfx1201v1;其他顯卡等於 tune)。K1a2.<...>:沿用 log 之前印出的表。tune:啟動時實測(約 9 秒;選擇與輸出可能每次不同)。0:hipBLASLt 自己的第一名。log 會印出實際使用的表 GGML_LF_KQ_BLAS_ALGOS=K1a2.<...>。 |
GGML_LF_MXFP4_ALGOS |
不設、heur、timed |
fp8 矩陣乘(K1 fp8 與 M4)。不設:內建的 gfx1201 fp8 清單。heur:hipBLASLt 的第一名。timed:在第一個完整批次實測(可能每次不同)。 |
GGML_LF_KQ_BLAS_CHUNK_MB |
數字 | 權重分段轉換,每段幾 MB。只省約 150 MB 顯存,prefill 變慢(Windows 約 9%),輸出也會改變。不建議。 |
| 變數 | 作用 |
|---|---|
GGML_LF_KQ_BLAS_LOG=1、GGML_LF_MXFP4_LOG=1 |
印出每個矩陣形狀選到的演算法(K1)/每個權重一行(M4)。 |
GGML_LF_KQ_BLAS_MIN_T(384)、GGML_LF_FA_FP8_MIN_T(32)、GGML_LF_FA_FP8_MIN_KV(512)、GGML_LF_MXFP4_MIN_T(64) |
各路徑接手的最小批次(token)或 KV 長度;括號內為預設值。K1 的門檻只用在 2000 萬元素以上的權重(較小的至少 1024);設 1024 等於 0001 v4 的行為。 |
GGML_LF_KQ_BLAS_DIRECT(開)、GGML_LF_KQ_BLAS_CHECK(關) |
0001 v6:Q4_K/Q5_K/IQ4_XS 權重轉換不經 LDS(位元組相同、較快);設 0 用舊 kernel。CHECK=1 每次轉換新舊各跑一次並記錄不同的位元組(診斷用,慢)。 |
GGML_LF_KQ_BLAS_SHARE=0、GGML_LF_MXFP4_SHARE=0 |
每個矩陣乘都重新轉換 activation,而不是每個輸入只轉一次:結果相同、較慢。 |
GGML_LF_MXFP4_AMAX=row、GGML_LF_MXFP4_CONV=row |
activation 縮放值/MXFP4 轉換的另一種 kernel:結果相同。 |
GGML_LF_MXFP4_CFG、GGML_LF_MXFP4_SPLITK |
M4 fp8 kernel 的實驗參數。 |
| 變數 | 作用 |
|---|---|
GGML_CUDA_FA_STAGE_MAX_MB |
rdna-boosts 的變數:flash attention F16 暫存複本的上限(MiB),這個暫存區只增不減。F8 有在跑(所有 GPU 都是 RDNA4)且沒設這個變數時,0002 把它設成 1:F8 不接手的批次(9~31 token)改直接讀 q8_0 快取,結果和速度相同,也不會產生那份複本(24 萬上下文約 1.2 GB;Windows 上會落到共用記憶體)。明確設定時以設定為準;0 表示不設上限。 |
GGML_LF_DFLASH_DEV |
rdna-boosts 的 F1,預設開:使用 DFlash 草稿時,目標模型的特徵留在 GPU 上。0 為關。 |
HIPBLASLT_TENSILE_LIBPATH |
hipBLASLt 自己的變數:kernel 的位置,見編譯說明。 |
HIP_VISIBLE_DEVICES |
HIP 自己的變數:程式看得到哪些 GPU。K1 的預設值要求看得到的 GPU 全是 gfx1201(見 Windows 編譯說明)。 |
HSA_USERPTR_FOR_PAGED_MEM |
ROCm 自己的變數,Linux 用。我們設成 0:ROCm 的固定主機記憶體(hipHostMalloc、ROCm_Host 緩衝區)改由驅動配置,而不是登記給 GPU 的一般可分頁記憶體;後者被核心換出或搬動時,整個行程的 GPU 佇列都會停住,直到該頁回來。詳見 README。Windows 不需要。 |