Repository navigation
llama : move the indexer key rotation choice into the model classes - #32653
Conversation
The KV cache forced a Hadamard rotation for the lightning indexer keys based on a list of architectures. The virtual llama_model::indexer_k_rot() now returns true for the same models. DeepSeek4.1 inherits from DeepSeek4 but was not in the list, so it overrides it back to false.
|
I guess this should also be part of memory? @ggerganov |
I have to check, but I think that the Hadamard transform for the lightning indexer is technically a property of the model - it is how it is trained. So if this is the case, then it should be OK as currently proposed. |
| // always rotate the lightning indexer keys with a Hadamard transform | ||
| virtual bool indexer_k_rot() const { return false; } |
There was a problem hiding this comment.
| // always rotate the lightning indexer keys with a Hadamard transform | |
| virtual bool indexer_k_rot() const { return false; } | |
| // apply Hadamard transform to the lightning indexer keys | |
| virtual bool lid_k_hdmd() const { return false; } |
|
yes it is a property of the model |
ggerganov
left a comment
There was a problem hiding this comment.
deepseek41 inherits from deepseek4 but was not in the list, so it overrides lid_k_hdmd() back to false. Its indexer KV cache does pass the size check, so this may be an omission from when DeepSeek4.1 was added. If so, the fix is to delete that override; I left that for a separate change.
Hm, interesting. Definitely need to check what's the case here.
It's not relevant. I checked it |
…gml-org#32653) * llama : move the indexer key rotation choice into the model classes The KV cache forced a Hadamard rotation for the lightning indexer keys based on a list of architectures. The virtual llama_model::indexer_k_rot() now returns true for the same models. DeepSeek4.1 inherits from DeepSeek4 but was not in the list, so it overrides it back to false. * llama : rename indexer_k_rot() to lid_k_hdmd()
…gml-org#32653) * llama : move the indexer key rotation choice into the model classes The KV cache forced a Hadamard rotation for the lightning indexer keys based on a list of architectures. The virtual llama_model::indexer_k_rot() now returns true for the same models. DeepSeek4.1 inherits from DeepSeek4 but was not in the list, so it overrides it back to false. * llama : rename indexer_k_rot() to lid_k_hdmd()
…gml-org#32653) * llama : move the indexer key rotation choice into the model classes The KV cache forced a Hadamard rotation for the lightning indexer keys based on a list of architectures. The virtual llama_model::indexer_k_rot() now returns true for the same models. DeepSeek4.1 inherits from DeepSeek4 but was not in the list, so it overrides it back to false. * llama : rename indexer_k_rot() to lid_k_hdmd() (cherry picked from commit 4783b11)
…gml-org#32653) * llama : move the indexer key rotation choice into the model classes The KV cache forced a Hadamard rotation for the lightning indexer keys based on a list of architectures. The virtual llama_model::indexer_k_rot() now returns true for the same models. DeepSeek4.1 inherits from DeepSeek4 but was not in the list, so it overrides it back to false. * llama : rename indexer_k_rot() to lid_k_hdmd()
Overview
Follow-up to #32648. The KV cache forced a Hadamard rotation for the lightning indexer keys based on a list of architectures. The virtual
llama_model::lid_k_hdmd()now returns true for the same models:deepseek32,deepseek4,glm_dsa,dots3note,mistral_large4.No behavior change.
Additional information
deepseek41inherits fromdeepseek4but was not in the list, so it overrideslid_k_hdmd()back to false. Its indexer KV cache does pass the size check, so this may be an omission from when DeepSeek4.1 was added. If so, the fix is to delete that override; I left that for a separate change.Checked the same way as #32648: with the old list kept next to the new code and an assert on equality,
test-llama-archson CPU passed for all architectures it runs (593 KV caches across 142 architectures).Requirements