Index key cache
×state · kept between calls
The indexer key of every position so far, kept between forward calls.
- shape
- k_I [B batch, T cached positions, 128 index d_h]
Prefill hands the prompt’s keys to the cache and scores against them. 128 features per position.
Sources
In codepast_key_values.update_indexer(k, self.layer_idx)
Contextual evidence
The indexer hands its key to the cache and scores its queries against every cached key so far; only a layer that runs an indexer calls this, so a shared layer’s cache holds no indexer keys.
modeling_glm_moe_dsa.py 225–228 ↗ · huggingface/transformers @ c4c4605f9618
Excerpt
if past_key_values is not None:
k = past_key_values.update_indexer(k, self.layer_idx)
scores = torch.matmul(q.float(), k.transpose(-1, -2).float().unsqueeze(1)) * self.softmax_scale