kv-cache : keep rotation constants on the GPU (#31073)
* kv-cache : keep rotation constants on the GPU Assisted-by: Codex * tests : verify resident KV rotation buffers Assisted-by: Codex * kv-cache : document remaining multi-device rotation work Assisted-by: Codex * kv-cache : support per-layer rotation buffers Assisted-by: Codex * kv-cache : fix hybrid SWA rotation inputs and mixed placement check Assisted-by: Codex * models : use per-layer rotation in mistral-large4 and dflash * tests: drop the rotation buffer tests --------- Co-authored-by: Pascal <admin@serveurperso.com>
This commit is contained in:
1 parent
ab3768cdc2
commit
fb5997274e
15 files changed
+179
-246
No files matched your search
@@ -968,13 +968,13 @@ ggml_tensor * llama_model_qwen4exp::graph::build_attn_qsa(
|
||||
int il) {
|
||||
// rotate q/k/v before they reach a quantized cache, as the dense path does. the indexer
|
||||
// has already scored with its own query in build_qsa_sel, so the selection is unaffected.
|
||||
if (inp->self_k_rot) {
|
||||
q_cur = llama_mul_mat_hadamard(ctx0, q_cur, inp->self_k_rot);
|
||||
k_cur = llama_mul_mat_hadamard(ctx0, k_cur, inp->self_k_rot);
|
||||
if (inp->self_k_rot[il]) {
|
||||
q_cur = llama_mul_mat_hadamard(ctx0, q_cur, inp->self_k_rot[il]);
|
||||
k_cur = llama_mul_mat_hadamard(ctx0, k_cur, inp->self_k_rot[il]);
|
||||
}
|
||||
|
||||
if (inp->self_v_rot) {
|
||||
v_cur = llama_mul_mat_hadamard(ctx0, v_cur, inp->self_v_rot);
|
||||
if (inp->self_v_rot[il]) {
|
||||
v_cur = llama_mul_mat_hadamard(ctx0, v_cur, inp->self_v_rot[il]);
|
||||
}
|
||||
|
||||
// these nodes are added to the graph together so that they are not reordered
|
||||
@@ -1009,8 +1009,8 @@ ggml_tensor * llama_model_qwen4exp::graph::build_attn_qsa(
|
||||
cb(cur, "kqv_out", il);
|
||||
|
||||
// the rotation is its own inverse, so undo it on the value side of the output
|
||||
if (inp->self_v_rot) {
|
||||
cur = llama_mul_mat_hadamard(ctx0, cur, inp->self_v_rot);
|
||||
if (inp->self_v_rot[il]) {
|
||||
cur = llama_mul_mat_hadamard(ctx0, cur, inp->self_v_rot[il]);
|
||||
}
|
||||
|
||||
return cur;
|
||||
|
||||
Reference in new issue
Block a user