metrale_config/
factory.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! 2026-09-26: `ModelConfig::qwen3_next_80b_nvfp4`, a hard-coded Qwen3-Next-80B config. The
4//! m2m_100, gemma4 and mistral parsers start from it and overwrite fields.
5//!
6//! Owner: config.
7//! Invariants: none beyond the types.
8
9#![allow(unused_imports)]
10
11use super::{LayerType, ModelConfig, QuantizationConfig};
12
13impl ModelConfig {
14    pub fn qwen3_next_80b_nvfp4() -> Self {
15        Self {
16            profile: false,
17            hidden_size: 2048,
18            num_hidden_layers: 48,
19            intermediate_size: 5120,
20            vocab_size: 151936,
21            num_attention_heads: 16,
22            num_attention_heads_per_layer: Vec::new(),
23            num_key_value_heads: 2,
24            head_dim: 256,
25            partial_rotary_factor: 0.25,
26            linear_num_key_heads: 16,
27            linear_key_head_dim: 128,
28            linear_num_value_heads: 32,
29            linear_value_head_dim: 128,
30            linear_conv_kernel_dim: 4,
31            num_experts: 512,
32            num_experts_per_tok: 10,
33            moe_intermediate_size: 512,
34            shared_expert_intermediate_size: 512,
35            norm_topk_prob: true,
36            decoder_sparse_step: 1,
37            layer_types: {
38                let mut types = Vec::with_capacity(48);
39                for i in 0..48 {
40                    if (i + 1) % 4 == 0 {
41                        types.push(LayerType::FullAttention);
42                    } else {
43                        types.push(LayerType::LinearAttention);
44                    }
45                }
46                types
47            },
48            mtp_layer_types: Vec::new(),
49            full_attention_interval: 4,
50            sliding_window: 0,
51            max_position_embeddings: 262144,
52            rope_theta: 10_000_000.0,
53            rms_norm_eps: 1e-6,
54            bos_token_id: 151643,
55            glm5next_router_mode: crate::Glm5NextRouterMode::HfFp32,
56            eos_token_id: 151645,
57            // 2026-09-26: Empty means not populated; `eos_ids()` then falls back to the scalar.
58            eos_token_ids: Vec::new(),
59            tie_word_embeddings: false,
60            lm_head_bf16_override: None,
61            lm_head_fp8: false,
62            model_type: "qwen3_next".to_string(),
63            mtp_num_hidden_layers: 1,
64            dspark_block_size: 0,
65            dspark_noise_token_id: 0,
66            dspark_target_layer_ids: Vec::new(),
67            dspark_markov_rank: 0,
68            weight_prefix: String::new(),
69            ep_rank: 0,
70            ep_world_size: 1,
71            tp_rank: 0,
72            tp_world_size: 1,
73            serve_max_seq_len: 0,
74            hybrid_override_pattern: String::new(),
75            mamba_num_heads: 0,
76            mamba_head_dim: 0,
77            ssm_state_size: 0,
78            n_groups: 0,
79            expand: 0,
80            n_routed_experts: 0,
81            norm_eps: 0.0,
82            conv_kernel: 0,
83            moe_shared_expert_intermediate_size: 0,
84            routed_scaling_factor: 1.0,
85            linear_gate_lower_bound: 0.0,
86            // 2026-09-26: 0.0 means no SwiGLU clamp. The glm5_next parser refuses a config
87            // without a positive one.
88            swiglu_limit: 0.0,
89            mlp_only_layers: Vec::new(),
90            moe_latent_size: 0,
91            moe_intermediate_sizes: Vec::new(),
92            num_experts_per_toks: Vec::new(),
93            vision: None,
94            quantization_config: None,
95            attn_gated: true,
96            gdn_norm_sigmoid: false,
97            nested_config: false,
98            mrope_section: [0, 0, 0],
99            mrope_interleaved: false,
100            kv_lora_rank: 0,
101            zero_expert_num: 0,
102            ngram_vocab_size_ratio: 0,
103            emb_neighbor_num: 0,
104            emb_split_num: 0,
105            ngram_vocab_size_base: 0,
106            ngram_split_parts: 0,
107            ple_layer_ids: Vec::new(),
108            ple_conv_kernel_size: 0,
109            kv_layer_dims: Vec::new(),
110            q_lora_rank: 0,
111            qk_nope_head_dim: 0,
112            qk_rope_head_dim: 0,
113            v_head_dim: 0,
114            o_lora_rank: 0,
115            o_groups: 0,
116            yarn_mscale: 1.0,
117            yarn_mscale_all_dim: 0.0,
118            hc_mult: 0,
119            hc_sinkhorn_iters: 0,
120            hc_lowrank: 0,
121            final_norm_identity: false,
122            hc_eps: 1e-6,
123            compress_ratios: Vec::new(),
124            index_compress_ratio: 0,
125            index_n_heads: 0,
126            index_head_dim: 0,
127            index_topk: 0,
128            index_kpool: 0,
129            index_kpool_always_select_tail: false,
130            num_hash_layers: 0,
131            yarn_factor: 0.0,
132            yarn_beta_slow: 0.0,
133            yarn_beta_fast: 0.0,
134            yarn_original_max_position_embeddings: 0,
135            yarn_attention_factor: 1.0,
136            llama_4_scaling_beta: 0.0,
137            llama_4_scaling_original_max_position_embeddings: 0,
138            fp8_kv_calibration_tokens: 0,
139            fp8_kv_headroom: 2.0,
140            final_logit_softcapping: 0.0,
141            embed_scale: 0.0,
142            scoring_func: String::new(),
143            use_routing_bias: false,
144            qk_norm_type: String::new(),
145            num_mtp_modules: 0,
146            mtp_transformer_layers: 0,
147            rotary_dim: 0,
148            attn_position_encoding: Some(super::AttnPositionEncoding::Rope),
149            dflash_capture_layers: Vec::new(),
150            dflash_gamma: None,
151            adapter_max_rank: 0,
152            compress_rope_theta: 0.0,
153            kv_source_layer_ids: Vec::new(),
154            index_source_layer_ids: Vec::new(),
155            candidate_source_layer_id: None,
156            candidate_topk_blocks: 0,
157            candidate_block_size: 0,
158            engram_layer_ids: Vec::new(),
159            engram_num_embeddings: Vec::new(),
160            engram_max_ngram_size: 0,
161            engram_vocab_size: 0,
162            engram_n_heads: 0,
163            engram_head_dim: 0,
164            engram_pad_token_id: 0,
165            engram_compressed_vocab_size: 0,
166            engram_multipliers: Vec::new(),
167            engram_primes: Vec::new(),
168            engram_offsets: Vec::new(),
169            attn_res_block_size: 0,
170            use_full_rank_gate: false,
171            mla_use_nope: false,
172            mla_use_output_gate: false,
173            latent_moe_use_norm: false,
174            hidden_act: String::new(),
175            activation_situ_beta: 0.0,
176            activation_situ_linear_beta: 0.0,
177            n_shared_experts: 0,
178        }
179    }
180}