(i, precision, model_type=None, skip_kv=False)
| 190 | |
| 191 | |
| 192 | def get_layer_weight_patterns(i, precision, model_type=None, skip_kv=False): |
| 193 | is_whisper = model_type == 'whisper' |
| 194 | is_qwen_family = isinstance(model_type, str) and ('qwen' in model_type) |
| 195 | is_youtu = model_type == 'youtu' |
| 196 | |
| 197 | patterns = [ |
| 198 | # Youtu MLA attention weights |
| 199 | (['self_attn.q_a_proj.weight'], precision, f'layer_{i}_attn_q_a.weights', False) if is_youtu else None, |
| 200 | (['self_attn.q_a_layernorm.weight'], precision, f'layer_{i}_attn_q_a_norm.weights', False) if is_youtu else None, |
| 201 | (['self_attn.q_b_proj.weight'], precision, f'layer_{i}_attn_q_b.weights', False) if is_youtu else None, |
| 202 | (['self_attn.kv_a_proj_with_mqa.weight'], precision, f'layer_{i}_attn_kv_a.weights', False) if is_youtu else None, |
| 203 | (['self_attn.kv_a_layernorm.weight'], precision, f'layer_{i}_attn_kv_a_norm.weights', False) if is_youtu else None, |
| 204 | (['self_attn.kv_b_proj.weight'], precision, f'layer_{i}_attn_kv_b.weights', False) if is_youtu else None, |
| 205 | (['self_attn.q_proj.weight', 'attn.q_proj.weight', 'attn.c_attn.weight'], precision, f'layer_{i}_attn_q.weights', False) if not is_whisper and not is_youtu else None, |
| 206 | (['self_attn.k_proj.weight', 'attn.k_proj.weight'], precision, f'layer_{i}_attn_k.weights', False) if not is_whisper and not skip_kv and not is_youtu else None, |
| 207 | (['self_attn.v_proj.weight', 'attn.v_proj.weight'], precision, f'layer_{i}_attn_v.weights', False) if not is_whisper and not skip_kv and not is_youtu else None, |
| 208 | (['self_attn.o_proj.weight', 'attn.o_proj.weight', 'attn.c_proj.weight', 'self_attn.out_proj.weight'], precision, f'layer_{i}_attn_output.weights', False) if not is_whisper else None, |
| 209 | # Qwen3.5 linear-attention path |
| 210 | (['linear_attn.in_proj_qkv.weight'], precision, f'layer_{i}_linear_attn_qkv.weights', False) if is_qwen_family else None, |
| 211 | (['linear_attn.in_proj_a.weight'], precision, f'layer_{i}_linear_attn_a.weights', False) if is_qwen_family else None, |
| 212 | (['linear_attn.in_proj_b.weight'], precision, f'layer_{i}_linear_attn_b.weights', False) if is_qwen_family else None, |
| 213 | (['linear_attn.in_proj_z.weight'], precision, f'layer_{i}_linear_attn_z.weights', False) if is_qwen_family else None, |
| 214 | (['linear_attn.out_proj.weight'], precision, f'layer_{i}_linear_attn_output.weights', False) if is_qwen_family else None, |
| 215 | (['linear_attn.norm.weight'], precision, f'layer_{i}_linear_attn_norm.weights', False) if is_qwen_family else None, |
| 216 | (['linear_attn.conv1d.weight'], precision, f'layer_{i}_linear_attn_conv1d.weights', False) if is_qwen_family else None, |
| 217 | (['linear_attn.A_log'], precision, f'layer_{i}_linear_attn_A_log.weights', False) if is_qwen_family else None, |
| 218 | (['linear_attn.dt_bias'], precision, f'layer_{i}_linear_attn_dt_bias.weights', False) if is_qwen_family else None, |
| 219 | ([ |
| 220 | 'self_attn.deltanet_gate_proj.weight', |
| 221 | 'self_attn.gated_deltanet_gate_proj.weight', |
| 222 | 'self_attn.attn_gate_proj.weight', |
| 223 | 'self_attn.f_gate_proj.weight', |
| 224 | 'self_attn.attn_f_gate_proj.weight', |
| 225 | 'self_attn.attn_gate.weight', |
| 226 | 'self_attn.attn_f_gate.weight', |
| 227 | ], precision, f'layer_{i}_deltanet_gate.weights', False) if is_qwen_family else None, |
| 228 | ([ |
| 229 | 'self_attn.deltanet_beta_proj.weight', |
| 230 | 'self_attn.gated_deltanet_beta_proj.weight', |
| 231 | 'self_attn.attn_beta_proj.weight', |
| 232 | 'self_attn.f_beta_proj.weight', |
| 233 | 'self_attn.attn_f_beta_proj.weight', |
| 234 | 'self_attn.attn_beta.weight', |
| 235 | 'self_attn.attn_f_beta.weight', |
| 236 | ], precision, f'layer_{i}_deltanet_beta.weights', False) if is_qwen_family else None, |
| 237 | (['input_layernorm.weight', 'ln_1.weight', 'operator_norm.weight'], precision, f'layer_{i}_input_norm.weights', False), |
| 238 | (['self_attn.q_norm.weight', 'self_attn.q_layernorm.weight'], precision, f'layer_{i}_attn_q_norm.weights', False), |
| 239 | (['self_attn.k_norm.weight', 'self_attn.k_layernorm.weight'], precision, f'layer_{i}_attn_k_norm.weights', False) if not skip_kv else None, |
| 240 | (['mlp.gate_proj.weight', 'mlp.c_fc.weight', 'feed_forward.w1.weight', 'ff.ff_proj.weight'], precision, f'layer_{i}_ffn_gate.weights', False), |
| 241 | (['mlp.up_proj.weight', 'feed_forward.w3.weight', 'ff.ff_noact.weight'], precision, f'layer_{i}_ffn_up.weights', False), |
| 242 | (['mlp.down_proj.weight', 'mlp.c_proj.weight', 'feed_forward.w2.weight', 'ff.ff_out.weight'], precision, f'layer_{i}_ffn_down.weights', False), |
| 243 | (['feed_forward.gate.weight'], precision, f'layer_{i}_moe_router.weights', False), |
| 244 | (['feed_forward.expert_bias'], precision, f'layer_{i}_moe_expert_bias.weights', False), |
| 245 | (['feed_forward.experts.{channel}.w1.weight'], precision, f'layer_{i}_moe_expert_{{channel}}_w1.weights', False), |
| 246 | (['feed_forward.experts.{channel}.w3.weight'], precision, f'layer_{i}_moe_expert_{{channel}}_w3.weights', False), |
| 247 | (['feed_forward.experts.{channel}.w2.weight'], precision, f'layer_{i}_moe_expert_{{channel}}_w2.weights', False), |
| 248 | (['moe.gate_proj'], precision, f'layer_{i}_moe_gate_proj.weights', False), |
| 249 | (['moe.up_proj'], precision, f'layer_{i}_moe_up_proj.weights', False), |
no outgoing calls
no test coverage detected