dav1dliu commited on
Commit
c351bbc
·
verified ·
1 Parent(s): db2f44c

Init Commit

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. README.md +57 -0
  3. added_tokens.json +29 -0
  4. chat_template.jinja +85 -0
  5. config.json +43 -0
  6. configuration_sdar_moe.py +243 -0
  7. generation_config.json +13 -0
  8. layer-0-ep-0-of-1.safetensors +3 -0
  9. layer-1-ep-0-of-1.safetensors +3 -0
  10. layer-10-ep-0-of-1.safetensors +3 -0
  11. layer-11-ep-0-of-1.safetensors +3 -0
  12. layer-12-ep-0-of-1.safetensors +3 -0
  13. layer-13-ep-0-of-1.safetensors +3 -0
  14. layer-14-ep-0-of-1.safetensors +3 -0
  15. layer-15-ep-0-of-1.safetensors +3 -0
  16. layer-16-ep-0-of-1.safetensors +3 -0
  17. layer-17-ep-0-of-1.safetensors +3 -0
  18. layer-18-ep-0-of-1.safetensors +3 -0
  19. layer-19-ep-0-of-1.safetensors +3 -0
  20. layer-2-ep-0-of-1.safetensors +3 -0
  21. layer-20-ep-0-of-1.safetensors +3 -0
  22. layer-21-ep-0-of-1.safetensors +3 -0
  23. layer-22-ep-0-of-1.safetensors +3 -0
  24. layer-23-ep-0-of-1.safetensors +3 -0
  25. layer-24-ep-0-of-1.safetensors +3 -0
  26. layer-25-ep-0-of-1.safetensors +3 -0
  27. layer-26-ep-0-of-1.safetensors +3 -0
  28. layer-27-ep-0-of-1.safetensors +3 -0
  29. layer-28-ep-0-of-1.safetensors +3 -0
  30. layer-29-ep-0-of-1.safetensors +3 -0
  31. layer-3-ep-0-of-1.safetensors +3 -0
  32. layer-30-ep-0-of-1.safetensors +3 -0
  33. layer-31-ep-0-of-1.safetensors +3 -0
  34. layer-32-ep-0-of-1.safetensors +3 -0
  35. layer-33-ep-0-of-1.safetensors +3 -0
  36. layer-34-ep-0-of-1.safetensors +3 -0
  37. layer-35-ep-0-of-1.safetensors +3 -0
  38. layer-36-ep-0-of-1.safetensors +3 -0
  39. layer-37-ep-0-of-1.safetensors +3 -0
  40. layer-38-ep-0-of-1.safetensors +3 -0
  41. layer-39-ep-0-of-1.safetensors +3 -0
  42. layer-4-ep-0-of-1.safetensors +3 -0
  43. layer-40-ep-0-of-1.safetensors +3 -0
  44. layer-41-ep-0-of-1.safetensors +3 -0
  45. layer-42-ep-0-of-1.safetensors +3 -0
  46. layer-43-ep-0-of-1.safetensors +3 -0
  47. layer-44-ep-0-of-1.safetensors +3 -0
  48. layer-45-ep-0-of-1.safetensors +3 -0
  49. layer-46-ep-0-of-1.safetensors +3 -0
  50. layer-47-ep-0-of-1.safetensors +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ ---
