| 315 | layer.lazy_initialization(fake_k, fake_v) |
| 316 | |
| 317 | def get_seq_length(self, layer_idx: int = 0) -> int | torch.Tensor: |
| 318 | if layer_idx >= len(self._layers): |
| 319 | return 0 |
| 320 | length = self._layers[layer_idx].get_seq_length() |
| 321 | if isinstance(length, torch.Tensor) and length.dim() == 1: |
| 322 | # Transformer decoder implementations use one scalar past length |
| 323 | # to build the causal mask. Continuous batching keeps rows aligned |
| 324 | # to a shared physical position, so the largest row is sufficient. |
| 325 | return length.max() |
| 326 | return length |
| 327 | |
| 328 | def get_max_cache_shape(self, layer_idx: int = 0) -> int: |
| 329 | if layer_idx >= len(self._layers): |