atlas_core/config/
factory.rs

1// SPDX-License-Identifier: AGPL-3.0-only
2
3//! Hard-coded model factories. Split out of `config.rs` for file-size budget.
4
5#![allow(unused_imports)]
6
7use super::{LayerType, ModelConfig, QuantizationConfig};
8
9impl ModelConfig {
10    pub fn qwen3_next_80b_nvfp4() -> Self {
11        Self {
12            profile: false,
13            hidden_size: 2048,
14            num_hidden_layers: 48,
15            intermediate_size: 5120,
16            vocab_size: 151936,
17            num_attention_heads: 16,
18            num_attention_heads_per_layer: Vec::new(),
19            num_key_value_heads: 2,
20            head_dim: 256,
21            partial_rotary_factor: 0.25,
22            linear_num_key_heads: 16,
23            linear_key_head_dim: 128,
24            linear_num_value_heads: 32,
25            linear_value_head_dim: 128,
26            linear_conv_kernel_dim: 4,
27            num_experts: 512,
28            num_experts_per_tok: 10,
29            moe_intermediate_size: 512,
30            shared_expert_intermediate_size: 512,
31            norm_topk_prob: true,
32            decoder_sparse_step: 1,
33            layer_types: {
34                let mut types = Vec::with_capacity(48);
35                for i in 0..48 {
36                    if (i + 1) % 4 == 0 {
37                        types.push(LayerType::FullAttention);
38                    } else {
39                        types.push(LayerType::LinearAttention);
40                    }
41                }
42                types
43            },
44            mtp_layer_types: Vec::new(),
45            full_attention_interval: 4,
46            sliding_window: 0,
47            max_position_embeddings: 262144,
48            rope_theta: 10_000_000.0,
49            rms_norm_eps: 1e-6,
50            bos_token_id: 151643,
51            glm5next_router_mode: crate::config::Glm5NextRouterMode::HfFp32,
52            eos_token_id: 151645,
53            // Empty = not populated; read through `eos_ids()`, which falls back to the scalar.
54            eos_token_ids: Vec::new(),
55            tie_word_embeddings: false,
56            lm_head_bf16_override: None,
57            lm_head_fp8: false,
58            model_type: "qwen3_next".to_string(),
59            mtp_num_hidden_layers: 1,
60            dspark_block_size: 0,
61            dspark_noise_token_id: 0,
62            dspark_target_layer_ids: Vec::new(),
63            dspark_markov_rank: 0,
64            weight_prefix: String::new(),
65            ep_rank: 0,
66            ep_world_size: 1,
67            tp_rank: 0,
68            tp_world_size: 1,
69            serve_max_seq_len: 0,
70            hybrid_override_pattern: String::new(),
71            mamba_num_heads: 0,
72            mamba_head_dim: 0,
73            ssm_state_size: 0,
74            n_groups: 0,
75            expand: 0,
76            n_routed_experts: 0,
77            norm_eps: 0.0,
78            conv_kernel: 0,
79            moe_shared_expert_intermediate_size: 0,
80            routed_scaling_factor: 1.0,
81            linear_gate_lower_bound: 0.0,
82            // 0.0 = no SwiGLU clamp. The glm5_next parser refuses to leave it here.
83            swiglu_limit: 0.0,
84            mlp_only_layers: Vec::new(),
85            moe_latent_size: 0,
86            moe_intermediate_sizes: Vec::new(),
87            num_experts_per_toks: Vec::new(),
88            vision: None,
89            quantization_config: None,
90            attn_gated: true,
91            gdn_norm_sigmoid: false,
92            nested_config: false,
93            mrope_section: [0, 0, 0],
94            mrope_interleaved: false,
95            kv_lora_rank: 0,
96            zero_expert_num: 0,
97            ngram_vocab_size_ratio: 0,
98            emb_neighbor_num: 0,
99            emb_split_num: 0,
100            ngram_vocab_size_base: 0,
101            ngram_split_parts: 0,
102            ple_layer_ids: Vec::new(),
103            ple_conv_kernel_size: 0,
104            kv_layer_dims: Vec::new(),
105            q_lora_rank: 0,
106            qk_nope_head_dim: 0,
107            qk_rope_head_dim: 0,
108            v_head_dim: 0,
109            o_lora_rank: 0,
110            o_groups: 0,
111            yarn_mscale: 1.0,
112            yarn_mscale_all_dim: 0.0,
113            hc_mult: 0,
114            hc_sinkhorn_iters: 0,
115            hc_lowrank: 0,
116            final_norm_identity: false,
117            hc_eps: 1e-6,
118            compress_ratios: Vec::new(),
119            index_compress_ratio: 0,
120            index_n_heads: 0,
121            index_head_dim: 0,
122            index_topk: 0,
123            index_kpool: 0,
124            index_kpool_always_select_tail: false,
125            num_hash_layers: 0,
126            yarn_factor: 0.0,
127            yarn_beta_slow: 0.0,
128            yarn_beta_fast: 0.0,
129            yarn_original_max_position_embeddings: 0,
130            yarn_attention_factor: 1.0,
131            llama_4_scaling_beta: 0.0,
132            llama_4_scaling_original_max_position_embeddings: 0,
133            fp8_kv_calibration_tokens: 0,
134            fp8_kv_headroom: 2.0,
135            final_logit_softcapping: 0.0,
136            embed_scale: 0.0,
137            // MiniMax M2 fields — all default to "unused" (empty/0) so the
138            // base Qwen3-Next-80B template behaves identically to before.
139            scoring_func: String::new(),
140            use_routing_bias: false,
141            qk_norm_type: String::new(),
142            num_mtp_modules: 0,
143            mtp_transformer_layers: 0,
144            rotary_dim: 0,
145            dflash_capture_layers: Vec::new(),
146            dflash_gamma: None,
147            adapter_max_rank: 0,
148        }
149    }
150}