| 373 | layer._trim_left(count) |
| 374 | |
| 375 | def update( |
| 376 | self, |
| 377 | key_states: torch.Tensor, |
| 378 | value_states: torch.Tensor, |
| 379 | layer_idx: int, |
| 380 | *args, |
| 381 | **kwargs, |
| 382 | ) -> tuple[torch.Tensor, torch.Tensor]: |
| 383 | if layer_idx >= len(self._layers): |
| 384 | raise IndexError(f"layer_idx {layer_idx} out of range (cache has {len(self._layers)} layers)") |
| 385 | layer = self._layers[layer_idx] |
| 386 | if isinstance(layer, DSStaticGDNSlot): |
| 387 | raise TypeError("linear-attention slots manage conv/recurrent state, not key/value pairs") |
| 388 | return layer.update(key_states, value_states, *args, **kwargs) |
| 389 | |
| 390 | def early_initialization( |
| 391 | self, |