@@ -37,6 +37,9 @@ struct llama_hparams_convnext {
3737};
3838
3939struct llama_hparams {
40+ // note: use the `_impl` suffix to avoid name conflict between members and getters
41+ // for example: n_embd_out() vs n_embd_out_impl
42+
4043 bool vocab_only;
4144 bool no_alloc;
4245 bool rope_finetuned;
@@ -46,7 +49,7 @@ struct llama_hparams {
4649 uint32_t n_ctx_train; // context size the model was trained on
4750 uint32_t n_embd;
4851 uint32_t n_layer;
49- int32_t n_layer_kv_from_start = -1 ; // if non-negative, the first n_layer_kv_from_start layers have KV cache
52+ int32_t n_layer_kv_from_start = -1 ; // if non-negative, the first n_layer_kv_from_start layers have KV cache
5053 uint32_t n_expert = 0 ;
5154 uint32_t n_expert_used = 0 ;
5255 uint32_t n_rel_attn_bkts = 0 ;
@@ -137,12 +140,16 @@ struct llama_hparams {
137140 llama_swa_type swa_type = LLAMA_SWA_TYPE_NONE ;
138141 // the size of the sliding window (0 - no SWA)
139142 uint32_t n_swa = 0 ;
143+
140144 // if is_swa_impl[il] == 1, then layer il is SWA
141145 // if is_swa_impl[il] == 0, then layer il is dense (i.e. non-SWA)
142146 // by default, all layers are dense
143147 // note: using uint32_t type for compatibility reason
144148 std::array<uint32_t , LLAMA_MAX_LAYERS > is_swa_impl;
145149
150+ // for hybrid state space models
151+ std::array<uint32_t , LLAMA_MAX_LAYERS > is_recr_impl;
152+
146153 // for State Space Models
147154 uint32_t ssm_d_conv = 0 ;
148155 uint32_t ssm_d_inner = 0 ;
@@ -153,9 +160,6 @@ struct llama_hparams {
153160 // for Kimi Linear KDA
154161 uint32_t n_embd_head_kda = 0 ;
155162
156- // for hybrid state space models
157- std::array<uint32_t , LLAMA_MAX_LAYERS > is_recr_impl;
158-
159163 bool ssm_dt_b_c_rms = false ;
160164
161165 float f_clamp_kqv = 0 .0f ;
@@ -266,6 +270,14 @@ struct llama_hparams {
266270 // return true if one of the layers is SWA
267271 bool is_swa_any () const ;
268272
273+ bool is_swa (uint32_t il) const ;
274+
275+ // TODO: implement
276+ // void set_recr_pattern(uint32_t n_pattern, bool dense_first = false);
277+
278+ // whether or not the given layer is recurrent (for hybrid models)
279+ bool is_recr (uint32_t il) const ;
280+
269281 uint32_t n_head (uint32_t il = 0 ) const ;
270282
271283 uint32_t n_head_kv (uint32_t il = 0 ) const ;
@@ -307,13 +319,8 @@ struct llama_hparams {
307319 // dimension of the recurrent state embeddings
308320 uint32_t n_embd_s () const ;
309321
310- // whether or not the given layer is recurrent (for hybrid models)
311- bool is_recurrent (uint32_t il) const ;
312-
313322 uint32_t n_pos_per_embd () const ;
314323
315- bool is_swa (uint32_t il) const ;
316-
317324 // note: currently only support if either all or none of the layers are MLA
318325 bool is_mla () const ;
319326
0 commit comments