Get the number of parameters in the attention linear layers, including the query/key/value projection and output matrices. Returns: int: the number of parameters in the attention linear layers
(self)
| 259 | return num_params_input_embedding + num_params_output_embedding |
| 260 | |
| 261 | def get_num_params_per_layer_attn(self) -> int: |
| 262 | """Get the number of parameters in the attention linear layers, including the |
| 263 | query/key/value projection and output matrices. |
| 264 | |
| 265 | Returns: |
| 266 | int: the number of parameters in the attention linear layers |
| 267 | """ |
| 268 | num_heads_per_gpu = max( |
| 269 | self.model_config.num_key_value_heads / |
| 270 | self.parallelism_config.tp_size, |
| 271 | 1) # At least on attention head on each tensor-parallel GPU |
| 272 | num_key_value_heads = num_heads_per_gpu * self.parallelism_config.tp_size |
| 273 | |
| 274 | return 2 * self.model_config.hidden_dim**2 + 2 * self.model_config.hidden_dim * ( |
| 275 | self.model_config.hidden_dim * num_key_value_heads / |
| 276 | self.model_config.n_head) |
| 277 | |
| 278 | def get_num_params_per_layer_mlp(self) -> int: |
| 279 | """Get the number of parameters in the MLP linear layers, including the |
no outgoing calls
no test coverage detected