xuan-luo commited on
Commit
07efce5
·
verified ·
1 Parent(s): f74bb8d

Add files using upload-large-folder tool

Browse files
Files changed (33) hide show
  1. .gitattributes +2 -0
  2. DMTD-E0D8C4/__init__.py +2 -0
  3. DMTD-E0D8C4/__pycache__/configuration_dmtdqwen3.cpython-312.pyc +0 -0
  4. DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3.cpython-312.pyc +0 -0
  5. DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3_hybrid.cpython-312.pyc +0 -0
  6. DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3_hybrid.cpython-36.pyc +0 -0
  7. DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3_inference.cpython-312.pyc +0 -0
  8. DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3_medusa_style.cpython-312.pyc +0 -0
  9. DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3_sd.cpython-312.pyc +0 -0
  10. DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3_tree_sd.cpython-312.pyc +0 -0
  11. DMTD-E0D8C4/__pycache__/reasoning_speed_comparison.cpython-312.pyc +0 -0
  12. DMTD-E0D8C4/__pycache__/speed_comparison.cpython-312.pyc +0 -0
  13. DMTD-E0D8C4/chat_template.jinja +89 -0
  14. DMTD-E0D8C4/config.json +80 -0
  15. DMTD-E0D8C4/configuration_dmtdqwen3.py +112 -0
  16. DMTD-E0D8C4/generation_config.json +13 -0
  17. DMTD-E0D8C4/model-00001-of-00002.safetensors +3 -0
  18. DMTD-E0D8C4/model-00002-of-00002.safetensors +3 -0
  19. DMTD-E0D8C4/model.safetensors.index.json +406 -0
  20. DMTD-E0D8C4/modeling_dmtdqwen3.py +525 -0
  21. DMTD-E0D8C4/register_dmtdqwen3.py +23 -0
  22. DMTD-E0D8C4/tokenizer.json +3 -0
  23. DMTD-E0D8C4/tokenizer_config.json +30 -0
  24. Qwen3-am-distilled/chat_template.jinja +89 -0
  25. Qwen3-am-distilled/config.json +76 -0
  26. Qwen3-am-distilled/configuration_dmtdqwen3.py +87 -0
  27. Qwen3-am-distilled/generation_config.json +12 -0
  28. Qwen3-am-distilled/model-00001-of-00002.safetensors +3 -0
  29. Qwen3-am-distilled/model-00002-of-00002.safetensors +3 -0
  30. Qwen3-am-distilled/model.safetensors.index.json +406 -0
  31. Qwen3-am-distilled/modeling_dmtdqwen3.py +467 -0
  32. Qwen3-am-distilled/tokenizer.json +3 -0
  33. Qwen3-am-distilled/tokenizer_config.json +30 -0
.gitattributes CHANGED
@@ -33,3 +33,5 @@ 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
+ DMTD-E0D8C4/tokenizer.json filter=lfs diff=lfs merge=lfs -text
37
+ Qwen3-am-distilled/tokenizer.json filter=lfs diff=lfs merge=lfs -text
DMTD-E0D8C4/__init__.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ from .configuration_dmtdqwen3 import DMTDQwen3Config
2
+ from .modeling_dmtdqwen3 import DMTDQwen3ForCausalLM, DMTDQwen3Model
DMTD-E0D8C4/__pycache__/configuration_dmtdqwen3.cpython-312.pyc ADDED
Binary file (4.64 kB). View file
 
DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3.cpython-312.pyc ADDED
Binary file (26.9 kB). View file
 
DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3_hybrid.cpython-312.pyc ADDED
Binary file (11.7 kB). View file
 
DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3_hybrid.cpython-36.pyc ADDED
Binary file (8.94 kB). View file
 
DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3_inference.cpython-312.pyc ADDED
Binary file (20.5 kB). View file
 
DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3_medusa_style.cpython-312.pyc ADDED
Binary file (23.7 kB). View file
 
DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3_sd.cpython-312.pyc ADDED
Binary file (19.1 kB). View file
 
DMTD-E0D8C4/__pycache__/modeling_dmtdqwen3_tree_sd.cpython-312.pyc ADDED
Binary file (28.1 kB). View file
 
DMTD-E0D8C4/__pycache__/reasoning_speed_comparison.cpython-312.pyc ADDED
Binary file (25.6 kB). View file
 
DMTD-E0D8C4/__pycache__/speed_comparison.cpython-312.pyc ADDED
Binary file (28.5 kB). View file
 