5
+
6
+ # SDAR
7
+
8
+ <div align="center">
9
+ <img src="https://raw.githubusercontent.com/JetAstra/SDAR/main/assets/SDAR_doc_head.png">
10
+
11
+
12
+ <div>&nbsp;</div>
13
+
14
+ [💻Github Repo](https://github.com/JetAstra/SDAR) • [🤗Model Collections](https://huggingface.co/collections/JetLM/sdar-689b1b6d392a4eeb2664f8ff)
15
+
16
+ </div>
17
+
18
+ # Introduction
19
+
20
+ **SDAR** (**S**ynergy of **D**iffusion and **A**uto**R**egression) model is a new large language model that integrates autoregressive (AR) and discrete diffusion modeling strategies. It combines the efficient training paradigm of AR models with the highly parallel inference capability of diffusion models, while delivering performance fully on par with SOTA open-source AR models. At the same time, SDAR sets a new benchmark as the most powerful diffusion language model to date. We highlight three major conclusions from our study:
21
+
22
+ > [!IMPORTANT]
23
+ > Take-home message
24
+ >
25
+ > - **Balanced Efficiency:** SDAR unifies the **efficient training** of AR models with the **parallel inference** of diffusion, achieving both fast training and inference.
26
+ > - **Fair Comparisons:** In rigorously controlled experiments, SDAR achieves **on-par general task performance** with strong AR baselines, ensuring credibility and reproducibility.
27
+ > - **Superior Learning Efficiency:** On complex scientific reasoning tasks (e.g., GPQA, ChemBench, Physics), SDAR shows **clear gains over AR models** of the same scale, approaching or even exceeding leading closed-source systems.
28
+
29
+ # Performance
30
+
31
+ ### SDAR v.s. Qwen
32
+
33
+ For **SDAR** models, inference hyperparameters are set to: `block_length = 4`, `denoising_steps = 4`, greedy decoding.
34
+
35
+ For **Qwen3-1.7B-AR-SFT** and **Qwen3-30B-AR-SFT**, we use *greedy decoding*, and the base models **Qwen3-1.7B-Base** and **Qwen3-30B-Base** are derived from the [Qwen3 Technical Report](https://arxiv.org/abs/2505.09388).
36
+
37
+ <p align="center">
38
+ <img src="https://raw.githubusercontent.com/JetAstra/SDAR/main/assets/table1.png" style="max-width:80%; height:auto;">
39
+ <p align="center">
40
+
41
+ ### SDAR-Sci v.s. AR Baseline
42
+
43
+ This table presents a **controlled comparison** between AR and SDAR under the same backbone and dataset settings.
44
+ The results are averaged over 8 runs for GPQA, and over 32 runs each for AIME 2024, AIME 2025, and LiveMathBench.
45
+
46
+ <p align="center">
47
+ <img src="https://raw.githubusercontent.com/JetAstra/SDAR/main/assets/table2.png" style="max-width:80%; height:auto;">
48
+ <p align="center">
49
+
50
+ #### SDAR-Sci v.s. Other Models
51
+
52
+ This table positions **SDAR-30B-A3B-Sci(sample)** against leading open-source and closed-source LLMs.
53
+ Scores for external models are sourced from the [InternLM/Intern-S1](https://github.com/InternLM/Intern-S1) repository.
54
+
55
+ <p align="center">
56
+ <img src="https://raw.githubusercontent.com/JetAstra/SDAR/main/assets/table3.png" style="max-width:80%; height:auto;">
57
+ <p align="center">
added_tokens.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</think>": 151668,
3
+ "</tool_call>": 151658,
4
+ "</tool_response>": 151666,
5
+ "<think>": 151667,
6
+ "<tool_call>": 151657,
7
+ "<tool_response>": 151665,
8
+ "<|MASK|>": 151669,
9
+ "<|box_end|>": 151649,
10
+ "<|box_start|>": 151648,
11
+ "<|endoftext|>": 151643,
12
+ "<|file_sep|>": 151664,
13
+ "<|fim_middle|>": 151660,
14
+ "<|fim_pad|>": 151662,
15
+ "<|fim_prefix|>": 151659,
16
+ "<|fim_suffix|>": 151661,
17
+ "<|im_end|>": 151645,
18
+ "<|im_start|>": 151644,
19
+ "<|image_pad|>": 151655,
20
+ "<|object_ref_end|>": 151647,
21
+ "<|object_ref_start|>": 151646,
22
+ "<|quad_end|>": 151651,
23
+ "<|quad_start|>": 151650,
24
+ "<|repo_name|>": 151663,
25
+ "<|video_pad|>": 151656,
26
+ "<|vision_end|>": 151653,
27
+ "<|vision_pad|>": 151654,
28
+ "<|vision_start|>": 151652
29
+ }
chat_template.jinja ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n\n' }}
5
+ {%- endif %}
6
+ {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
7
+ {%- for tool in tools %}
8
+ {{- "\n" }}
9
+ {{- tool | tojson }}
10
+ {%- endfor %}
11
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
12
+ {%- else %}
13
+ {%- if messages[0].role == 'system' %}
14
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
+ {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
27
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
28
+ {%- elif message.role == "assistant" %}
29
+ {%- set content = message.content %}
30
+ {%- set reasoning_content = '' %}
31
+ {%- if message.reasoning_content is defined and message.reasoning_content is not none %}
32
+ {%- set reasoning_content = message.reasoning_content %}
33
+ {%- else %}
34
+ {%- if '</think>' in message.content %}
35
+ {%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
36
+ {%- set reasoning_content = message.content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
37
+ {%- endif %}
38
+ {%- endif %}
39
+ {%- if loop.index0 > ns.last_query_index %}
40
+ {%- if loop.last or (not loop.last and reasoning_content) %}
41
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
42
+ {%- else %}
43
+ {{- '<|im_start|>' + message.role + '\n' + content }}
44
+ {%- endif %}
45
+ {%- else %}
46
+ {{- '<|im_start|>' + message.role + '\n' + content }}
47
+ {%- endif %}
48
+ {%- if message.tool_calls %}
49
+ {%- for tool_call in message.tool_calls %}
50
+ {%- if (loop.first and content) or (not loop.first) %}
51
+ {{- '\n' }}
52
+ {%- endif %}
53
+ {%- if tool_call.function %}
54
+ {%- set tool_call = tool_call.function %}
55
+ {%- endif %}
56
+ {{- '<tool_call>\n{"name": "' }}
57
+ {{- tool_call.name }}
58
+ {{- '", "arguments": ' }}
59
+ {%- if tool_call.arguments is string %}
60
+ {{- tool_call.arguments }}
61
+ {%- else %}
62
+ {{- tool_call.arguments | tojson }}
63
+ {%- endif %}
64
+ {{- '}\n</tool_call>' }}
65
+ {%- endfor %}
66
+ {%- endif %}
67
+ {{- '<|im_end|>\n' }}
68
+ {%- elif message.role == "tool" %}
69
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
70
+ {{- '<|im_start|>user' }}
71
+ {%- endif %}
72
+ {{- '\n<tool_response>\n' }}
73
+ {{- message.content }}
74
+ {{- '\n</tool_response>' }}
75
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
76
+ {{- '<|im_end|>\n' }}
77
+ {%- endif %}
78
+ {%- endif %}
79
+ {%- endfor %}
80
+ {%- if add_generation_prompt %}
81
+ {{- '<|im_start|>assistant\n' }}
82
+ {%- if enable_thinking is defined and enable_thinking is false %}
83
+ {{- '<think>\n\n</think>\n\n' }}
84
+ {%- endif %}
85
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SDARMoeForCausalLM"
4
+ ],
5
+ "auto_map": {
6
+ "AutoConfig": "configuration_sdar_moe.SDARMoeConfig",
7
+ "AutoModel": "modeling_sdar_moe.SDARMoeModel",
8
+ "AutoModelForCausalLM": "modeling_sdar_moe.SDARMoeForCausalLM"
9
+ },
10
+ "attention_bias": false,
11
+ "attention_dropout": 0.0,
12
+ "bos_token_id": 151643,
13
+ "decoder_sparse_step": 1,
14
+ "eos_token_id": 151643,
15
+ "head_dim": 128,
16
+ "hidden_act": "silu",
17
+ "hidden_size": 2048,
18
+ "initializer_range": 0.02,
19
+ "intermediate_size": 6144,
20
+ "max_position_embeddings": 32768,
21
+ "max_window_layers": 48,
22
+ "mlp_only_layers": [],
23
+ "model_type": "sdar_moe",
24
+ "moe_intermediate_size": 768,
25
+ "norm_topk_prob": true,
26
+ "num_attention_heads": 32,
27
+ "num_experts": 128,
28
+ "num_experts_per_tok": 8,
29
+ "num_hidden_layers": 48,
30
+ "num_key_value_heads": 4,
31
+ "output_router_logits": false,
32
+ "rms_norm_eps": 1e-06,
33
+ "rope_scaling": null,
34
+ "rope_theta": 1000000.0,
35
+ "router_aux_loss_coef": 0.001,
36
+ "sliding_window": null,
37
+ "tie_word_embeddings": false,
38
+ "torch_dtype": "bfloat16",
39
+ "transformers_version": "4.51.0",
40
+ "use_cache": true,
41
+ "use_sliding_window": false,
42
+ "vocab_size": 151936
43
+ }
configuration_sdar_moe.py ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """SDARMoE model configuration"""
16
+
17
+ from transformers.configuration_utils import PretrainedConfig
18
+ from transformers.modeling_rope_utils import rope_config_validation
19
+ from transformers.utils import logging
20
+
21
+
22
+ logger = logging.get_logger(__name__)
23
+
24
+
25
+ class SDARMoeConfig(PretrainedConfig):
26
+ r"""
27
+ This is the configuration class to store the configuration of a [`SDARMoeModel`]. It is used to instantiate a
28
+ SDARMoE model according to the specified arguments, defining the model architecture. Instantiating a configuration
29
+ with the defaults will yield a similar configuration to that of [JetLM/SDAR-1.7B-Chat](https://huggingface.co/JetLM/SDAR-1.7B-Chat).
30
+
31
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
32
+ documentation from [`PretrainedConfig`] for more information.
33
+
34
+
35
+ Args:
36
+ vocab_size (`int`, *optional*, defaults to 151936):
37
+ Vocabulary size of the SDARMoE model. Defines the number of different tokens that can be represented by the
38
+ `inputs_ids` passed when calling [`SDARMoeModel`]
39
+ hidden_size (`int`, *optional*, defaults to 2048):
40
+ Dimension of the hidden representations.
41
+ intermediate_size (`int`, *optional*, defaults to 6144):
42
+ Dimension of the MLP representations.
43
+ num_hidden_layers (`int`, *optional*, defaults to 24):
44
+ Number of hidden layers in the Transformer encoder.
45
+ num_attention_heads (`int`, *optional*, defaults to 32):
46
+ Number of attention heads for each attention layer in the Transformer encoder.
47
+ num_key_value_heads (`int`, *optional*, defaults to 4):
48
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
49
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
50
+ `num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
51
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
52
+ by meanpooling all the original heads within that group. For more details checkout [this
53
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to `32`.
54
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
55
+ The non-linear activation function (function or string) in the decoder.
56
+ max_position_embeddings (`int`, *optional*, defaults to 32768):
57
+ The maximum sequence length that this model might ever be used with.
58
+ initializer_range (`float`, *optional*, defaults to 0.02):
59
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
60
+ rms_norm_eps (`float`, *optional*, defaults to 1e-06):
61
+ The epsilon used by the rms normalization layers.
62
+ use_cache (`bool`, *optional*, defaults to `True`):
63
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
64
+ relevant if `config.is_decoder=True`.
65
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
66
+ Whether the model's input and output word embeddings should be tied.
67
+ rope_theta (`float`, *optional*, defaults to 10000.0):
68
+ The base period of the RoPE embeddings.
69
+ rope_scaling (`Dict`, *optional*):
70
+ Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
71
+ and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
72
+ accordingly.
73
+ Expected contents:
74
+ `rope_type` (`str`):
75
+ The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
76
+ 'llama3'], with 'default' being the original RoPE implementation.
77
+ `factor` (`float`, *optional*):
78
+ Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
79
+ most scaling types, a `factor` of x will enable the model to handle sequences of length x *
80
+ original maximum pre-trained length.
81
+ `original_max_position_embeddings` (`int`, *optional*):
82
+ Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
83
+ pretraining.
84
+ `attention_factor` (`float`, *optional*):
85
+ Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
86
+ computation. If unspecified, it defaults to value recommended by the implementation, using the
87
+ `factor` field to infer the suggested value.
88
+ `beta_fast` (`float`, *optional*):
89
+ Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
90
+ ramp function. If unspecified, it defaults to 32.
91
+ `beta_slow` (`float`, *optional*):
92
+ Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
93
+ ramp function. If unspecified, it defaults to 1.
94
+ `short_factor` (`List[float]`, *optional*):
95
+ Only used with 'longrope'. The scaling factor to be applied to short contexts (<
96
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
97
+ size divided by the number of attention heads divided by 2
98
+ `long_factor` (`List[float]`, *optional*):
99
+ Only used with 'longrope'. The scaling factor to be applied to long contexts (<
100
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
101
+ size divided by the number of attention heads divided by 2
102
+ `low_freq_factor` (`float`, *optional*):
103
+ Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
104
+ `high_freq_factor` (`float`, *optional*):
105
+ Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
106
+ attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
107
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
108
+ use_sliding_window (`bool`, *optional*, defaults to `False`):
109
+ Whether to use sliding window attention.
110
+ sliding_window (`int`, *optional*, defaults to 4096):
111
+ Sliding window attention (SWA) window size. If not specified, will default to `4096`.
112
+ max_window_layers (`int`, *optional*, defaults to 28):
113
+ The number of layers that use SWA (Sliding Window Attention). The bottom layers use SWA while the top use full attention.
114
+ attention_dropout (`float`, *optional*, defaults to 0.0):
115
+ The dropout ratio for the attention probabilities.
116
+ decoder_sparse_step (`int`, *optional*, defaults to 1):
117
+ The frequency of the MoE layer.
118
+ moe_intermediate_size (`int`, *optional*, defaults to 768):
119
+ Intermediate size of the routed expert.
120
+ num_experts_per_tok (`int`, *optional*, defaults to 8):
121
+ Number of selected experts.
122
+ num_experts (`int`, *optional*, defaults to 128):
123
+ Number of routed experts.
124
+ norm_topk_prob (`bool`, *optional*, defaults to `False`):
125
+ Whether to normalize the topk probabilities.
126
+ output_router_logits (`bool`, *optional*, defaults to `False`):
127
+ Whether or not the router logits should be returned by the model. Enabling this will also
128
+ allow the model to output the auxiliary loss, including load balancing loss and router z-loss.
129
+ router_aux_loss_coef (`float`, *optional*, defaults to 0.001):
130
+ The aux loss factor for the total loss.
131
+ mlp_only_layers (`List[int]`, *optional*, defaults to `[]`):
132
+ Indicate which layers use SDARMoeMLP rather than SDARMoeSparseMoeBlock
133
+ The list contains layer index, from 0 to num_layers-1 if we have num_layers layers
134
+ If `mlp_only_layers` is empty, `decoder_sparse_step` is used to determine the sparsity.
135
+
136
+ ```python
137
+ >>> from transformers import SDARMoeModel, SDARMoeConfig
138
+
139
+ >>> # Initializing a SDARMoE style configuration
140
+ >>> configuration = SDARMoeConfig()
141
+
142
+ >>> # Initializing a model from the SDAR-15B-A2B" style configuration
143
+ >>> model = SDARMoeModel(configuration)
144
+
145
+ >>> # Accessing the model configuration
146
+ >>> configuration = model.config
147
+ ```"""
148
+
149
+ model_type = "sdar_moe"
150
+ keys_to_ignore_at_inference = ["past_key_values"]
151
+
152
+ # Default tensor parallel plan for base model `SDARMoe`
153
+ base_model_tp_plan = {
154
+ "layers.*.self_attn.q_proj": "colwise",
155
+ "layers.*.self_attn.k_proj": "colwise",
156
+ "layers.*.self_attn.v_proj": "colwise",
157
+ "layers.*.self_attn.o_proj": "rowwise",
158
+ "layers.*.mlp.experts.*.gate_proj": "colwise",
159
+ "layers.*.mlp.experts.*.up_proj": "colwise",
160
+ "layers.*.mlp.experts.*.down_proj": "rowwise",
161
+ "layers.*.mlp.gate_proj": "colwise",
162
+ "layers.*.mlp.up_proj": "colwise",
163
+ "layers.*.mlp.down_proj": "rowwise",
164
+ }
165
+ base_model_pp_plan = {
166
+ "embed_tokens": (["input_ids"], ["inputs_embeds"]),
167
+ "layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
168
+ "norm": (["hidden_states"], ["hidden_states"]),
169
+ }
170
+
171
+ def __init__(
172
+ self,
173
+ vocab_size=151936,
174
+ hidden_size=2048,
175
+ intermediate_size=6144,
176
+ num_hidden_layers=24,
177
+ num_attention_heads=32,
178
+ num_key_value_heads=4,
179
+ hidden_act="silu",
180
+ max_position_embeddings=32768,
181
+ initializer_range=0.02,
182
+ rms_norm_eps=1e-6,
183
+ use_cache=True,
184
+ tie_word_embeddings=False,
185
+ rope_theta=10000.0,
186
+ rope_scaling=None,
187
+ attention_bias=False,
188
+ use_sliding_window=False,
189
+ sliding_window=4096,
190
+ max_window_layers=28,
191
+ attention_dropout=0.0,
192
+ decoder_sparse_step=1,
193
+ moe_intermediate_size=768,
194
+ num_experts_per_tok=8,
195
+ num_experts=128,
196
+ norm_topk_prob=False,
197
+ output_router_logits=False,
198
+ router_aux_loss_coef=0.001,
199
+ mlp_only_layers=None,
200
+ **kwargs,
201
+ ):
202
+ self.vocab_size = vocab_size
203
+ self.max_position_embeddings = max_position_embeddings
204
+ self.hidden_size = hidden_size
205
+ self.intermediate_size = intermediate_size
206
+ self.num_hidden_layers = num_hidden_layers
207
+ self.num_attention_heads = num_attention_heads
208
+ self.use_sliding_window = use_sliding_window
209
+ self.sliding_window = sliding_window if use_sliding_window else None
210
+ self.max_window_layers = max_window_layers
211
+
212
+ self.num_key_value_heads = num_key_value_heads
213
+ self.hidden_act = hidden_act
214
+ self.initializer_range = initializer_range
215
+ self.rms_norm_eps = rms_norm_eps
216
+ self.use_cache = use_cache
217
+ self.rope_theta = rope_theta
218
+ self.rope_scaling = rope_scaling
219
+ self.attention_bias = attention_bias
220
+ self.attention_dropout = attention_dropout
221
+ # Validate the correctness of rotary position embeddings parameters
222
+ # BC: if there is a 'type' field, move it to 'rope_type'.
223
+ if self.rope_scaling is not None and "type" in self.rope_scaling:
224
+ self.rope_scaling["rope_type"] = self.rope_scaling["type"]
225
+ rope_config_validation(self)
226
+
227
+ # MoE arguments
228
+ self.decoder_sparse_step = decoder_sparse_step
229
+ self.moe_intermediate_size = moe_intermediate_size
230
+ self.num_experts_per_tok = num_experts_per_tok
231
+ self.num_experts = num_experts
232
+ self.norm_topk_prob = norm_topk_prob
233
+ self.output_router_logits = output_router_logits
234
+ self.router_aux_loss_coef = router_aux_loss_coef
235
+ self.mlp_only_layers = [] if mlp_only_layers is None else mlp_only_layers
236
+
237
+ super().__init__(
238
+ tie_word_embeddings=tie_word_embeddings,
239
+ **kwargs,
240
+ )
241
+
242
+
243
+ __all__ = ["SDARMoeConfig"]
generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 151645,
6
+ 151643
7
+ ],
8
+ "pad_token_id": 151643,
9
+ "temperature": 0.6,
10
+ "top_k": 20,
11
+ "top_p": 0.95,
12
+ "transformers_version": "4.51.0"
13
+ }
layer-0-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a8c8e06f5577c8ae66fb790e8fb29c968e7640a52f43f6429d744bb002f6a3a3
3
+ size 1246289008
layer-1-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d559e3f487e25cf9388fea0eb3de0c2682672be7c43929034a09cd0d2aaf03a4
3
+ size 1246289008
layer-10-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8850bef05418544bdf751ddf88f0332be3220862fdf022ef3c0951ae9444e67
3
+ size 1246289400
layer-11-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f7417f1c9d3f4feb487efe47117933d167e8c68eac7494827a4ae5f0c9c3c91b
3
+ size 1246289400
layer-12-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:007f3a2178e7ecc436a30703d49d5c4ca232e995e797859992e4417ac9fc3959
3
+ size 1246289400
layer-13-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c904f46cd6d90113229efd6b33e382a000f201dc78c9bc73899438b9ef83a05f
3
+ size 1246289400
layer-14-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fcb707b99c8a69b6b2ef47a0ff99ec82fd80f7ba71a2fe86da5075d2c3857366
3
+ size 1246289400
layer-15-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0d6a6987b6d61cd42e14b7bc1113eb050b3ff211c8a43717697c8eacbeb8958
3
+ size 1246289400
layer-16-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f14822bf1ca2c0bba448e2c04019c1b816e999c36d303de6f0f5a2f9712c128
3
+ size 1246289400
layer-17-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:87db9f39ab7c7f2a8abdfb67b2e0729b0ef79d056da828df09ef93e5e3b8515c
3
+ size 1246289400
layer-18-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a811f53918d77696817ef3e872c98b9695ef7bf9c983f2584bbb314461333352
3
+ size 1246289400
layer-19-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8564ad456afe63bc5a5dc6ee576e6a4b8e1a2276d00df2a1c7028696497d8f7a
3
+ size 1246289400
layer-2-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4339bb55d80d228021340f668e70b34352a10909399de43a0aa58ee348d25b60
3
+ size 1246289008
layer-20-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2bb08c7cd797a1fcdf32080d3bf6e54a3e0e00b6337104f049ec953b32ca3e25
3
+ size 1246289400
layer-21-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18b151c75f8c8538c4e127b63093ef14869c8a941e6ad2eb339c55c7a20bed94
3
+ size 1246289400
layer-22-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc5dcdf747072d5c517ea453de758f5aae5d39c91eceb30e1e3685b0b47fa2fe
3
+ size 1246289400
layer-23-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52617650ac0cb82a879ffbdbdbed5163e840973b2138e419b598078e3f4e819a
3
+ size 1246289400
layer-24-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4fc9951e47a6a6ed06a7bec6fe3e3bd004fd5d9c89ccbf53798f8f04d43014f1
3
+ size 1246289400
layer-25-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:75e57c5f9b2ab96fe0e3ecdd04d23591ef73545aff8070b96b5e7916e2711a4d
3
+ size 1246289400
layer-26-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44994fc6e279dadcc9d9966370db14d2b15accc0a45e08b938dbf75088a9d244
3
+ size 1246289400
layer-27-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4b4134b69a6aacf2406b596530eb48b7cffce52950413b52cf98bf63895d6bc5
3
+ size 1246289400
layer-28-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53a27042dcfc2d0659e1b51d81c048c60f4e8a49145166ab4a891dcb13cdff24
3
+ size 1246289400
layer-29-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:824583f875a733e8ad913e56c8bd9a05fa8f7f55b3131c31a53ff7b8222e1d23
3
+ size 1246289400
layer-3-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6eff3d5a8ce57d0fb3ec9cd9bc790f3a4cc1b3ffea4b4d4f3d9651f52b91d9ba
3
+ size 1246289008
layer-30-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d9d4fb4ab52ef01c6380bc71640d175c82c0303f2578ceb55c2acae9ebf250c
3
+ size 1246289400
layer-31-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:31f5b4ce2d4f2dcda01f56c2c1b991d67faee7281c05f1fcc01c2ad648e65c45
3
+ size 1246289400
layer-32-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52a26a912cd5dc054a072369d3994faa5e0dbe47d7c9b027308fc6eaaed43210
3
+ size 1246289400
layer-33-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f28ea08eb74e910fddf19c0d5439f2df713f2dabecbe7898dfb64cd087bf4b7
3
+ size 1246289400
layer-34-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d9e92981aca3c9f04973058afce58885943ad29c25b9d1ec81d29b55de77bcf6
3
+ size 1246289400
layer-35-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:31bf1b970cfa139aed5abba68c1a1467c6255bc19d74d690a418d656e8ab9f64
3
+ size 1246289400
layer-36-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0cec4ef2daa21906025cc0bd45873d6dca7e277c477cf3b7a8846024befc025
3
+ size 1246289400
layer-37-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be49e9c5a69c8bb6159c9ccd3ff433ef456309168d808dff85721502fc4d9458
3
+ size 1246289400
layer-38-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c995c79940971bf845be5c6da8a656cec17d1eeaa81de06d5ff4d3e27a69da99
3
+ size 1246289400
layer-39-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a69b34213c52dd0a1beb7703aeb28e49a9946ba4529637d42f4837a1ccf26ee6
3
+ size 1246289400
layer-4-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef27c11b67e3a1f33c35ea807beb3569746c22d3736c4af1db7ccb339b5d17db
3
+ size 1246289008
layer-40-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f7b0272898064f12b761faff8833fd75eb2f3194377f1e700dc26734109ecec3
3
+ size 1246289400
layer-41-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ff88d5dfae6321596006e4f2e966133cd2d3aae115243670a2d98483b89da058
3
+ size 1246289400
layer-42-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c0e44e9e352d3e2493dfc7f6423158f260b0f775980bc173cb8c9ce01785bad6
3
+ size 1246289400
layer-43-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4f3b9450d182600488cdbc04ad267507c54d6f6291d4b3ba9ccc783b43720fa
3
+ size 1246289400
layer-44-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:146a22a3fa1064f869bf9faeaf53b69b5bd3a7cdc5396b3eb8c376543ed54798
3
+ size 1246289400
layer-45-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45f735e20dd6c9c4e5868623ea74c1b958320f2d42c83253a81bcbed77ae405f
3
+ size 1246289400
layer-46-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:407ce8012e737e627f4c7466130d0ea5a18ffd3a258f38bc9f40164d05215b3a
3
+ size 1246289400
layer-47-ep-0-of-1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d35a95bcbcc8c484d738ee877edaff8386938f40f65305cbecb4de1c953b3341
3
+ size 1246289400