MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / get_mask_sizes

Method get_mask_sizes

deepspeed/utils/static_cache.py:476–488  ·  view source on GitHub ↗
(self, query_length: int, layer_idx: int = 0)

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 2

_first_attention_idxMethod · 0.95
get_mask_sizesMethod · 0.45

Tested by

no test coverage detected