DMTD-E0D8C4/chat_template.jinja ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 message.content is string 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.content is string %}
27
+ {%- set content = message.content %}
28
+ {%- else %}
29
+ {%- set content = '' %}
30
+ {%- endif %}
31
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
+ {%- elif message.role == "assistant" %}
34
+ {%- set reasoning_content = '' %}
35
+ {%- if message.reasoning_content is string %}
36
+ {%- set reasoning_content = message.reasoning_content %}
37
+ {%- else %}
38
+ {%- if '</think>' in content %}
39
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
+ {%- endif %}
42
+ {%- endif %}
43
+ {%- if loop.index0 > ns.last_query_index %}
44
+ {%- if loop.last or (not loop.last and reasoning_content) %}
45
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
46
+ {%- else %}
47
+ {{- '<|im_start|>' + message.role + '\n' + content }}
48
+ {%- endif %}
49
+ {%- else %}
50
+ {{- '<|im_start|>' + message.role + '\n' + content }}
51
+ {%- endif %}
52
+ {%- if message.tool_calls %}
53
+ {%- for tool_call in message.tool_calls %}
54
+ {%- if (loop.first and content) or (not loop.first) %}
55
+ {{- '\n' }}
56
+ {%- endif %}
57
+ {%- if tool_call.function %}
58
+ {%- set tool_call = tool_call.function %}
59
+ {%- endif %}
60
+ {{- '<tool_call>\n{"name": "' }}
61
+ {{- tool_call.name }}
62
+ {{- '", "arguments": ' }}
63
+ {%- if tool_call.arguments is string %}
64
+ {{- tool_call.arguments }}
65
+ {%- else %}
66
+ {{- tool_call.arguments | tojson }}
67
+ {%- endif %}
68
+ {{- '}\n</tool_call>' }}
69
+ {%- endfor %}
70
+ {%- endif %}
71
+ {{- '<|im_end|>\n' }}
72
+ {%- elif message.role == "tool" %}
73
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
74
+ {{- '<|im_start|>user' }}
75
+ {%- endif %}
76
+ {{- '\n<tool_response>\n' }}
77
+ {{- content }}
78
+ {{- '\n</tool_response>' }}
79
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
80
+ {{- '<|im_end|>\n' }}
81
+ {%- endif %}
82
+ {%- endif %}
83
+ {%- endfor %}
84
+ {%- if add_generation_prompt %}
85
+ {{- '<|im_start|>assistant\n' }}
86
+ {%- if enable_thinking is defined and enable_thinking is false %}
87
+ {{- '<think>\n\n</think>\n\n' }}
88
+ {%- endif %}
89
+ {%- endif %}
DMTD-E0D8C4/config.json ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DMTDQwen3ForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_dmtdqwen3.DMTDQwen3Config",
9
+ "AutoModel": "modeling_dmtdqwen3.DMTDQwen3Model",
10
+ "AutoModelForCausalLM": "modeling_dmtdqwen3.DMTDQwen3ForCausalLM"
11
+ },
12
+ "bos_token_id": null,
13
+ "dtype": "bfloat16",
14
+ "eos_token_id": 151645,
15
+ "head_dim": 128,
16
+ "hidden_act": "silu",
17
+ "hidden_size": 2560,
18
+ "initializer_range": 0.02,
19
+ "intermediate_size": 9728,
20
+ "layer_types": [
21
+ "full_attention",
22
+ "full_attention",
23
+ "full_attention",
24
+ "full_attention",
25
+ "full_attention",
26
+ "full_attention",
27
+ "full_attention",
28
+ "full_attention",
29
+ "full_attention",
30
+ "full_attention",
31
+ "full_attention",
32
+ "full_attention",
33
+ "full_attention",
34
+ "full_attention",
35
+ "full_attention",
36
+ "full_attention",
37
+ "full_attention",
38
+ "full_attention",
39
+ "full_attention",
40
+ "full_attention",
41
+ "full_attention",
42
+ "full_attention",
43
+ "full_attention",
44
+ "full_attention",
45
+ "full_attention",
46
+ "full_attention",
47
+ "full_attention",
48
+ "full_attention",
49
+ "full_attention",
50
+ "full_attention",
51
+ "full_attention",
52
+ "full_attention",
53
+ "full_attention",
54
+ "full_attention",
55
+ "full_attention",
56
+ "full_attention"
57
+ ],
58
+ "max_position_embeddings": 40960,
59
+ "max_window_layers": 36,
60
+ "model_type": "dmtdqwen3",
61
+ "mtp_horizon": 4,
62
+ "num_attention_heads": 32,
63
+ "num_decoding_layers": 8,
64
+ "num_encoding_layers": 0,
65
+ "num_hidden_layers": 36,
66
+ "num_key_value_heads": 8,
67
+ "num_thinking_layers": 28,
68
+ "pad_token_id": 151643,
69
+ "rms_norm_eps": 1e-06,
70
+ "rope_parameters": {
71
+ "rope_theta": 1000000,
72
+ "rope_type": "default"
73
+ },
74
+ "sliding_window": null,
75
+ "tie_word_embeddings": true,
76
+ "transformers_version": "5.6.2",
77
+ "use_cache": false,
78
+ "use_sliding_window": false,
79
+ "vocab_size": 151936
80
+ }
DMTD-E0D8C4/configuration_dmtdqwen3.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """DMTDQwen3 model configuration"""
15
+
16
+ from dataclasses import field
17
+
18
+ from huggingface_hub.dataclasses import strict
19
+
20
+ from transformers.configuration_utils import PreTrainedConfig
21
+ from transformers.modeling_rope_utils import RopeParameters
22
+
23
+
24
+ @strict
25
+ class DMTDQwen3Config(PreTrainedConfig):
26
+ model_type = "dmtdqwen3"
27
+ keys_to_ignore_at_inference = ["past_key_values"]
28
+
29
+ base_model_tp_plan = {
30
+ "layers.*.self_attn.q_proj": "colwise",
31
+ "layers.*.self_attn.k_proj": "colwise",
32
+ "layers.*.self_attn.v_proj": "colwise",
33
+ "layers.*.self_attn.q_norm": "replicated_with_grad_allreduce",
34
+ "layers.*.self_attn.k_norm": "replicated_with_grad_allreduce",
35
+ "layers.*.self_attn.o_proj": "rowwise",
36
+ "layers.*.mlp.gate_proj": "colwise",
37
+ "layers.*.mlp.up_proj": "colwise",
38
+ "layers.*.mlp.down_proj": "rowwise",
39
+ }
40
+ base_model_pp_plan = {
41
+ "embed_tokens": (["input_ids"], ["inputs_embeds"]),
42
+ "layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
43
+ "norm": (["hidden_states"], ["hidden_states"]),
44
+ }
45
+
46
+ vocab_size: int = 151936
47
+ hidden_size: int = 2560
48
+ intermediate_size: int = 9728
49
+ num_hidden_layers: int = 36
50
+ num_attention_heads: int = 32
51
+ num_key_value_heads: int | None = 8
52
+ head_dim: int = 128
53
+ hidden_act: str = "silu"
54
+ max_position_embeddings: int = 40960
55
+ initializer_range: float = 0.02
56
+ rms_norm_eps: float = 1e-6
57
+ use_cache: bool = True
58
+ tie_word_embeddings: bool = True
59
+ rope_parameters: RopeParameters | dict | None = field(
60
+ default_factory=lambda: {"rope_type": "default", "rope_theta": 1000000}
61
+ )
62
+ attention_bias: bool = False
63
+ use_sliding_window: bool = False
64
+ sliding_window: int | None = 4096
65
+ max_window_layers: int = 36
66
+ layer_types: list[str] | None = None
67
+ attention_dropout: float | int = 0.0
68
+ pad_token_id: int | None = None
69
+ bos_token_id: int | None = 151643
70
+ eos_token_id: int | list[int] | None = 151645
71
+
72
+ # DMTD-specific fields: encoding / thinking / decoding split + cycle length.
73
+ # For Qwen3DMTD-E0D8C3 with 36 total layers:
74
+ # num_encoding_layers = 0
75
+ # num_decoding_layers = 8
76
+ # num_thinking_layers = 28 (= num_hidden_layers - num_encoding_layers - num_decoding_layers)
77
+ # mtp_horizon (cycle length) = 3
78
+ num_encoding_layers: int = 0
79
+ num_thinking_layers: int = 28
80
+ num_decoding_layers: int = 8
81
+ mtp_horizon: int = 3
82
+
83
+ def __post_init__(self, **kwargs):
84
+ self.sliding_window = self.sliding_window if self.use_sliding_window else None
85
+ if self.num_key_value_heads is None:
86
+ self.num_key_value_heads = self.num_attention_heads
87
+
88
+ if self.layer_types is None:
89
+ self.layer_types = [
90
+ "sliding_attention"
91
+ if self.sliding_window is not None and i >= self.max_window_layers
92
+ else "full_attention"
93
+ for i in range(self.num_hidden_layers)
94
+ ]
95
+
96
+ # Sanity check the DMTD layer split.
97
+ total_split = (
98
+ self.num_encoding_layers + self.num_thinking_layers + self.num_decoding_layers
99
+ )
100
+ if total_split != self.num_hidden_layers:
101
+ raise ValueError(
102
+ "num_encoding_layers + num_thinking_layers + num_decoding_layers must equal "
103
+ f"num_hidden_layers; got {self.num_encoding_layers} + {self.num_thinking_layers} "
104
+ f"+ {self.num_decoding_layers} = {total_split} vs num_hidden_layers={self.num_hidden_layers}."
105
+ )
106
+ if self.mtp_horizon < 1:
107
+ raise ValueError(f"mtp_horizon must be >= 1, got {self.mtp_horizon}.")
108
+
109
+ super().__post_init__(**kwargs)
110
+
111
+
112
+ __all__ = ["DMTDQwen3Config"]
DMTD-E0D8C4/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": "5.6.2"
13
+ }
DMTD-E0D8C4/model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f58036fdb9ec72e7f79f3551340b926f05f30e8eb17b3288a0dfaa1cabde4e2
3
+ size 4990818672
DMTD-E0D8C4/model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b78c2ccdab7b02caa8d6bc61a2a71291de4092f24706c31ca7adc81a690595de
3
+ size 3054163328
DMTD-E0D8C4/model.safetensors.index.json ADDED
@@ -0,0 +1,406 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_parameters": 4022468096,
4
+ "total_size": 8044936192
5
+ },
6
+ "weight_map": {
7
+ "model.embed_tokens.weight": "model-00001-of-00002.safetensors",
8
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
9
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
10
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
11
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
12
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
13
+ "model.layers.0.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
14
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
15
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
16
+ "model.layers.0.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
17
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
18
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
19
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
20
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
21
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
22
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
23
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
24
+ "model.layers.1.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
25
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
26
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
27
+ "model.layers.1.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
28
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
29
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
30
+ "model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
31
+ "model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
32
+ "model.layers.10.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
33
+ "model.layers.10.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
34
+ "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
35
+ "model.layers.10.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
36
+ "model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
37
+ "model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
38
+ "model.layers.10.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
39
+ "model.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
40
+ "model.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
41
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
42
+ "model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
43
+ "model.layers.11.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
44
+ "model.layers.11.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
45
+ "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
46
+ "model.layers.11.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
47
+ "model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
48
+ "model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
49
+ "model.layers.11.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
50
+ "model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
51
+ "model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
52
+ "model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
53
+ "model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
54
+ "model.layers.12.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
55
+ "model.layers.12.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
56
+ "model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
57
+ "model.layers.12.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
58
+ "model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
59
+ "model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
60
+ "model.layers.12.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
61
+ "model.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
62
+ "model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
63
+ "model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
64
+ "model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
65
+ "model.layers.13.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
66
+ "model.layers.13.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
67
+ "model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
68
+ "model.layers.13.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
69
+ "model.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
70
+ "model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
71
+ "model.layers.13.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
72
+ "model.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
73
+ "model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
74
+ "model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
75
+ "model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
76
+ "model.layers.14.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
77
+ "model.layers.14.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
78
+ "model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
79
+ "model.layers.14.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
80
+ "model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
81
+ "model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
82
+ "model.layers.14.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
83
+ "model.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
84
+ "model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
85
+ "model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
86
+ "model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
87
+ "model.layers.15.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
88
+ "model.layers.15.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
89
+ "model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
90
+ "model.layers.15.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
91
+ "model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
92
+ "model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
93
+ "model.layers.15.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
94
+ "model.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
95
+ "model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
96
+ "model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
97
+ "model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
98
+ "model.layers.16.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
99
+ "model.layers.16.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
100
+ "model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
101
+ "model.layers.16.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
102
+ "model.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
103
+ "model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
104
+ "model.layers.16.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
105
+ "model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
106
+ "model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
107
+ "model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
108
+ "model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
109
+ "model.layers.17.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
110
+ "model.layers.17.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
111
+ "model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
112
+ "model.layers.17.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
113
+ "model.layers.17.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
114
+ "model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
115
+ "model.layers.17.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
116
+ "model.layers.17.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
117
+ "model.layers.17.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
118
+ "model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
119
+ "model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
120
+ "model.layers.18.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
121
+ "model.layers.18.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
122
+ "model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
123
+ "model.layers.18.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
124
+ "model.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
125
+ "model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
126
+ "model.layers.18.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
127
+ "model.layers.18.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
128
+ "model.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
129
+ "model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
130
+ "model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
131
+ "model.layers.19.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
132
+ "model.layers.19.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
133
+ "model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
134
+ "model.layers.19.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
135
+ "model.layers.19.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
136
+ "model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
137
+ "model.layers.19.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
138
+ "model.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
139
+ "model.layers.19.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
140
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
141
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
142
+ "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
143
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
144
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
145
+ "model.layers.2.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
146
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
147
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
148
+ "model.layers.2.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
149
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
150
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
151
+ "model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
152
+ "model.layers.20.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
153
+ "model.layers.20.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
154
+ "model.layers.20.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
155
+ "model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
156
+ "model.layers.20.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
157
+ "model.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
158
+ "model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
159
+ "model.layers.20.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
160
+ "model.layers.20.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
161
+ "model.layers.20.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
162
+ "model.layers.21.input_layernorm.weight": "model-00002-of-00002.safetensors",
163
+ "model.layers.21.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
164
+ "model.layers.21.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
165
+ "model.layers.21.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
166
+ "model.layers.21.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
167
+ "model.layers.21.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
168
+ "model.layers.21.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
169
+ "model.layers.21.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
170
+ "model.layers.21.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
171
+ "model.layers.21.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
172
+ "model.layers.21.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
173
+ "model.layers.22.input_layernorm.weight": "model-00002-of-00002.safetensors",
174
+ "model.layers.22.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
175
+ "model.layers.22.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
176
+ "model.layers.22.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
177
+ "model.layers.22.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
178
+ "model.layers.22.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
179
+ "model.layers.22.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
180
+ "model.layers.22.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
181
+ "model.layers.22.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
182
+ "model.layers.22.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
183
+ "model.layers.22.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
184
+ "model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors",
185
+ "model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
186
+ "model.layers.23.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
187
+ "model.layers.23.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
188
+ "model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
189
+ "model.layers.23.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
190
+ "model.layers.23.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
191
+ "model.layers.23.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
192
+ "model.layers.23.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
193
+ "model.layers.23.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
194
+ "model.layers.23.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
195
+ "model.layers.24.input_layernorm.weight": "model-00002-of-00002.safetensors",
196
+ "model.layers.24.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
197
+ "model.layers.24.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
198
+ "model.layers.24.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
199
+ "model.layers.24.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
200
+ "model.layers.24.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
201
+ "model.layers.24.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
202
+ "model.layers.24.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
203
+ "model.layers.24.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
204
+ "model.layers.24.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
205
+ "model.layers.24.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
206
+ "model.layers.25.input_layernorm.weight": "model-00002-of-00002.safetensors",
207
+ "model.layers.25.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
208
+ "model.layers.25.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
209
+ "model.layers.25.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
210
+ "model.layers.25.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
211
+ "model.layers.25.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
212
+ "model.layers.25.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
213
+ "model.layers.25.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
214
+ "model.layers.25.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
215
+ "model.layers.25.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
216
+ "model.layers.25.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
217
+ "model.layers.26.input_layernorm.weight": "model-00002-of-00002.safetensors",
218
+ "model.layers.26.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
219
+ "model.layers.26.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
220
+ "model.layers.26.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
221
+ "model.layers.26.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
222
+ "model.layers.26.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
223
+ "model.layers.26.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
224
+ "model.layers.26.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
225
+ "model.layers.26.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
226
+ "model.layers.26.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
227
+ "model.layers.26.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
228
+ "model.layers.27.input_layernorm.weight": "model-00002-of-00002.safetensors",
229
+ "model.layers.27.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
230
+ "model.layers.27.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
231
+ "model.layers.27.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
232
+ "model.layers.27.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
233
+ "model.layers.27.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
234
+ "model.layers.27.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
235
+ "model.layers.27.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
236
+ "model.layers.27.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
237
+ "model.layers.27.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
238
+ "model.layers.27.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
239
+ "model.layers.28.input_layernorm.weight": "model-00002-of-00002.safetensors",
240
+ "model.layers.28.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
241
+ "model.layers.28.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
242
+ "model.layers.28.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
243
+ "model.layers.28.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
244
+ "model.layers.28.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
245
+ "model.layers.28.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
246
+ "model.layers.28.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
247
+ "model.layers.28.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
248
+ "model.layers.28.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
249
+ "model.layers.28.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
250
+ "model.layers.29.input_layernorm.weight": "model-00002-of-00002.safetensors",
251
+ "model.layers.29.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
252
+ "model.layers.29.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
253
+ "model.layers.29.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
254
+ "model.layers.29.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
255
+ "model.layers.29.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
256
+ "model.layers.29.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
257
+ "model.layers.29.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
258
+ "model.layers.29.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
259
+ "model.layers.29.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
260
+ "model.layers.29.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
261
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
262
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
263
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
264
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
265
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
266
+ "model.layers.3.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
267
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
268
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
269
+ "model.layers.3.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
270
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
271
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
272
+ "model.layers.30.input_layernorm.weight": "model-00002-of-00002.safetensors",
273
+ "model.layers.30.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
274
+ "model.layers.30.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
275
+ "model.layers.30.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
276
+ "model.layers.30.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
277
+ "model.layers.30.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
278
+ "model.layers.30.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
279
+ "model.layers.30.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
280
+ "model.layers.30.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
281
+ "model.layers.30.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
282
+ "model.layers.30.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
283
+ "model.layers.31.input_layernorm.weight": "model-00002-of-00002.safetensors",
284
+ "model.layers.31.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
285
+ "model.layers.31.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
286
+ "model.layers.31.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
287
+ "model.layers.31.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
288
+ "model.layers.31.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
289
+ "model.layers.31.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
290
+ "model.layers.31.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
291
+ "model.layers.31.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
292
+ "model.layers.31.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
293
+ "model.layers.31.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
294
+ "model.layers.32.input_layernorm.weight": "model-00002-of-00002.safetensors",
295
+ "model.layers.32.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
296
+ "model.layers.32.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
297
+ "model.layers.32.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
298
+ "model.layers.32.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
299
+ "model.layers.32.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
300
+ "model.layers.32.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
301
+ "model.layers.32.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
302
+ "model.layers.32.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
303
+ "model.layers.32.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
304
+ "model.layers.32.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
305
+ "model.layers.33.input_layernorm.weight": "model-00002-of-00002.safetensors",
306
+ "model.layers.33.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
307
+ "model.layers.33.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
308
+ "model.layers.33.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
309
+ "model.layers.33.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
310
+ "model.layers.33.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
311
+ "model.layers.33.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
312
+ "model.layers.33.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
313
+ "model.layers.33.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
314
+ "model.layers.33.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
315
+ "model.layers.33.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
316
+ "model.layers.34.input_layernorm.weight": "model-00002-of-00002.safetensors",
317
+ "model.layers.34.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
318
+ "model.layers.34.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
319
+ "model.layers.34.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
320
+ "model.layers.34.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
321
+ "model.layers.34.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
322
+ "model.layers.34.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
323
+ "model.layers.34.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
324
+ "model.layers.34.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
325
+ "model.layers.34.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
326
+ "model.layers.34.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
327
+ "model.layers.35.input_layernorm.weight": "model-00002-of-00002.safetensors",
328
+ "model.layers.35.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
329
+ "model.layers.35.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
330
+ "model.layers.35.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
331
+ "model.layers.35.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
332
+ "model.layers.35.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
333
+ "model.layers.35.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
334
+ "model.layers.35.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
335
+ "model.layers.35.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
336
+ "model.layers.35.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
337
+ "model.layers.35.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
338
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
339
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
340
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
341
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
342
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
343
+ "model.layers.4.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
344
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
345
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
346
+ "model.layers.4.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
347
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
348
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
349
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
350
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
351
+ "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
352
+ "model.layers.5.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
353
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
354
+ "model.layers.5.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
355
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
356
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
357
+ "model.layers.5.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
358
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
359
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
360
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
361
+ "model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
362
+ "model.layers.6.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
363
+ "model.layers.6.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
364
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
365
+ "model.layers.6.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
366
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
367
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
368
+ "model.layers.6.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
369
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
370
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
371
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
372
+ "model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
373
+ "model.layers.7.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
374
+ "model.layers.7.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
375
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
376
+ "model.layers.7.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
377
+ "model.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
378
+ "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
379
+ "model.layers.7.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
380
+ "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
381
+ "model.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
382
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
383
+ "model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
384
+ "model.layers.8.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
385
+ "model.layers.8.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
386
+ "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
387
+ "model.layers.8.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
388
+ "model.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
389
+ "model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
390
+ "model.layers.8.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
391
+ "model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
392
+ "model.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
393
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
394
+ "model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
395
+ "model.layers.9.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
396
+ "model.layers.9.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
397
+ "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
398
+ "model.layers.9.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
399
+ "model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
400
+ "model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
401
+ "model.layers.9.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
402
+ "model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
403
+ "model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
404
+ "model.norm.weight": "model-00002-of-00002.safetensors"
405
+ }
406
+ }
DMTD-E0D8C4/modeling_dmtdqwen3.py ADDED
@@ -0,0 +1,525 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2025 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from collections.abc import Callable
16
+ from typing import Optional
17
+
18
+ import torch
19
+ from torch import nn
20
+
21
+ from transformers.activations import ACT2FN
22
+ from transformers.cache_utils import Cache, DynamicCache
23
+ from transformers.generation import GenerationMixin
24
+ from transformers.integrations import use_kernel_forward_from_hub, use_kernel_func_from_hub, use_kernelized_func
25
+ from transformers.masking_utils import create_causal_mask, create_sliding_window_causal_mask
26
+ from transformers.modeling_flash_attention_utils import FlashAttentionKwargs
27
+ from transformers.modeling_layers import (
28
+ GenericForQuestionAnswering,
29
+ GenericForSequenceClassification,
30
+ GenericForTokenClassification,
31
+ GradientCheckpointingLayer,
32
+ )
33
+ from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
34
+ from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
35
+ from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
36
+ from transformers.processing_utils import Unpack
37
+ from transformers.utils import TransformersKwargs, can_return_tuple
38
+ from transformers.utils.generic import maybe_autocast, merge_with_config_defaults
39
+ from transformers.utils.output_capturing import capture_outputs
40
+ from .configuration_dmtdqwen3 import DMTDQwen3Config
41
+
42
+
43
+ @use_kernel_forward_from_hub("RMSNorm")
44
+ class DMTDQwen3RMSNorm(nn.Module):
45
+ def __init__(self, hidden_size, eps: float = 1e-6) -> None:
46
+ super().__init__()
47
+ self.weight = nn.Parameter(torch.ones(hidden_size))
48
+ self.variance_epsilon = eps
49
+
50
+ def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
51
+ input_dtype = hidden_states.dtype
52
+ hidden_states = hidden_states.to(torch.float32)
53
+ variance = hidden_states.pow(2).mean(-1, keepdim=True)
54
+ hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
55
+ return self.weight * hidden_states.to(input_dtype)
56
+
57
+ def extra_repr(self):
58
+ return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
59
+
60
+
61
+ class DMTDQwen3MLP(nn.Module):
62
+ def __init__(self, config):
63
+ super().__init__()
64
+ self.config = config
65
+ self.hidden_size = config.hidden_size
66
+ self.intermediate_size = config.intermediate_size
67
+ self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
68
+ self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
69
+ self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
70
+ self.act_fn = ACT2FN[config.hidden_act]
71
+
72
+ def forward(self, x):
73
+ down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
74
+ return down_proj
75
+
76
+
77
+ class DMTDQwen3RotaryEmbedding(nn.Module):
78
+ inv_freq: torch.Tensor # fix linting for `register_buffer`
79
+
80
+ def __init__(self, config: DMTDQwen3Config, device=None):
81
+ super().__init__()
82
+ self.max_seq_len_cached = config.max_position_embeddings
83
+ self.original_max_seq_len = config.max_position_embeddings
84
+
85
+ self.config = config
86
+
87
+ self.rope_type = self.config.rope_parameters["rope_type"]
88
+ rope_init_fn: Callable = self.compute_default_rope_parameters
89
+ if self.rope_type != "default":
90
+ rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
91
+ inv_freq, self.attention_scaling = rope_init_fn(self.config, device)
92
+
93
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
94
+ self.register_buffer("original_inv_freq", inv_freq.clone(), persistent=False)
95
+
96
+ @staticmethod
97
+ def compute_default_rope_parameters(
98
+ config: DMTDQwen3Config | None = None,
99
+ device: Optional["torch.device"] = None,
100
+ seq_len: int | None = None,
101
+ ) -> tuple["torch.Tensor", float]:
102
+ base = config.rope_parameters["rope_theta"]
103
+ dim = getattr(config, "head_dim", None) or config.hidden_size // config.num_attention_heads
104
+
105
+ attention_factor = 1.0 # Unused in this type of RoPE
106
+
107
+ # Compute the inverse frequencies
108
+ inv_freq = 1.0 / (
109
+ base ** (torch.arange(0, dim, 2, dtype=torch.int64).to(device=device, dtype=torch.float) / dim)
110
+ )
111
+ return inv_freq, attention_factor
112
+
113
+ @torch.no_grad()
114
+ @dynamic_rope_update # power user: used with advanced RoPE types (e.g. dynamic rope)
115
+ def forward(self, x, position_ids):
116
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device)
117
+ position_ids_expanded = position_ids[:, None, :].float()
118
+
119
+ device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu"
120
+ with maybe_autocast(device_type=device_type, enabled=False): # Force float32
121
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
122
+ emb = torch.cat((freqs, freqs), dim=-1)
123
+ cos = emb.cos() * self.attention_scaling
124
+ sin = emb.sin() * self.attention_scaling
125
+
126
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
127
+
128
+
129
+ def rotate_half(x):
130
+ """Rotates half the hidden dims of the input."""
131
+ x1 = x[..., : x.shape[-1] // 2]
132
+ x2 = x[..., x.shape[-1] // 2 :]
133
+ return torch.cat((-x2, x1), dim=-1)
134
+
135
+
136
+ @use_kernel_func_from_hub("rotary_pos_emb")
137
+ def apply_rotary_pos_emb(q, k, cos, sin, unsqueeze_dim=1):
138
+ cos = cos.unsqueeze(unsqueeze_dim)
139
+ sin = sin.unsqueeze(unsqueeze_dim)
140
+ q_embed = (q * cos) + (rotate_half(q) * sin)
141
+ k_embed = (k * cos) + (rotate_half(k) * sin)
142
+ return q_embed, k_embed
143
+
144
+
145
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
146
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
147
+ if n_rep == 1:
148
+ return hidden_states
149
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
150
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
151
+
152
+
153
+ def eager_attention_forward(
154
+ module: nn.Module,
155
+ query: torch.Tensor,
156
+ key: torch.Tensor,
157
+ value: torch.Tensor,
158
+ attention_mask: torch.Tensor | None,
159
+ scaling: float,
160
+ dropout: float = 0.0,
161
+ **kwargs: Unpack[TransformersKwargs],
162
+ ):
163
+ key_states = repeat_kv(key, module.num_key_value_groups)
164
+ value_states = repeat_kv(value, module.num_key_value_groups)
165
+
166
+ attn_weights = torch.matmul(query, key_states.transpose(2, 3)) * scaling
167
+ if attention_mask is not None:
168
+ attn_weights = attn_weights + attention_mask
169
+
170
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype)
171
+ attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)
172
+ attn_output = torch.matmul(attn_weights, value_states)
173
+ attn_output = attn_output.transpose(1, 2).contiguous()
174
+
175
+ return attn_output, attn_weights
176
+
177
+
178
+ @use_kernelized_func(apply_rotary_pos_emb)
179
+ class DMTDQwen3Attention(nn.Module):
180
+ def __init__(self, config: DMTDQwen3Config, layer_idx: int):
181
+ super().__init__()
182
+ self.layer_type = config.layer_types[layer_idx] if hasattr(config, "layer_types") else None
183
+ self.config = config
184
+ self.layer_idx = layer_idx
185
+ self.head_dim = getattr(config, "head_dim", config.hidden_size // config.num_attention_heads)
186
+ self.num_key_value_groups = config.num_attention_heads // config.num_key_value_heads
187
+ self.scaling = self.head_dim**-0.5
188
+ self.attention_dropout = config.attention_dropout
189
+ self.is_causal = True
190
+
191
+ self.q_proj = nn.Linear(
192
+ config.hidden_size, config.num_attention_heads * self.head_dim, bias=config.attention_bias
193
+ )
194
+ self.k_proj = nn.Linear(
195
+ config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias
196
+ )
197
+ self.v_proj = nn.Linear(
198
+ config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias
199
+ )
200
+ self.o_proj = nn.Linear(
201
+ config.num_attention_heads * self.head_dim, config.hidden_size, bias=config.attention_bias
202
+ )
203
+ self.q_norm = DMTDQwen3RMSNorm(self.head_dim, eps=config.rms_norm_eps)
204
+ self.k_norm = DMTDQwen3RMSNorm(self.head_dim, eps=config.rms_norm_eps)
205
+ self.sliding_window = config.sliding_window if self.layer_type == "sliding_attention" else None
206
+
207
+ def forward(
208
+ self,
209
+ hidden_states: torch.Tensor,
210
+ position_embeddings: tuple[torch.Tensor, torch.Tensor],
211
+ attention_mask: torch.Tensor | None,
212
+ past_key_values: Cache | None = None,
213
+ **kwargs: Unpack[FlashAttentionKwargs],
214
+ ) -> tuple[torch.Tensor, torch.Tensor | None]:
215
+ input_shape = hidden_states.shape[:-1]
216
+ hidden_shape = (*input_shape, -1, self.head_dim)
217
+
218
+ query_states = self.q_norm(self.q_proj(hidden_states).view(hidden_shape)).transpose(1, 2)
219
+ key_states = self.k_norm(self.k_proj(hidden_states).view(hidden_shape)).transpose(1, 2)
220
+ value_states = self.v_proj(hidden_states).view(hidden_shape).transpose(1, 2)
221
+
222
+ cos, sin = position_embeddings
223
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
224
+
225
+ if past_key_values is not None:
226
+ key_states, value_states = past_key_values.update(key_states, value_states, self.layer_idx)
227
+
228
+ attention_interface: Callable = ALL_ATTENTION_FUNCTIONS.get_interface(
229
+ self.config._attn_implementation, eager_attention_forward
230
+ )
231
+
232
+ attn_output, attn_weights = attention_interface(
233
+ self,
234
+ query_states,
235
+ key_states,
236
+ value_states,
237
+ attention_mask,
238
+ dropout=0.0 if not self.training else self.attention_dropout,
239
+ scaling=self.scaling,
240
+ sliding_window=self.sliding_window, # diff with Llama
241
+ **kwargs,
242
+ )
243
+
244
+ attn_output = attn_output.reshape(*input_shape, -1).contiguous()
245
+ attn_output = self.o_proj(attn_output)
246
+ return attn_output, attn_weights
247
+
248
+
249
+ class DMTDQwen3DecoderLayer(GradientCheckpointingLayer):
250
+ def __init__(self, config: DMTDQwen3Config, layer_idx: int):
251
+ super().__init__()
252
+ self.hidden_size = config.hidden_size
253
+
254
+ self.self_attn = DMTDQwen3Attention(config=config, layer_idx=layer_idx)
255
+
256
+ self.mlp = DMTDQwen3MLP(config)
257
+ self.input_layernorm = DMTDQwen3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
258
+ self.post_attention_layernorm = DMTDQwen3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
259
+
260
+ def forward(
261
+ self,
262
+ hidden_states: torch.Tensor,
263
+ attention_mask: torch.Tensor | None = None,
264
+ position_ids: torch.LongTensor | None = None,
265
+ past_key_values: Cache | None = None,
266
+ use_cache: bool | None = False,
267
+ position_embeddings: tuple[torch.Tensor, torch.Tensor] | None = None,
268
+ **kwargs: Unpack[TransformersKwargs],
269
+ ) -> torch.Tensor:
270
+ residual = hidden_states
271
+ hidden_states = self.input_layernorm(hidden_states)
272
+ # Self Attention
273
+ hidden_states, _ = self.self_attn(
274
+ hidden_states=hidden_states,
275
+ attention_mask=attention_mask,
276
+ position_ids=position_ids,
277
+ past_key_values=past_key_values,
278
+ use_cache=use_cache,
279
+ position_embeddings=position_embeddings,
280
+ **kwargs,
281
+ )
282
+ hidden_states = residual + hidden_states
283
+
284
+ # Fully Connected
285
+ residual = hidden_states
286
+ hidden_states = self.post_attention_layernorm(hidden_states)
287
+ hidden_states = self.mlp(hidden_states)
288
+ hidden_states = residual + hidden_states
289
+ return hidden_states
290
+
291
+
292
+ class DMTDQwen3PreTrainedModel(PreTrainedModel):
293
+ config: DMTDQwen3Config
294
+ base_model_prefix = "model"
295
+ supports_gradient_checkpointing = True
296
+ _no_split_modules = ["DMTDQwen3DecoderLayer"]
297
+ _skip_keys_device_placement = ["past_key_values"]
298
+ _supports_flash_attn = True
299
+ _supports_sdpa = True
300
+ _supports_flex_attn = True
301
+
302
+ _can_compile_fullgraph = True
303
+ _supports_attention_backend = True
304
+ _can_record_outputs = {
305
+ "hidden_states": DMTDQwen3DecoderLayer,
306
+ "attentions": DMTDQwen3Attention,
307
+ }
308
+
309
+
310
+ class DMTDQwen3Model(DMTDQwen3PreTrainedModel):
311
+ def __init__(self, config: DMTDQwen3Config):
312
+ super().__init__(config)
313
+ self.padding_idx = config.pad_token_id
314
+ self.vocab_size = config.vocab_size
315
+
316
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
317
+ self.layers = nn.ModuleList(
318
+ [DMTDQwen3DecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
319
+ )
320
+
321
+ # DMTD layer split + cycle length used by the masked-training forward pass.
322
+ self.num_encoding_layers = config.num_encoding_layers
323
+ self.num_thinking_layers = config.num_thinking_layers
324
+ self.num_decoding_layers = config.num_decoding_layers
325
+ self.mtp_horizon = config.mtp_horizon
326
+
327
+ self.norm = DMTDQwen3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
328
+ self.rotary_emb = DMTDQwen3RotaryEmbedding(config=config)
329
+ self.gradient_checkpointing = False
330
+ self.has_sliding_layers = "sliding_attention" in self.config.layer_types
331
+
332
+ # Initialize weights and apply final processing
333
+ self.post_init()
334
+
335
+ @merge_with_config_defaults
336
+ @capture_outputs
337
+ def forward(
338
+ self,
339
+ input_ids: torch.LongTensor | None = None,
340
+ attention_mask: torch.Tensor | None = None,
341
+ position_ids: torch.LongTensor | None = None,
342
+ past_key_values: Cache | None = None,
343
+ inputs_embeds: torch.FloatTensor | None = None,
344
+ use_cache: bool | None = None,
345
+ **kwargs: Unpack[TransformersKwargs],
346
+ ) -> BaseModelOutputWithPast:
347
+ if (input_ids is None) ^ (inputs_embeds is not None):
348
+ raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
349
+
350
+ if inputs_embeds is None:
351
+ inputs_embeds = self.embed_tokens(input_ids)
352
+
353
+ if use_cache and past_key_values is None:
354
+ past_key_values = DynamicCache(config=self.config)
355
+
356
+ if position_ids is None:
357
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
358
+ position_ids = torch.arange(inputs_embeds.shape[1], device=inputs_embeds.device) + past_seen_tokens
359
+ position_ids = position_ids.unsqueeze(0)
360
+
361
+ # It may already have been prepared by e.g. `generate`
362
+ if not isinstance(causal_mask_mapping := attention_mask, dict):
363
+ # Prepare mask arguments
364
+ mask_kwargs = {
365
+ "config": self.config,
366
+ "inputs_embeds": inputs_embeds,
367
+ "attention_mask": attention_mask,
368
+ "past_key_values": past_key_values,
369
+ "position_ids": position_ids,
370
+ }
371
+ # Create the masks
372
+ causal_mask_mapping = {
373
+ "full_attention": create_causal_mask(**mask_kwargs),
374
+ }
375
+ # The sliding window alternating layers are not always activated depending on the config
376
+ if self.has_sliding_layers:
377
+ causal_mask_mapping["sliding_attention"] = create_sliding_window_causal_mask(**mask_kwargs)
378
+
379
+ hidden_states = inputs_embeds
380
+ position_embeddings = self.rotary_emb(hidden_states, position_ids)
381
+
382
+ # Indices delimiting the encoding / thinking / decoding layer groups.
383
+ enc_end = self.num_encoding_layers
384
+ thk_end = enc_end + self.num_thinking_layers
385
+ dec_end = thk_end + self.num_decoding_layers
386
+
387
+ ####################################################################################################
388
+ # Encoding layers: process every position with full layers (no masking).
389
+ for i, decoder_layer in enumerate(self.layers[:enc_end]):
390
+ hidden_states = decoder_layer(
391
+ hidden_states,
392
+ attention_mask=causal_mask_mapping[self.config.layer_types[i]],
393
+ position_embeddings=position_embeddings,
394
+ position_ids=position_ids,
395
+ past_key_values=past_key_values,
396
+ use_cache=use_cache,
397
+ **kwargs,
398
+ )
399
+ # Snapshot of the encoder output; this is what positions OUTSIDE the cycle keep.
400
+ # When num_encoding_layers == 0 this is just the input embeddings.
401
+ encoding_hidden_states = hidden_states
402
+
403
+ ####################################################################################################
404
+ # Thinking layers: deep processing whose output is only routed to cycle positions.
405
+ for i, decoder_layer in enumerate(self.layers[enc_end:thk_end], start=enc_end):
406
+ hidden_states = decoder_layer(
407
+ hidden_states,
408
+ attention_mask=causal_mask_mapping[self.config.layer_types[i]],
409
+ position_embeddings=position_embeddings,
410
+ position_ids=position_ids,
411
+ past_key_values=past_key_values,
412
+ use_cache=use_cache,
413
+ **kwargs,
414
+ )
415
+
416
+ ####################################################################################################
417
+ # DMTD masked training: keep thinking output only at positions p where
418
+ # (p - past_seen_tokens) % mtp_horizon == 0
419
+ # and fall back to encoding_hidden_states elsewhere. This makes the
420
+ # decoder reconstruct the next (mtp_horizon - 1) tokens between cycle
421
+ # positions purely from the cycle slots.
422
+ seq_len = hidden_states.shape[1]
423
+ # Use the absolute position indices (first row, broadcasts across batch) so that
424
+ # the cycle pattern is consistent during cached generation as well.
425
+ cycle_indices = position_ids[0].to(hidden_states.device)
426
+ pattern_mask = (cycle_indices % self.mtp_horizon == 0).to(hidden_states.dtype)
427
+ # Shape: (1, seq_len, 1) — broadcasts over batch and hidden dim.
428
+ routing_masks = pattern_mask.view(1, seq_len, 1)
429
+ hidden_states = encoding_hidden_states + hidden_states * routing_masks
430
+
431
+ ####################################################################################################
432
+ # Decoding layers: read the masked composite representation.
433
+ for i, decoder_layer in enumerate(self.layers[thk_end:dec_end], start=thk_end):
434
+ hidden_states = decoder_layer(
435
+ hidden_states,
436
+ attention_mask=causal_mask_mapping[self.config.layer_types[i]],
437
+ position_embeddings=position_embeddings,
438
+ position_ids=position_ids,
439
+ past_key_values=past_key_values,
440
+ use_cache=use_cache,
441
+ **kwargs,
442
+ )
443
+
444
+ hidden_states = self.norm(hidden_states)
445
+ return BaseModelOutputWithPast(
446
+ last_hidden_state=hidden_states,
447
+ past_key_values=past_key_values if use_cache else None,
448
+ )
449
+
450
+
451
+ class DMTDQwen3ForCausalLM(DMTDQwen3PreTrainedModel, GenerationMixin):
452
+ _tied_weights_keys = {"lm_head.weight": "model.embed_tokens.weight"}
453
+ _tp_plan = {"lm_head": "colwise_gather_output"}
454
+ _pp_plan = {"lm_head": (["hidden_states"], ["logits"])}
455
+
456
+ def __init__(self, config):
457
+ super().__init__(config)
458
+ self.model = DMTDQwen3Model(config)
459
+ self.vocab_size = config.vocab_size
460
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
461
+
462
+ # Initialize weights and apply final processing
463
+ self.post_init()
464
+
465
+ @can_return_tuple
466
+ def forward(
467
+ self,
468
+ input_ids: torch.LongTensor | None = None,
469
+ attention_mask: torch.Tensor | None = None,
470
+ position_ids: torch.LongTensor | None = None,
471
+ past_key_values: Cache | None = None,
472
+ inputs_embeds: torch.FloatTensor | None = None,
473
+ labels: torch.LongTensor | None = None,
474
+ use_cache: bool | None = None,
475
+ logits_to_keep: int | torch.Tensor = 0,
476
+ **kwargs: Unpack[TransformersKwargs],
477
+ ) -> CausalLMOutputWithPast:
478
+ outputs: BaseModelOutputWithPast = self.model(
479
+ input_ids=input_ids,
480
+ attention_mask=attention_mask,
481
+ position_ids=position_ids,
482
+ past_key_values=past_key_values,
483
+ inputs_embeds=inputs_embeds,
484
+ use_cache=use_cache,
485
+ **kwargs,
486
+ )
487
+
488
+ hidden_states = outputs.last_hidden_state
489
+ # Only compute necessary logits, and do not upcast them to float if we are not computing the loss
490
+ slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep
491
+ logits = self.lm_head(hidden_states[:, slice_indices, :])
492
+
493
+ loss = None
494
+ if labels is not None:
495
+ loss = self.loss_function(logits=logits, labels=labels, vocab_size=self.config.vocab_size, **kwargs)
496
+
497
+ return CausalLMOutputWithPast(
498
+ loss=loss,
499
+ logits=logits,
500
+ past_key_values=outputs.past_key_values,
501
+ hidden_states=outputs.hidden_states,
502
+ attentions=outputs.attentions,
503
+ )
504
+
505
+
506
+ class DMTDQwen3ForSequenceClassification(GenericForSequenceClassification, DMTDQwen3PreTrainedModel):
507
+ pass
508
+
509
+
510
+ class DMTDQwen3ForTokenClassification(GenericForTokenClassification, DMTDQwen3PreTrainedModel):
511
+ pass
512
+
513
+
514
+ class DMTDQwen3ForQuestionAnswering(GenericForQuestionAnswering, DMTDQwen3PreTrainedModel):
515
+ base_model_prefix = "transformer" # For BC, where `transformer` was used instead of `model`
516
+
517
+
518
+ __all__ = [
519
+ "DMTDQwen3ForCausalLM",
520
+ "DMTDQwen3ForQuestionAnswering",
521
+ "DMTDQwen3PreTrainedModel",
522
+ "DMTDQwen3Model",
523
+ "DMTDQwen3ForSequenceClassification",
524
+ "DMTDQwen3ForTokenClassification",
525
+ ]
DMTD-E0D8C4/register_dmtdqwen3.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Register DMTD Qwen3 for ms-swift (import via --external_plugins).
2
+ from swift.model import Model, ModelGroup, ModelMeta, register_model
3
+ from swift.model.model_arch import ModelArch
4
+ from swift.template.constant import TemplateType
5
+
6
+ register_model(
7
+ ModelMeta(
8
+ 'dmtdqwen3',
9
+ [
10
+ ModelGroup(
11
+ [
12
+ Model(model_path='.'),
13
+ ],
14
+ TemplateType.qwen3,
15
+ ),
16
+ ],
17
+ template=TemplateType.qwen3,
18
+ architectures=['DMTDQwen3ForCausalLM'],
19
+ model_arch=ModelArch.llama,
20
+ requires=['transformers>=4.51'],
21
+ ),
22
+ exist_ok=True,
23
+ )
DMTD-E0D8C4/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be75606093db2094d7cd20f3c2f385c212750648bd6ea4fb2bf507a6a4c55506
3
+ size 11422650
DMTD-E0D8C4/tokenizer_config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|im_end|>",
7
+ "errors": "replace",
8
+ "extra_special_tokens": [
9
+ "<|im_start|>",
10
+ "<|im_end|>",
11
+ "<|object_ref_start|>",
12
+ "<|object_ref_end|>",
13
+ "<|box_start|>",
14
+ "<|box_end|>",
15
+ "<|quad_start|>",
16
+ "<|quad_end|>",
17
+ "<|vision_start|>",
18
+ "<|vision_end|>",
19
+ "<|vision_pad|>",
20
+ "<|image_pad|>",
21
+ "<|video_pad|>"
22
+ ],
23
+ "is_local": false,
24
+ "local_files_only": false,
25
+ "model_max_length": 131072,
26
+ "pad_token": "<|endoftext|>",
27
+ "split_special_tokens": false,
28
+ "tokenizer_class": "Qwen2Tokenizer",
29
+ "unk_token": null
30
+ }
Qwen3-am-distilled/chat_template.jinja ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 message.content is string 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.content is string %}
27
+ {%- set content = message.content %}
28
+ {%- else %}
29
+ {%- set content = '' %}
30
+ {%- endif %}
31
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
+ {%- elif message.role == "assistant" %}
34
+ {%- set reasoning_content = '' %}
35
+ {%- if message.reasoning_content is string %}
36
+ {%- set reasoning_content = message.reasoning_content %}
37
+ {%- else %}
38
+ {%- if '</think>' in content %}
39
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
+ {%- endif %}
42
+ {%- endif %}
43
+ {%- if loop.index0 > ns.last_query_index %}
44
+ {%- if loop.last or (not loop.last and reasoning_content) %}
45
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
46
+ {%- else %}
47
+ {{- '<|im_start|>' + message.role + '\n' + content }}
48
+ {%- endif %}
49
+ {%- else %}
50
+ {{- '<|im_start|>' + message.role + '\n' + content }}
51
+ {%- endif %}
52
+ {%- if message.tool_calls %}
53
+ {%- for tool_call in message.tool_calls %}
54
+ {%- if (loop.first and content) or (not loop.first) %}
55
+ {{- '\n' }}
56
+ {%- endif %}
57
+ {%- if tool_call.function %}
58
+ {%- set tool_call = tool_call.function %}
59
+ {%- endif %}
60
+ {{- '<tool_call>\n{"name": "' }}
61
+ {{- tool_call.name }}
62
+ {{- '", "arguments": ' }}
63
+ {%- if tool_call.arguments is string %}
64
+ {{- tool_call.arguments }}
65
+ {%- else %}
66
+ {{- tool_call.arguments | tojson }}
67
+ {%- endif %}
68
+ {{- '}\n</tool_call>' }}
69
+ {%- endfor %}
70
+ {%- endif %}
71
+ {{- '<|im_end|>\n' }}
72
+ {%- elif message.role == "tool" %}
73
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
74
+ {{- '<|im_start|>user' }}
75
+ {%- endif %}
76
+ {{- '\n<tool_response>\n' }}
77
+ {{- content }}
78
+ {{- '\n</tool_response>' }}
79
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
80
+ {{- '<|im_end|>\n' }}
81
+ {%- endif %}
82
+ {%- endif %}
83
+ {%- endfor %}
84
+ {%- if add_generation_prompt %}
85
+ {{- '<|im_start|>assistant\n' }}
86
+ {%- if enable_thinking is defined and enable_thinking is false %}
87
+ {{- '<think>\n\n</think>\n\n' }}
88
+ {%- endif %}
89
+ {%- endif %}
Qwen3-am-distilled/config.json ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DMTDQwen3ForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_dmtdqwen3.DMTDQwen3Config",
9
+ "AutoModel": "modeling_dmtdqwen3.DMTDQwen3Model",
10
+ "AutoModelForCausalLM": "modeling_dmtdqwen3.DMTDQwen3ForCausalLM"
11
+ },
12
+ "bos_token_id": null,
13
+ "dtype": "bfloat16",
14
+ "eos_token_id": 151645,
15
+ "head_dim": 128,
16
+ "hidden_act": "silu",
17
+ "hidden_size": 2560,
18
+ "initializer_range": 0.02,
19
+ "intermediate_size": 9728,
20
+ "layer_types": [
21
+ "full_attention",
22
+ "full_attention",
23
+ "full_attention",
24
+ "full_attention",
25
+ "full_attention",
26
+ "full_attention",
27
+ "full_attention",
28
+ "full_attention",
29
+ "full_attention",
30
+ "full_attention",
31
+ "full_attention",
32
+ "full_attention",
33
+ "full_attention",
34
+ "full_attention",
35
+ "full_attention",
36
+ "full_attention",
37
+ "full_attention",
38
+ "full_attention",
39
+ "full_attention",
40
+ "full_attention",
41
+ "full_attention",
42
+ "full_attention",
43
+ "full_attention",
44
+ "full_attention",
45
+ "full_attention",
46
+ "full_attention",
47
+ "full_attention",
48
+ "full_attention",
49
+ "full_attention",
50
+ "full_attention",
51
+ "full_attention",
52
+ "full_attention",
53
+ "full_attention",
54
+ "full_attention",
55
+ "full_attention",
56
+ "full_attention"
57
+ ],
58
+ "max_position_embeddings": 40960,
59
+ "max_window_layers": 36,
60
+ "model_type": "dmtdqwen3",
61
+ "num_attention_heads": 32,
62
+ "num_hidden_layers": 36,
63
+ "num_key_value_heads": 8,
64
+ "pad_token_id": 151643,
65
+ "rms_norm_eps": 1e-06,
66
+ "rope_parameters": {
67
+ "rope_theta": 1000000,
68
+ "rope_type": "default"
69
+ },
70
+ "sliding_window": null,
71
+ "tie_word_embeddings": true,
72
+ "transformers_version": "5.6.2",
73
+ "use_cache": false,
74
+ "use_sliding_window": false,
75
+ "vocab_size": 151936
76
+ }
Qwen3-am-distilled/configuration_dmtdqwen3.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """DMTDQwen3 model configuration"""
15
+
16
+ from dataclasses import field
17
+
18
+ from huggingface_hub.dataclasses import strict
19
+
20
+ from transformers.configuration_utils import PreTrainedConfig
21
+ from transformers.modeling_rope_utils import RopeParameters
22
+
23
+
24
+ @strict
25
+ class DMTDQwen3Config(PreTrainedConfig):
26
+ model_type = "dmtdqwen3"
27
+ keys_to_ignore_at_inference = ["past_key_values"]
28
+
29
+ base_model_tp_plan = {
30
+ "layers.*.self_attn.q_proj": "colwise",
31
+ "layers.*.self_attn.k_proj": "colwise",
32
+ "layers.*.self_attn.v_proj": "colwise",
33
+ "layers.*.self_attn.q_norm": "replicated_with_grad_allreduce",
34
+ "layers.*.self_attn.k_norm": "replicated_with_grad_allreduce",
35
+ "layers.*.self_attn.o_proj": "rowwise",
36
+ "layers.*.mlp.gate_proj": "colwise",
37
+ "layers.*.mlp.up_proj": "colwise",
38
+ "layers.*.mlp.down_proj": "rowwise",
39
+ }
40
+ base_model_pp_plan = {
41
+ "embed_tokens": (["input_ids"], ["inputs_embeds"]),
42
+ "layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
43
+ "norm": (["hidden_states"], ["hidden_states"]),
44
+ }
45
+
46
+ vocab_size: int = 151936
47
+ hidden_size: int = 2560
48
+ intermediate_size: int = 9728
49
+ num_hidden_layers: int = 36
50
+ num_attention_heads: int = 32
51
+ num_key_value_heads: int | None = 8
52
+ head_dim: int = 128
53
+ hidden_act: str = "silu"
54
+ max_position_embeddings: int = 40960
55
+ initializer_range: float = 0.02
56
+ rms_norm_eps: float = 1e-6
57
+ use_cache: bool = True
58
+ tie_word_embeddings: bool = True
59
+ rope_parameters: RopeParameters | dict | None = field(
60
+ default_factory=lambda: {"rope_type": "default", "rope_theta": 1000000}
61
+ )
62
+ attention_bias: bool = False
63
+ use_sliding_window: bool = False
64
+ sliding_window: int | None = 4096
65
+ max_window_layers: int = 36
66
+ layer_types: list[str] | None = None
67
+ attention_dropout: float | int = 0.0
68
+ pad_token_id: int | None = None
69
+ bos_token_id: int | None = 151643
70
+ eos_token_id: int | list[int] | None = 151645
71
+
72
+ def __post_init__(self, **kwargs):
73
+ self.sliding_window = self.sliding_window if self.use_sliding_window else None
74
+ if self.num_key_value_heads is None:
75
+ self.num_key_value_heads = self.num_attention_heads
76
+
77
+ if self.layer_types is None:
78
+ self.layer_types = [
79
+ "sliding_attention"
80
+ if self.sliding_window is not None and i >= self.max_window_layers
81
+ else "full_attention"
82
+ for i in range(self.num_hidden_layers)
83
+ ]
84
+ super().__post_init__(**kwargs)
85
+
86
+
87
+ __all__ = ["DMTDQwen3Config"]
Qwen3-am-distilled/generation_config.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 151643,
4
+ "eos_token_id": [
5
+ 151645,
6
+ 151643
7
+ ],
8
+ "output_attentions": false,
9
+ "output_hidden_states": false,
10
+ "transformers_version": "5.6.2",
11
+ "use_cache": true
12
+ }
Qwen3-am-distilled/model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f41d01b42ce65d95441f6829856a56b526b227509f32d40fbb8a65ecaa24cbd
3
+ size 4990818672
Qwen3-am-distilled/model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:87406b8dccdb1182fc7cd1bb20ae0ed580e2a10a80b59f6775cdf121a23624bf
3
+ size 3054163328
Qwen3-am-distilled/model.safetensors.index.json ADDED
@@ -0,0 +1,406 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_parameters": 4022468096,
4
+ "total_size": 8044936192
5
+ },
6
+ "weight_map": {
7
+ "model.embed_tokens.weight": "model-00001-of-00002.safetensors",
8
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
9
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
10
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
11
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
12
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
13
+ "model.layers.0.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
14
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
15
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
16
+ "model.layers.0.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
17
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
18
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
19
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
20
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
21
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
22
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
23
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
24
+ "model.layers.1.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
25
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
26
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
27
+ "model.layers.1.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
28
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
29
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
30
+ "model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
31
+ "model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
32
+ "model.layers.10.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
33
+ "model.layers.10.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
34
+ "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
35
+ "model.layers.10.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
36
+ "model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
37
+ "model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
38
+ "model.layers.10.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
39
+ "model.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
40
+ "model.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
41
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
42
+ "model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
43
+ "model.layers.11.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
44
+ "model.layers.11.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
45
+ "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
46
+ "model.layers.11.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
47
+ "model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
48
+ "model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
49
+ "model.layers.11.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
50
+ "model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
51
+ "model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
52
+ "model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
53
+ "model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
54
+ "model.layers.12.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
55
+ "model.layers.12.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
56
+ "model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
57
+ "model.layers.12.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
58
+ "model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
59
+ "model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
60
+ "model.layers.12.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
61
+ "model.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
62
+ "model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
63
+ "model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
64
+ "model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
65
+ "model.layers.13.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
66
+ "model.layers.13.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
67
+ "model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
68
+ "model.layers.13.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
69
+ "model.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
70
+ "model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
71
+ "model.layers.13.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
72
+ "model.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
73
+ "model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
74
+ "model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
75
+ "model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
76
+ "model.layers.14.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
77
+ "model.layers.14.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
78
+ "model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
79
+ "model.layers.14.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
80
+ "model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
81
+ "model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
82
+ "model.layers.14.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
83
+ "model.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
84
+ "model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
85
+ "model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
86
+ "model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
87
+ "model.layers.15.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
88
+ "model.layers.15.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
89
+ "model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
90
+ "model.layers.15.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
91
+ "model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
92
+ "model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
93
+ "model.layers.15.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
94
+ "model.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
95
+ "model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
96
+ "model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
97
+ "model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
98
+ "model.layers.16.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
99
+ "model.layers.16.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
100
+ "model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
101
+ "model.layers.16.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
102
+ "model.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
103
+ "model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
104
+ "model.layers.16.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
105
+ "model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
106
+ "model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
107
+ "model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
108
+ "model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
109
+ "model.layers.17.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
110
+ "model.layers.17.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
111
+ "model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
112
+ "model.layers.17.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
113
+ "model.layers.17.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
114
+ "model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
115
+ "model.layers.17.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
116
+ "model.layers.17.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
117
+ "model.layers.17.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
118
+ "model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
119
+ "model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
120
+ "model.layers.18.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
121
+ "model.layers.18.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
122
+ "model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
123
+ "model.layers.18.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
124
+ "model.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
125
+ "model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
126
+ "model.layers.18.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
127
+ "model.layers.18.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
128
+ "model.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
129
+ "model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
130
+ "model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
131
+ "model.layers.19.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
132
+ "model.layers.19.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
133
+ "model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
134
+ "model.layers.19.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
135
+ "model.layers.19.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
136
+ "model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
137
+ "model.layers.19.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
138
+ "model.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
139
+ "model.layers.19.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
140
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
141
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
142
+ "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
143
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
144
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
145
+ "model.layers.2.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
146
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
147
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
148
+ "model.layers.2.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
149
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
150
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
151
+ "model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
152
+ "model.layers.20.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
153
+ "model.layers.20.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
154
+ "model.layers.20.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
155
+ "model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
156
+ "model.layers.20.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
157
+ "model.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
158
+ "model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
159
+ "model.layers.20.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
160
+ "model.layers.20.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
161
+ "model.layers.20.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
162
+ "model.layers.21.input_layernorm.weight": "model-00002-of-00002.safetensors",
163
+ "model.layers.21.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
164
+ "model.layers.21.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
165
+ "model.layers.21.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
166
+ "model.layers.21.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
167
+ "model.layers.21.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
168
+ "model.layers.21.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
169
+ "model.layers.21.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
170
+ "model.layers.21.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
171
+ "model.layers.21.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
172
+ "model.layers.21.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
173
+ "model.layers.22.input_layernorm.weight": "model-00002-of-00002.safetensors",
174
+ "model.layers.22.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
175
+ "model.layers.22.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
176
+ "model.layers.22.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
177
+ "model.layers.22.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
178
+ "model.layers.22.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
179
+ "model.layers.22.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
180
+ "model.layers.22.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
181
+ "model.layers.22.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
182
+ "model.layers.22.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
183
+ "model.layers.22.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
184
+ "model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors",
185
+ "model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
186
+ "model.layers.23.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
187
+ "model.layers.23.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
188
+ "model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
189
+ "model.layers.23.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
190
+ "model.layers.23.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
191
+ "model.layers.23.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
192
+ "model.layers.23.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
193
+ "model.layers.23.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
194
+ "model.layers.23.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
195
+ "model.layers.24.input_layernorm.weight": "model-00002-of-00002.safetensors",
196
+ "model.layers.24.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
197
+ "model.layers.24.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
198
+ "model.layers.24.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
199
+ "model.layers.24.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
200
+ "model.layers.24.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
201
+ "model.layers.24.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
202
+ "model.layers.24.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
203
+ "model.layers.24.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
204
+ "model.layers.24.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
205
+ "model.layers.24.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
206
+ "model.layers.25.input_layernorm.weight": "model-00002-of-00002.safetensors",
207
+ "model.layers.25.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
208
+ "model.layers.25.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
209
+ "model.layers.25.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
210
+ "model.layers.25.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
211
+ "model.layers.25.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
212
+ "model.layers.25.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
213
+ "model.layers.25.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
214
+ "model.layers.25.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
215
+ "model.layers.25.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
216
+ "model.layers.25.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
217
+ "model.layers.26.input_layernorm.weight": "model-00002-of-00002.safetensors",
218
+ "model.layers.26.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
219
+ "model.layers.26.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
220
+ "model.layers.26.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
221
+ "model.layers.26.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
222
+ "model.layers.26.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
223
+ "model.layers.26.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
224
+ "model.layers.26.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
225
+ "model.layers.26.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
226
+ "model.layers.26.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
227
+ "model.layers.26.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
228
+ "model.layers.27.input_layernorm.weight": "model-00002-of-00002.safetensors",
229
+ "model.layers.27.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
230
+ "model.layers.27.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
231
+ "model.layers.27.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
232
+ "model.layers.27.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
233
+ "model.layers.27.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
234
+ "model.layers.27.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
235
+ "model.layers.27.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
236
+ "model.layers.27.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
237
+ "model.layers.27.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
238
+ "model.layers.27.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
239
+ "model.layers.28.input_layernorm.weight": "model-00002-of-00002.safetensors",
240
+ "model.layers.28.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
241
+ "model.layers.28.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
242
+ "model.layers.28.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
243
+ "model.layers.28.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
244
+ "model.layers.28.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
245
+ "model.layers.28.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
246
+ "model.layers.28.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
247
+ "model.layers.28.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
248
+ "model.layers.28.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
249
+ "model.layers.28.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
250
+ "model.layers.29.input_layernorm.weight": "model-00002-of-00002.safetensors",
251
+ "model.layers.29.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
252
+ "model.layers.29.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
253
+ "model.layers.29.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
254
+ "model.layers.29.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
255
+ "model.layers.29.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
256
+ "model.layers.29.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
257
+ "model.layers.29.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
258
+ "model.layers.29.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
259
+ "model.layers.29.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
260
+ "model.layers.29.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
261
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
262
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
263
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
264
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
265
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
266
+ "model.layers.3.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
267
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
268
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
269
+ "model.layers.3.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
270
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
271
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
272
+ "model.layers.30.input_layernorm.weight": "model-00002-of-00002.safetensors",
273
+ "model.layers.30.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
274
+ "model.layers.30.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
275
+ "model.layers.30.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
276
+ "model.layers.30.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
277
+ "model.layers.30.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
278
+ "model.layers.30.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
279
+ "model.layers.30.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
280
+ "model.layers.30.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
281
+ "model.layers.30.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
282
+ "model.layers.30.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
283
+ "model.layers.31.input_layernorm.weight": "model-00002-of-00002.safetensors",
284
+ "model.layers.31.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
285
+ "model.layers.31.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
286
+ "model.layers.31.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
287
+ "model.layers.31.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
288
+ "model.layers.31.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
289
+ "model.layers.31.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
290
+ "model.layers.31.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
291
+ "model.layers.31.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
292
+ "model.layers.31.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
293
+ "model.layers.31.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
294
+ "model.layers.32.input_layernorm.weight": "model-00002-of-00002.safetensors",
295
+ "model.layers.32.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
296
+ "model.layers.32.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
297
+ "model.layers.32.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
298
+ "model.layers.32.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
299
+ "model.layers.32.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
300
+ "model.layers.32.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
301
+ "model.layers.32.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
302
+ "model.layers.32.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
303
+ "model.layers.32.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
304
+ "model.layers.32.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
305
+ "model.layers.33.input_layernorm.weight": "model-00002-of-00002.safetensors",
306
+ "model.layers.33.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
307
+ "model.layers.33.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
308
+ "model.layers.33.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
309
+ "model.layers.33.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
310
+ "model.layers.33.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
311
+ "model.layers.33.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
312
+ "model.layers.33.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
313
+ "model.layers.33.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
314
+ "model.layers.33.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
315
+ "model.layers.33.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
316
+ "model.layers.34.input_layernorm.weight": "model-00002-of-00002.safetensors",
317
+ "model.layers.34.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
318
+ "model.layers.34.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
319
+ "model.layers.34.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
320
+ "model.layers.34.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
321
+ "model.layers.34.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
322
+ "model.layers.34.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
323
+ "model.layers.34.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
324
+ "model.layers.34.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
325
+ "model.layers.34.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
326
+ "model.layers.34.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
327
+ "model.layers.35.input_layernorm.weight": "model-00002-of-00002.safetensors",
328
+ "model.layers.35.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
329
+ "model.layers.35.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
330
+ "model.layers.35.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
331
+ "model.layers.35.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
332
+ "model.layers.35.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
333
+ "model.layers.35.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
334
+ "model.layers.35.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
335
+ "model.layers.35.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
336
+ "model.layers.35.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
337
+ "model.layers.35.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
338
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
339
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
340
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
341
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
342
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
343
+ "model.layers.4.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
344
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
345
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
346
+ "model.layers.4.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
347
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
348
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
349
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
350
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
351
+ "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
352
+ "model.layers.5.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
353
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
354
+ "model.layers.5.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
355
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
356
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
357
+ "model.layers.5.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
358
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
359
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
360
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
361
+ "model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
362
+ "model.layers.6.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
363
+ "model.layers.6.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
364
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
365
+ "model.layers.6.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
366
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
367
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
368
+ "model.layers.6.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
369
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
370
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
371
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
372
+ "model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
373
+ "model.layers.7.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
374
+ "model.layers.7.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
375
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
376
+ "model.layers.7.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
377
+ "model.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
378
+ "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
379
+ "model.layers.7.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
380
+ "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
381
+ "model.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
382
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
383
+ "model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
384
+ "model.layers.8.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
385
+ "model.layers.8.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
386
+ "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
387
+ "model.layers.8.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
388
+ "model.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
389
+ "model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
390
+ "model.layers.8.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
391
+ "model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
392
+ "model.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
393
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
394
+ "model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
395
+ "model.layers.9.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
396
+ "model.layers.9.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
397
+ "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
398
+ "model.layers.9.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
399
+ "model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
400
+ "model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
401
+ "model.layers.9.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
402
+ "model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
403
+ "model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
404
+ "model.norm.weight": "model-00002-of-00002.safetensors"
405
+ }
406
+ }
Qwen3-am-distilled/modeling_dmtdqwen3.py ADDED
@@ -0,0 +1,467 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2025 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from collections.abc import Callable
16
+ from typing import Optional
17
+
18
+ import torch
19
+ from torch import nn
20
+
21
+ from transformers.activations import ACT2FN
22
+ from transformers.cache_utils import Cache, DynamicCache
23
+ from transformers.generation import GenerationMixin
24
+ from transformers.integrations import use_kernel_forward_from_hub, use_kernel_func_from_hub, use_kernelized_func
25
+ from transformers.masking_utils import create_causal_mask, create_sliding_window_causal_mask
26
+ from transformers.modeling_flash_attention_utils import FlashAttentionKwargs
27
+ from transformers.modeling_layers import (
28
+ GenericForQuestionAnswering,
29
+ GenericForSequenceClassification,
30
+ GenericForTokenClassification,
31
+ GradientCheckpointingLayer,
32
+ )
33
+ from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
34
+ from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
35
+ from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
36
+ from transformers.processing_utils import Unpack
37
+ from transformers.utils import TransformersKwargs, can_return_tuple
38
+ from transformers.utils.generic import maybe_autocast, merge_with_config_defaults
39
+ from transformers.utils.output_capturing import capture_outputs
40
+ from .configuration_dmtdqwen3 import DMTDQwen3Config
41
+
42
+
43
+ @use_kernel_forward_from_hub("RMSNorm")
44
+ class DMTDQwen3RMSNorm(nn.Module):
45
+ def __init__(self, hidden_size, eps: float = 1e-6) -> None:
46
+ super().__init__()
47
+ self.weight = nn.Parameter(torch.ones(hidden_size))
48
+ self.variance_epsilon = eps
49
+
50
+ def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
51
+ input_dtype = hidden_states.dtype
52
+ hidden_states = hidden_states.to(torch.float32)
53
+ variance = hidden_states.pow(2).mean(-1, keepdim=True)
54
+ hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
55
+ return self.weight * hidden_states.to(input_dtype)
56
+
57
+ def extra_repr(self):
58
+ return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
59
+
60
+
61
+ class DMTDQwen3MLP(nn.Module):
62
+ def __init__(self, config):
63
+ super().__init__()
64
+ self.config = config
65
+ self.hidden_size = config.hidden_size
66
+ self.intermediate_size = config.intermediate_size
67
+ self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
68
+ self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
69
+ self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
70
+ self.act_fn = ACT2FN[config.hidden_act]
71
+
72
+ def forward(self, x):
73
+ down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
74
+ return down_proj
75
+
76
+
77
+ class DMTDQwen3RotaryEmbedding(nn.Module):
78
+ inv_freq: torch.Tensor # fix linting for `register_buffer`
79
+
80
+ def __init__(self, config: DMTDQwen3Config, device=None):
81
+ super().__init__()
82
+ self.max_seq_len_cached = config.max_position_embeddings
83
+ self.original_max_seq_len = config.max_position_embeddings
84
+
85
+ self.config = config
86
+
87
+ self.rope_type = self.config.rope_parameters["rope_type"]
88
+ rope_init_fn: Callable = self.compute_default_rope_parameters
89
+ if self.rope_type != "default":
90
+ rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
91
+ inv_freq, self.attention_scaling = rope_init_fn(self.config, device)
92
+
93
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
94
+ self.register_buffer("original_inv_freq", inv_freq.clone(), persistent=False)
95
+
96
+ @staticmethod
97
+ def compute_default_rope_parameters(
98
+ config: DMTDQwen3Config | None = None,
99
+ device: Optional["torch.device"] = None,
100
+ seq_len: int | None = None,
101
+ ) -> tuple["torch.Tensor", float]:
102
+ base = config.rope_parameters["rope_theta"]
103
+ dim = getattr(config, "head_dim", None) or config.hidden_size // config.num_attention_heads
104
+
105
+ attention_factor = 1.0 # Unused in this type of RoPE
106
+
107
+ # Compute the inverse frequencies
108
+ inv_freq = 1.0 / (
109
+ base ** (torch.arange(0, dim, 2, dtype=torch.int64).to(device=device, dtype=torch.float) / dim)
110
+ )
111
+ return inv_freq, attention_factor
112
+
113
+ @torch.no_grad()
114
+ @dynamic_rope_update # power user: used with advanced RoPE types (e.g. dynamic rope)
115
+ def forward(self, x, position_ids):
116
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device)
117
+ position_ids_expanded = position_ids[:, None, :].float()
118
+
119
+ device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu"
120
+ with maybe_autocast(device_type=device_type, enabled=False): # Force float32
121
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
122
+ emb = torch.cat((freqs, freqs), dim=-1)
123
+ cos = emb.cos() * self.attention_scaling
124
+ sin = emb.sin() * self.attention_scaling
125
+
126
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
127
+
128
+
129
+ def rotate_half(x):
130
+ """Rotates half the hidden dims of the input."""
131
+ x1 = x[..., : x.shape[-1] // 2]
132
+ x2 = x[..., x.shape[-1] // 2 :]
133
+ return torch.cat((-x2, x1), dim=-1)
134
+
135
+
136
+ @use_kernel_func_from_hub("rotary_pos_emb")
137
+ def apply_rotary_pos_emb(q, k, cos, sin, unsqueeze_dim=1):
138
+ cos = cos.unsqueeze(unsqueeze_dim)
139
+ sin = sin.unsqueeze(unsqueeze_dim)
140
+ q_embed = (q * cos) + (rotate_half(q) * sin)
141
+ k_embed = (k * cos) + (rotate_half(k) * sin)
142
+ return q_embed, k_embed
143
+
144
+
145
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
146
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
147
+ if n_rep == 1:
148
+ return hidden_states
149
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
150
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
151
+
152
+
153
+ def eager_attention_forward(
154
+ module: nn.Module,
155
+ query: torch.Tensor,
156
+ key: torch.Tensor,
157
+ value: torch.Tensor,
158
+ attention_mask: torch.Tensor | None,
159
+ scaling: float,
160
+ dropout: float = 0.0,
161
+ **kwargs: Unpack[TransformersKwargs],
162
+ ):
163
+ key_states = repeat_kv(key, module.num_key_value_groups)
164
+ value_states = repeat_kv(value, module.num_key_value_groups)
165
+
166
+ attn_weights = torch.matmul(query, key_states.transpose(2, 3)) * scaling
167
+ if attention_mask is not None:
168
+ attn_weights = attn_weights + attention_mask
169
+
170
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype)
171
+ attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)
172
+ attn_output = torch.matmul(attn_weights, value_states)
173
+ attn_output = attn_output.transpose(1, 2).contiguous()
174
+
175
+ return attn_output, attn_weights
176
+
177
+
178
+ @use_kernelized_func(apply_rotary_pos_emb)
179
+ class DMTDQwen3Attention(nn.Module):
180
+ def __init__(self, config: DMTDQwen3Config, layer_idx: int):
181
+ super().__init__()
182
+ self.layer_type = config.layer_types[layer_idx] if hasattr(config, "layer_types") else None
183
+ self.config = config
184
+ self.layer_idx = layer_idx
185
+ self.head_dim = getattr(config, "head_dim", config.hidden_size // config.num_attention_heads)
186
+ self.num_key_value_groups = config.num_attention_heads // config.num_key_value_heads
187
+ self.scaling = self.head_dim**-0.5
188
+ self.attention_dropout = config.attention_dropout
189
+ self.is_causal = True
190
+
191
+ self.q_proj = nn.Linear(
192
+ config.hidden_size, config.num_attention_heads * self.head_dim, bias=config.attention_bias
193
+ )
194
+ self.k_proj = nn.Linear(
195
+ config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias
196
+ )
197
+ self.v_proj = nn.Linear(
198
+ config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias
199
+ )
200
+ self.o_proj = nn.Linear(
201
+ config.num_attention_heads * self.head_dim, config.hidden_size, bias=config.attention_bias
202
+ )
203
+ self.q_norm = DMTDQwen3RMSNorm(self.head_dim, eps=config.rms_norm_eps)
204
+ self.k_norm = DMTDQwen3RMSNorm(self.head_dim, eps=config.rms_norm_eps)
205
+ self.sliding_window = config.sliding_window if self.layer_type == "sliding_attention" else None
206
+
207
+ def forward(
208
+ self,
209
+ hidden_states: torch.Tensor,
210
+ position_embeddings: tuple[torch.Tensor, torch.Tensor],
211
+ attention_mask: torch.Tensor | None,
212
+ past_key_values: Cache | None = None,
213
+ **kwargs: Unpack[FlashAttentionKwargs],
214
+ ) -> tuple[torch.Tensor, torch.Tensor | None]:
215
+ input_shape = hidden_states.shape[:-1]
216
+ hidden_shape = (*input_shape, -1, self.head_dim)
217
+
218
+ query_states = self.q_norm(self.q_proj(hidden_states).view(hidden_shape)).transpose(1, 2)
219
+ key_states = self.k_norm(self.k_proj(hidden_states).view(hidden_shape)).transpose(1, 2)
220
+ value_states = self.v_proj(hidden_states).view(hidden_shape).transpose(1, 2)
221
+
222
+ cos, sin = position_embeddings
223
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
224
+
225
+ if past_key_values is not None:
226
+ key_states, value_states = past_key_values.update(key_states, value_states, self.layer_idx)
227
+
228
+ attention_interface: Callable = ALL_ATTENTION_FUNCTIONS.get_interface(
229
+ self.config._attn_implementation, eager_attention_forward
230
+ )
231
+
232
+ attn_output, attn_weights = attention_interface(
233
+ self,
234
+ query_states,
235
+ key_states,
236
+ value_states,
237
+ attention_mask,
238
+ dropout=0.0 if not self.training else self.attention_dropout,
239
+ scaling=self.scaling,
240
+ sliding_window=self.sliding_window, # diff with Llama
241
+ **kwargs,
242
+ )
243
+
244
+ attn_output = attn_output.reshape(*input_shape, -1).contiguous()
245
+ attn_output = self.o_proj(attn_output)
246
+ return attn_output, attn_weights
247
+
248
+
249
+ class DMTDQwen3DecoderLayer(GradientCheckpointingLayer):
250
+ def __init__(self, config: DMTDQwen3Config, layer_idx: int):
251
+ super().__init__()
252
+ self.hidden_size = config.hidden_size
253
+
254
+ self.self_attn = DMTDQwen3Attention(config=config, layer_idx=layer_idx)
255
+
256
+ self.mlp = DMTDQwen3MLP(config)
257
+ self.input_layernorm = DMTDQwen3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
258
+ self.post_attention_layernorm = DMTDQwen3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
259
+
260
+ def forward(
261
+ self,
262
+ hidden_states: torch.Tensor,
263
+ attention_mask: torch.Tensor | None = None,
264
+ position_ids: torch.LongTensor | None = None,
265
+ past_key_values: Cache | None = None,
266
+ use_cache: bool | None = False,
267
+ position_embeddings: tuple[torch.Tensor, torch.Tensor] | None = None,
268
+ **kwargs: Unpack[TransformersKwargs],
269
+ ) -> torch.Tensor:
270
+ residual = hidden_states
271
+ hidden_states = self.input_layernorm(hidden_states)
272
+ # Self Attention
273
+ hidden_states, _ = self.self_attn(
274
+ hidden_states=hidden_states,
275
+ attention_mask=attention_mask,
276
+ position_ids=position_ids,
277
+ past_key_values=past_key_values,
278
+ use_cache=use_cache,
279
+ position_embeddings=position_embeddings,
280
+ **kwargs,
281
+ )
282
+ hidden_states = residual + hidden_states
283
+
284
+ # Fully Connected
285
+ residual = hidden_states
286
+ hidden_states = self.post_attention_layernorm(hidden_states)
287
+ hidden_states = self.mlp(hidden_states)
288
+ hidden_states = residual + hidden_states
289
+ return hidden_states
290
+
291
+
292
+ class DMTDQwen3PreTrainedModel(PreTrainedModel):
293
+ config: DMTDQwen3Config
294
+ base_model_prefix = "model"
295
+ supports_gradient_checkpointing = True
296
+ _no_split_modules = ["DMTDQwen3DecoderLayer"]
297
+ _skip_keys_device_placement = ["past_key_values"]
298
+ _supports_flash_attn = True
299
+ _supports_sdpa = True
300
+ _supports_flex_attn = True
301
+
302
+ _can_compile_fullgraph = True
303
+ _supports_attention_backend = True
304
+ _can_record_outputs = {
305
+ "hidden_states": DMTDQwen3DecoderLayer,
306
+ "attentions": DMTDQwen3Attention,
307
+ }
308
+
309
+
310
+ class DMTDQwen3Model(DMTDQwen3PreTrainedModel):
311
+ def __init__(self, config: DMTDQwen3Config):
312
+ super().__init__(config)
313
+ self.padding_idx = config.pad_token_id
314
+ self.vocab_size = config.vocab_size
315
+
316
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
317
+ self.layers = nn.ModuleList(
318
+ [DMTDQwen3DecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
319
+ )
320
+ self.norm = DMTDQwen3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
321
+ self.rotary_emb = DMTDQwen3RotaryEmbedding(config=config)
322
+ self.gradient_checkpointing = False
323
+ self.has_sliding_layers = "sliding_attention" in self.config.layer_types
324
+
325
+ # Initialize weights and apply final processing
326
+ self.post_init()
327
+
328
+ @merge_with_config_defaults
329
+ @capture_outputs
330
+ def forward(
331
+ self,
332
+ input_ids: torch.LongTensor | None = None,
333
+ attention_mask: torch.Tensor | None = None,
334
+ position_ids: torch.LongTensor | None = None,
335
+ past_key_values: Cache | None = None,
336
+ inputs_embeds: torch.FloatTensor | None = None,
337
+ use_cache: bool | None = None,
338
+ **kwargs: Unpack[TransformersKwargs],
339
+ ) -> BaseModelOutputWithPast:
340
+ if (input_ids is None) ^ (inputs_embeds is not None):
341
+ raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
342
+
343
+ if inputs_embeds is None:
344
+ inputs_embeds = self.embed_tokens(input_ids)
345
+
346
+ if use_cache and past_key_values is None:
347
+ past_key_values = DynamicCache(config=self.config)
348
+
349
+ if position_ids is None:
350
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
351
+ position_ids = torch.arange(inputs_embeds.shape[1], device=inputs_embeds.device) + past_seen_tokens
352
+ position_ids = position_ids.unsqueeze(0)
353
+
354
+ # It may already have been prepared by e.g. `generate`
355
+ if not isinstance(causal_mask_mapping := attention_mask, dict):
356
+ # Prepare mask arguments
357
+ mask_kwargs = {
358
+ "config": self.config,
359
+ "inputs_embeds": inputs_embeds,
360
+ "attention_mask": attention_mask,
361
+ "past_key_values": past_key_values,
362
+ "position_ids": position_ids,
363
+ }
364
+ # Create the masks
365
+ causal_mask_mapping = {
366
+ "full_attention": create_causal_mask(**mask_kwargs),
367
+ }
368
+ # The sliding window alternating layers are not always activated depending on the config
369
+ if self.has_sliding_layers:
370
+ causal_mask_mapping["sliding_attention"] = create_sliding_window_causal_mask(**mask_kwargs)
371
+
372
+ hidden_states = inputs_embeds
373
+ position_embeddings = self.rotary_emb(hidden_states, position_ids)
374
+
375
+ for i, decoder_layer in enumerate(self.layers[: self.config.num_hidden_layers]):
376
+ hidden_states = decoder_layer(
377
+ hidden_states,
378
+ attention_mask=causal_mask_mapping[self.config.layer_types[i]],
379
+ position_embeddings=position_embeddings,
380
+ position_ids=position_ids,
381
+ past_key_values=past_key_values,
382
+ use_cache=use_cache,
383
+ **kwargs,
384
+ )
385
+
386
+ hidden_states = self.norm(hidden_states)
387
+ return BaseModelOutputWithPast(
388
+ last_hidden_state=hidden_states,
389
+ past_key_values=past_key_values if use_cache else None,
390
+ )
391
+
392
+
393
+ class DMTDQwen3ForCausalLM(DMTDQwen3PreTrainedModel, GenerationMixin):
394
+ _tied_weights_keys = {"lm_head.weight": "model.embed_tokens.weight"}
395
+ _tp_plan = {"lm_head": "colwise_gather_output"}
396
+ _pp_plan = {"lm_head": (["hidden_states"], ["logits"])}
397
+
398
+ def __init__(self, config):
399
+ super().__init__(config)
400
+ self.model = DMTDQwen3Model(config)
401
+ self.vocab_size = config.vocab_size
402
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
403
+
404
+ # Initialize weights and apply final processing
405
+ self.post_init()
406
+
407
+ @can_return_tuple
408
+ def forward(
409
+ self,
410
+ input_ids: torch.LongTensor | None = None,
411
+ attention_mask: torch.Tensor | None = None,
412
+ position_ids: torch.LongTensor | None = None,
413
+ past_key_values: Cache | None = None,
414
+ inputs_embeds: torch.FloatTensor | None = None,
415
+ labels: torch.LongTensor | None = None,
416
+ use_cache: bool | None = None,
417
+ logits_to_keep: int | torch.Tensor = 0,
418
+ **kwargs: Unpack[TransformersKwargs],
419
+ ) -> CausalLMOutputWithPast:
420
+ outputs: BaseModelOutputWithPast = self.model(
421
+ input_ids=input_ids,
422
+ attention_mask=attention_mask,
423
+ position_ids=position_ids,
424
+ past_key_values=past_key_values,
425
+ inputs_embeds=inputs_embeds,
426
+ use_cache=use_cache,
427
+ **kwargs,
428
+ )
429
+
430
+ hidden_states = outputs.last_hidden_state
431
+ # Only compute necessary logits, and do not upcast them to float if we are not computing the loss
432
+ slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep
433
+ logits = self.lm_head(hidden_states[:, slice_indices, :])
434
+
435
+ loss = None
436
+ if labels is not None:
437
+ loss = self.loss_function(logits=logits, labels=labels, vocab_size=self.config.vocab_size, **kwargs)
438
+
439
+ return CausalLMOutputWithPast(
440
+ loss=loss,
441
+ logits=logits,
442
+ past_key_values=outputs.past_key_values,
443
+ hidden_states=outputs.hidden_states,
444
+ attentions=outputs.attentions,
445
+ )
446
+
447
+
448
+ class DMTDQwen3ForSequenceClassification(GenericForSequenceClassification, DMTDQwen3PreTrainedModel):
449
+ pass
450
+
451
+
452
+ class DMTDQwen3ForTokenClassification(GenericForTokenClassification, DMTDQwen3PreTrainedModel):
453
+ pass
454
+
455
+
456
+ class DMTDQwen3ForQuestionAnswering(GenericForQuestionAnswering, DMTDQwen3PreTrainedModel):
457
+ base_model_prefix = "transformer" # For BC, where `transformer` was used instead of `model`
458
+
459
+
460
+ __all__ = [
461
+ "DMTDQwen3ForCausalLM",
462
+ "DMTDQwen3ForQuestionAnswering",
463
+ "DMTDQwen3PreTrainedModel",
464
+ "DMTDQwen3Model",
465
+ "DMTDQwen3ForSequenceClassification",
466
+ "DMTDQwen3ForTokenClassification",
467
+ ]
Qwen3-am-distilled/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be75606093db2094d7cd20f3c2f385c212750648bd6ea4fb2bf507a6a4c55506
3
+ size 11422650
Qwen3-am-distilled/tokenizer_config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|im_end|>",
7
+ "errors": "replace",
8
+ "extra_special_tokens": [
9
+ "<|im_start|>",
10
+ "<|im_end|>",
11
+ "<|object_ref_start|>",
12
+ "<|object_ref_end|>",
13
+ "<|box_start|>",
14
+ "<|box_end|>",
15
+ "<|quad_start|>",
16
+ "<|quad_end|>",
17
+ "<|vision_start|>",
18
+ "<|vision_end|>",
19
+ "<|vision_pad|>",
20
+ "<|image_pad|>",
21
+ "<|video_pad|>"
22
+ ],
23
+ "is_local": true,
24
+ "local_files_only": false,
25
+ "model_max_length": 131072,
26
+ "pad_token": "<|endoftext|>",
27
+ "split_special_tokens": false,
28
+ "tokenizer_class": "Qwen2Tokenizer",
29
+ "unk_token": null
30
+ }