(self, query_length: int, layer_idx: int = 0)
| 474 | return offset |
| 475 | |
| 476 | def get_mask_sizes(self, query_length: int, layer_idx: int = 0) -> tuple[int, int]: |
| 477 | # HF convention: mask builders sample shared masks with the default |
| 478 | # layer_idx, which on hybrid models may land on a linear-attention |
| 479 | # slot; redirect such queries to the first attention slot so the |
| 480 | # shared mask gets attention-sized spans. |
| 481 | if layer_idx < len(self._layers) and isinstance(self._layers[layer_idx], DSStaticGDNSlot): |
| 482 | first = self._first_attention_idx() |
| 483 | if first is None: |
| 484 | return query_length, 0 |
| 485 | return self._layers[first].get_mask_sizes(query_length) |
| 486 | if layer_idx >= len(self._layers): |
| 487 | return query_length, 0 |
| 488 | return self._layers[layer_idx].get_mask_sizes(query_length) |
| 489 | |
| 490 | def reset(self): |
| 491 | for layer in self._layers: |
nothing calls this directly
no test coverage detected