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

Function _classify_leaf

deepspeed/__init__.py:143–158  ·  view source on GitHub ↗

Which kind of attention matrix this leaf name claims to be, or None if it claims none. A name is a claim, not a layout. What the leaf resolves to is decided later, by the shape.

(leaf: str)

Source from the content-addressed store, hash-verified

141
142
143def _classify_leaf(leaf: str):
144 """Which kind of attention matrix this leaf name claims to be, or None if it claims none.
145
146 A name is a claim, not a layout. What the leaf resolves to is decided later, by the shape.
147 """
148 if any(leaf.startswith(k) for k in _FUSED_QKV_LEAVES) or any(leaf.startswith(k) for k in _MLA_DOWN_LEAVES):
149 return NOT_HEAD_BLOCKED
150 if any(leaf.startswith(k) for k in _MLA_Q_LEAVES):
151 return MLA_Q
152 if any(leaf.startswith(k) for k in _MLA_KV_LEAVES):
153 return MLA_KV
154 if any(leaf.startswith(k) for k in _KV_HEAD_LEAVES):
155 return KV
156 if any(leaf.startswith(k) for k in _QUERY_HEAD_LEAVES):
157 return QUERY
158 return None
159
160
161def _standard_head_dim(text_config, num_attention_heads: int):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected