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)
| 141 | |
| 142 | |
| 143 | def _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 | |
| 161 | def _standard_head_dim(text_config, num_attention_heads: int): |
no outgoing calls
no test coverage detected