| 153 | } |
| 154 | |
| 155 | uint32_t llama_hparams::n_embd_r() const { |
| 156 | if (dsv4_state_size != 0) { |
| 157 | return dsv4_state_size; |
| 158 | } |
| 159 | |
| 160 | if (wkv_head_size != 0) { |
| 161 | // for RWKV models |
| 162 | return token_shift_count * n_embd; |
| 163 | } |
| 164 | |
| 165 | if (n_shortconv_l_cache != 0) { |
| 166 | // for LFM2 models |
| 167 | return n_embd * (n_shortconv_l_cache - 1); |
| 168 | } |
| 169 | |
| 170 | if (n_embd_head_kda != 0) { |
| 171 | // for Kimi KDA layers |
| 172 | // Conv state for Q, K, V: 3 * (d_conv - 1) * n_head * head_dim |
| 173 | const uint32_t d_inner = n_head() * n_embd_head_kda; // 32 * 128 = 4096 |
| 174 | return 3 * (ssm_d_conv > 0 ? ssm_d_conv - 1 : 3) * d_inner; |
| 175 | } |
| 176 | |
| 177 | // TODO: maybe support other convolution strides than 1 |
| 178 | // NOTE: since the first column of the conv_state is shifted out each time, it's not actually needed |
| 179 | // Corresponds to Mamba's conv_states size |
| 180 | return (ssm_d_conv > 0 ? ssm_d_conv - 1 : 0) * (ssm_d_inner + 2*ssm_n_group*ssm_d_state); |
| 181 | } |
| 182 | |
| 183 | uint32_t llama_hparams::n_embd_s() const { |
| 184 | if (dsv4_state_size != 0) { |
no outgoing calls
no test coverage detected