Lightning indexer

Index key cache

×

state · kept between calls

The indexer key of every position so far, kept between forward calls.

shape
k~I\tilde k^{I} k_I [B batch, 1001 cached positions, 128 index d_h]

This call hands the new key to the cache and scores the new query against every cached key. 128 features per position.

Sources

In codepast_key_values.update_indexer(k, self.layer_idx)

Open pinned code ↗

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