Minimum bytes transferred for fused matmul+sampling (read W + read X + write indices).
(vocab_size: int, hidden_size: int, n_hidden_states: float)
| 234 | |
| 235 | |
| 236 | def model_bytes(vocab_size: int, hidden_size: int, n_hidden_states: float) -> float: |
| 237 | """Minimum bytes transferred for fused matmul+sampling (read W + read X + write indices).""" |
| 238 | H = int(n_hidden_states) # noqa: N806 |
| 239 | return ( |
| 240 | vocab_size * hidden_size * BYTES_PER_ELEMENT # read weights [V, D] |
| 241 | + H * hidden_size * BYTES_PER_ELEMENT # read hidden_states [H, D] |
| 242 | + H * BYTES_PER_INDEX # write sampled indices [H] |
| 243 | ) |
| 244 | |
| 245 | |
| 246 | def model_flops(vocab_size: int, hidden_size: int, n_hidden_states: float) -> float: |
no outgoing calls
no test coverage detected