diff --git a/.gitattributes b/.gitattributes index a6344aac8c09253b3b630fb776ae94478aa0275b..52373fe24473b1aa44333d318f578ae6bf04b49b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text *tfevents* filter=lfs diff=lfs merge=lfs -text +tokenizer.json filter=lfs diff=lfs merge=lfs -text diff --git a/chat_template.jinja b/chat_template.jinja new file mode 100644 index 0000000000000000000000000000000000000000..41478957aca7a04b7321022e7d1f73de5badd995 --- /dev/null +++ b/chat_template.jinja @@ -0,0 +1,103 @@ +[gMASK] +{%- if tools -%} +<|system|> +# Tools + +You may call one or more functions to assist with the user query. + +You are provided with function signatures within XML tags: + +{% for tool in tools %} +{{ tool | tojson(ensure_ascii=False) }} +{% endfor %} + + +For each function call, output the function name and arguments within the following XML format: +{function-name} +{arg-key-1} +{arg-value-1} +{arg-key-2} +{arg-value-2} +... +{%- endif -%} +{%- macro visible_text(content) -%} + {%- if content is string -%} + {{- content }} + {%- elif content is iterable and content is not mapping -%} + {%- for item in content -%} + {%- if item is mapping and item.type == 'text' -%} + {{- item.text }} + {%- elif item is string -%} + {{- item }} + {%- endif -%} + {%- endfor -%} + {%- else -%} + {{- content }} + {%- endif -%} +{%- endmacro -%} +{%- set ns = namespace(last_user_index=-1) %} +{%- for m in messages %} + {%- if m.role == 'user' %} + {% set ns.last_user_index = loop.index0 -%} + {%- endif %} +{%- endfor %} +{% for m in messages %} +{%- if m.role == 'user' -%}<|user|> +{{ visible_text(m.content) }} +{{- '/nothink' if (enable_thinking is defined and not enable_thinking and not visible_text(m.content).endswith("/nothink")) else '' -}} +{%- elif m.role == 'assistant' -%} +<|assistant|> +{%- set reasoning_content = '' %} +{%- set content = visible_text(m.content) %} +{%- if m.reasoning_content is string %} + {%- set reasoning_content = m.reasoning_content %} +{%- else %} + {%- if '' in content %} + {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') %} + {%- set content = content.split('')[-1].lstrip('\n') %} + {%- endif %} +{%- endif %} +{%- if loop.index0 > ns.last_user_index and reasoning_content -%} +{{ '\n' + reasoning_content.strip() + ''}} +{%- else -%} +{{ '\n' }} +{%- endif -%} +{%- if content.strip() -%} +{{ '\n' + content.strip() }} +{%- endif -%} +{% if m.tool_calls %} +{% for tc in m.tool_calls %} +{%- if tc.function %} + {%- set tc = tc.function %} +{%- endif %} +{{ '\n' + tc.name }} +{% set _args = tc.arguments %} +{% for k, v in _args.items() %} +{{ k }} +{{ v | tojson(ensure_ascii=False) if v is not string else v }} +{% endfor %} +{% endfor %} +{% endif %} +{%- elif m.role == 'tool' -%} +{%- if m.content is string -%} +{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} + {{- '<|observation|>' }} +{%- endif %} +{{- '\n\n' }} +{{- m.content }} +{{- '\n' }} +{%- else -%} +<|observation|>{% for tr in m.content %} + + +{{ tr.output if tr.output is defined else tr }} +{% endfor -%} +{% endif -%} +{%- elif m.role == 'system' -%} +<|system|> +{{ visible_text(m.content) }} +{%- endif -%} +{%- endfor -%} +{%- if add_generation_prompt -%} + <|assistant|>{{- '\n' if (enable_thinking is defined and not enable_thinking) else '' -}} +{%- endif -%} \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000000000000000000000000000000000000..95ce6f89fbd9ccaf18cf2c37659c4d7e61e2c643 --- /dev/null +++ b/config.json @@ -0,0 +1,48 @@ +{ + "architectures": [ + "Glm4SharedMoeForCausalLM" + ], + "attention_bias": true, + "attention_dropout": 0.0, + "auto_map": { + "AutoConfig": "configuration_glm4_shared_moe.Glm4SharedMoeConfig", + "AutoModel": "modeling_glm4_shared_moe.Glm4SharedMoeModel", + "AutoModelForCausalLM": "modeling_glm4_shared_moe.Glm4SharedMoeForCausalLM" + }, + "eos_token_id": [ + 151329, + 151336, + 151338 + ], + "first_k_dense_replace": 1, + "head_dim": 128, + "hidden_act": "silu", + "hidden_size": 4096, + "initializer_range": 0.02, + "intermediate_size": 10944, + "max_position_embeddings": 131072, + "model_type": "glm4_shared_moe", + "moe_intermediate_size": 1408, + "n_group": 1, + "n_routed_experts": 128, + "n_shared_experts": 1, + "norm_topk_prob": true, + "num_attention_heads": 96, + "num_experts_per_tok": 8, + "num_hidden_layers": 46, + "num_key_value_heads": 8, + "num_nextn_predict_layers": 1, + "pad_token_id": 151329, + "partial_rotary_factor": 0.5, + "rms_norm_eps": 1e-05, + "rope_scaling": null, + "rope_theta": 1000000, + "routed_scaling_factor": 1.0, + "tie_word_embeddings": false, + "topk_group": 1, + "torch_dtype": "bfloat16", + "transformers_version": "4.54.1", + "use_cache": true, + "use_qk_norm": false, + "vocab_size": 151552 +} diff --git a/configuration_glm4_shared_moe.py b/configuration_glm4_shared_moe.py new file mode 100644 index 0000000000000000000000000000000000000000..c273c214275486b5e9cbf02c99e771f8642e679a --- /dev/null +++ b/configuration_glm4_shared_moe.py @@ -0,0 +1,236 @@ +# coding=utf-8 +# Copyright 2025 The ZhipuAI Inc. team and HuggingFace Inc. team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from transformers.configuration_utils import PretrainedConfig +from transformers.modeling_rope_utils import rope_config_validation + + +class Glm4SharedMoeConfig(PretrainedConfig): + r""" + This is the configuration class to store the configuration of a [`Glm4MoeModel`]. It is used to instantiate a + Glm4Moe model according to the specified arguments, defining the model architecture. Instantiating a configuration + with the defaults will yield a similar configuration to that of [THUDM/GLM-4-100B-A10B](https://huggingface.co/THUDM/GLM-4-100B-A10B). + + Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the + documentation from [`PretrainedConfig`] for more information. + + + Args: + vocab_size (`int`, *optional*, defaults to 151552): + Vocabulary size of the Glm4Moe model. Defines the number of different tokens that can be represented by the + `inputs_ids` passed when calling [`Glm4MoeModel`] + hidden_size (`int`, *optional*, defaults to 4096): + Dimension of the hidden representations. + intermediate_size (`int`, *optional*, defaults to 10944): + Dimension of the MLP representations. + num_hidden_layers (`int`, *optional*, defaults to 46): + Number of hidden layers in the Transformer encoder. + num_attention_heads (`int`, *optional*, defaults to 96): + Number of attention heads for each attention layer in the Transformer encoder. + partial_rotary_factor (`float`, *optional*, defaults to 0.5): + The factor of the partial rotary position. + num_key_value_heads (`int`, *optional*, defaults to 8): + This is the number of key_value heads that should be used to implement Grouped Query Attention. If + `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if + `num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When + converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed + by meanpooling all the original heads within that group. For more details, check out [this + paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to `32`. + + hidden_act (`str` or `function`, *optional*, defaults to `"silu"`): + The non-linear activation function (function or string) in the decoder. + max_position_embeddings (`int`, *optional*, defaults to 131072): + The maximum sequence length that this model might ever be used with. + initializer_range (`float`, *optional*, defaults to 0.02): + The standard deviation of the truncated_normal_initializer for initializing all weight matrices. + rms_norm_eps (`float`, *optional*, defaults to 1e-05): + The epsilon used by the rms normalization layers. + use_cache (`bool`, *optional*, defaults to `True`): + Whether or not the model should return the last key/values attentions (not used by all models). Only + relevant if `config.is_decoder=True`. + tie_word_embeddings (`bool`, *optional*, defaults to `False`): + Whether the model's input and output word embeddings should be tied. + rope_theta (`float`, *optional*, defaults to 10000.0): + The base period of the RoPE embeddings. + rope_scaling (`Dict`, *optional*): + Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type + and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value + accordingly. + Expected contents: + `rope_type` (`str`): + The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope', + 'llama3'], with 'default' being the original RoPE implementation. + `factor` (`float`, *optional*): + Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In + most scaling types, a `factor` of x will enable the model to handle sequences of length x * + original maximum pre-trained length. + `original_max_position_embeddings` (`int`, *optional*): + Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during + pretraining. + `attention_factor` (`float`, *optional*): + Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention + computation. If unspecified, it defaults to value recommended by the implementation, using the + `factor` field to infer the suggested value. + `beta_fast` (`float`, *optional*): + Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear + ramp function. If unspecified, it defaults to 32. + `beta_slow` (`float`, *optional*): + Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear + ramp function. If unspecified, it defaults to 1. + `short_factor` (`list[float]`, *optional*): + Only used with 'longrope'. The scaling factor to be applied to short contexts (< + `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden + size divided by the number of attention heads divided by 2 + `long_factor` (`list[float]`, *optional*): + Only used with 'longrope'. The scaling factor to be applied to long contexts (< + `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden + size divided by the number of attention heads divided by 2 + `low_freq_factor` (`float`, *optional*): + Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE + `high_freq_factor` (`float`, *optional*): + Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE + attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`): + Whether to use a bias in the query, key, value and output projection layers during self-attention. + attention_dropout (`float`, *optional*, defaults to 0.0): + The dropout ratio for the attention probabilities. + moe_intermediate_size (`int`, *optional*, defaults to 1408): + Intermediate size of the routed expert. + num_experts_per_tok (`int`, *optional*, defaults to 8): + number of experts per token. + n_shared_experts (`int`, *optional*, defaults to 1): + Number of shared experts. + n_routed_experts (`int`, *optional*, defaults to 128): + Number of routed experts. + routed_scaling_factor (`float`, *optional*, defaults to 1.0): + Scaling factor or routed experts. + n_group (`int`, *optional*, defaults to 1): + Number of groups for routed experts. + topk_group (`int`, *optional*, defaults to 1): + Number of selected groups for each token(for each token, ensuring the selected experts is only within `topk_group` groups). + first_k_dense_replace (`int`, *optional*, defaults to 1): + Number of dense layers in shallow layers(embed->dense->dense->...->dense->moe->moe...->lm_head). + \--k dense layers--/ + norm_topk_prob (`bool`, *optional*, defaults to `True`): + Whether to normalize the topk probabilities. + use_qk_norm (`bool`, *optional*, defaults to `False`): + Whether to use query-key normalization in the attention + ```python + >>> from transformers import Glm4MoeModel, Glm4MoeConfig + + >>> # Initializing a Glm4Moe style configuration + >>> configuration = Glm4MoeConfig() + + >>> # Initializing a model from the GLM-4-MOE-100B-A10B style configuration + >>> model = Glm4MoeModel(configuration) + + >>> # Accessing the model configuration + >>> configuration = model.config + ```""" + + model_type = "glm4_shared_moe" + keys_to_ignore_at_inference = ["past_key_values"] + + # Default tensor parallel plan for base model `Glm4Moe` + base_model_tp_plan = { + "layers.*.self_attn.q_proj": "colwise", + "layers.*.self_attn.k_proj": "colwise", + "layers.*.self_attn.v_proj": "colwise", + "layers.*.self_attn.o_proj": "rowwise", + "layers.*.mlp.experts.*.gate_proj": "colwise", + "layers.*.mlp.experts.*.up_proj": "colwise", + "layers.*.mlp.experts.*.down_proj": "rowwise", + "layers.*.mlp.gate_proj": "colwise", + "layers.*.mlp.up_proj": "colwise", + "layers.*.mlp.down_proj": "rowwise", + } + base_model_pp_plan = { + "embed_tokens": (["input_ids"], ["inputs_embeds"]), + "layers": (["hidden_states", "attention_mask"], ["hidden_states"]), + "norm": (["hidden_states"], ["hidden_states"]), + } + + def __init__( + self, + vocab_size=151552, + hidden_size=4096, + intermediate_size=10944, + num_hidden_layers=46, + num_attention_heads=96, + partial_rotary_factor=0.5, + num_key_value_heads=8, + hidden_act="silu", + max_position_embeddings=131072, + initializer_range=0.02, + rms_norm_eps=1e-5, + use_cache=True, + tie_word_embeddings=False, + rope_theta=10000.0, + rope_scaling=None, + attention_bias=False, + attention_dropout=0.0, + moe_intermediate_size=1408, + num_experts_per_tok=8, + n_shared_experts=1, + n_routed_experts=128, + routed_scaling_factor=1.0, + n_group=1, + topk_group=1, + first_k_dense_replace=1, + norm_topk_prob=True, + use_qk_norm=False, + **kwargs, + ): + self.vocab_size = vocab_size + self.max_position_embeddings = max_position_embeddings + self.hidden_size = hidden_size + self.intermediate_size = intermediate_size + self.num_hidden_layers = num_hidden_layers + self.num_attention_heads = num_attention_heads + self.partial_rotary_factor = partial_rotary_factor + + self.num_key_value_heads = num_key_value_heads + self.hidden_act = hidden_act + self.initializer_range = initializer_range + self.rms_norm_eps = rms_norm_eps + self.use_cache = use_cache + self.rope_theta = rope_theta + self.rope_scaling = rope_scaling + self.attention_bias = attention_bias + self.attention_dropout = attention_dropout + # Validate the correctness of rotary position embeddings parameters + # BC: if there is a 'type' field, move it to 'rope_type'. + if self.rope_scaling is not None and "type" in self.rope_scaling: + self.rope_scaling["rope_type"] = self.rope_scaling["type"] + rope_config_validation(self) + + # MoE arguments + self.moe_intermediate_size = moe_intermediate_size + self.num_experts_per_tok = num_experts_per_tok + self.n_group = n_group + self.topk_group = topk_group + self.n_shared_experts = n_shared_experts + self.n_routed_experts = n_routed_experts + self.routed_scaling_factor = routed_scaling_factor + self.first_k_dense_replace = first_k_dense_replace + self.norm_topk_prob = norm_topk_prob + self.use_qk_norm = use_qk_norm + + super().__init__( + tie_word_embeddings=tie_word_embeddings, + **kwargs, + ) + + +__all__ = ["Glm4SharedMoeConfig"] diff --git a/convert_hf_to_scm.py b/convert_hf_to_scm.py new file mode 100644 index 0000000000000000000000000000000000000000..1fd773a856db911eb80eaab8ad5ad4b4886c5233 --- /dev/null +++ b/convert_hf_to_scm.py @@ -0,0 +1,126 @@ +import glob +import re +import shutil +import sys + +import accelerate +import torch +from safetensors import safe_open +from configuration_glm4_shared_moe import Glm4SharedMoeConfig +from modeling_glm4_shared_moe import Glm4SharedMoeForCausalLM +from transformers.models.glm4_moe.configuration_glm4_moe import Glm4MoeConfig + +input_model = sys.argv[1] +output_model_path = sys.argv[2] + +auto_map = { + "AutoConfig": "configuration_glm4_shared_moe.Glm4SharedMoeConfig", + "AutoModel": "modeling_glm4_shared_moe.Glm4SharedMoeModel", + "AutoModelForCausalLM": "modeling_glm4_shared_moe.Glm4SharedMoeForCausalLM" +} + +cfg_standard_moe = Glm4MoeConfig.from_pretrained(input_model) +cfg_shared_moe = Glm4SharedMoeConfig( + auto_map=auto_map, + vocab_size=cfg_standard_moe.vocab_size, + hidden_size=cfg_standard_moe.hidden_size, + intermediate_size=cfg_standard_moe.intermediate_size, + num_hidden_layers=cfg_standard_moe.num_hidden_layers, + num_attention_heads=cfg_standard_moe.num_attention_heads, + num_key_value_heads=cfg_standard_moe.num_key_value_heads, + hidden_act=cfg_standard_moe.hidden_act, + max_position_embeddings=cfg_standard_moe.max_position_embeddings, + initializer_range=cfg_standard_moe.initializer_range, + rms_norm_eps=cfg_standard_moe.rms_norm_eps, + use_cache=cfg_standard_moe.use_cache, + tie_word_embeddings=cfg_standard_moe.tie_word_embeddings, + rope_theta=cfg_standard_moe.rope_theta, + rope_scaling=cfg_standard_moe.rope_scaling, + attention_bias=cfg_standard_moe.attention_bias, + attention_dropout=cfg_standard_moe.attention_dropout, + moe_intermediate_size=cfg_standard_moe.moe_intermediate_size, + num_experts_per_tok=cfg_standard_moe.num_experts_per_tok, + n_routed_experts=cfg_standard_moe.n_routed_experts, + n_shared_experts=cfg_standard_moe.n_shared_experts, + norm_topk_prob=cfg_standard_moe.norm_topk_prob, + head_dim=cfg_standard_moe.head_dim, + pad_token_id=cfg_standard_moe.pad_token_id, + eos_token_id=cfg_standard_moe.eos_token_id, + routed_scaling_factor=cfg_standard_moe.routed_scaling_factor, + first_k_dense_replace=cfg_standard_moe.first_k_dense_replace, + num_nextn_predict_layers=cfg_standard_moe.num_nextn_predict_layers, +) + +num_experts = cfg_standard_moe.n_routed_experts + +with accelerate.init_empty_weights(): + model_shared_moe = Glm4SharedMoeForCausalLM(cfg_shared_moe) + +model_shared_moe = model_shared_moe.to(torch.bfloat16) +new_state_dict = {} +pattern = f"{input_model}/model-*-of-*.safetensors" +files = sorted(glob.glob(pattern)) + +if len(files) == 0: + raise FileNotFoundError +tensors = {} + +for file_path in files: + print(f"processing {file_path}") + with safe_open(file_path, framework="pt", device="cpu") as f: + for key in f.keys(): + tensor = f.get_tensor(key) + tensors[key] = tensor + +for key in tensors: + try: + layer_num = int(re.search(r"\d+", key).group()) + if layer_num >= cfg_standard_moe.num_hidden_layers: + continue + except: + pass + if "experts" not in key or "shared_experts" in key: + new_state_dict[key] = tensors[key] + elif "experts.0" in key: + layer_num = int(re.search(r"\d+", key).group()) + new_state_dict[ + f"model.layers.{layer_num}.mlp.moe_mlp.output_experts.weight" + ] = torch.stack( + [ + tensors[f"model.layers.{layer_num}.mlp.experts.{i}.down_proj.weight"] + for i in range(num_experts) + ] + ) + new_state_dict[f"model.layers.{layer_num}.mlp.moe_mlp.experts.weight"] = ( + torch.stack( + [ + torch.cat( + [ + tensors[ + f"model.layers.{layer_num}.mlp.experts.{i}.up_proj.weight" + ], + tensors[ + f"model.layers.{layer_num}.mlp.experts.{i}.gate_proj.weight" + ], + ], + dim=0, + ) + for i in range(num_experts) + ] + ) + ) +model_shared_moe.load_state_dict(new_state_dict, strict=True, assign=True) +model_shared_moe.save_pretrained(output_model_path) +cfg_shared_moe.save_pretrained(output_model_path) + + +shutil.copy( + "modeling_glm4_shared_moe.py", + output_model_path + "/" + "modeling_glm4_shared_moe.py", +) +shutil.copy( + "configuration_glm4_shared_moe.py", + output_model_path + "/" + "configuration_glm4_shared_moe.py", +) +for i in ["chat_template.jinja", "tokenizer_config.json", "tokenizer.json"]: + shutil.copy(input_model + "/" + i, output_model_path + "/" + i) diff --git a/generation_config.json b/generation_config.json new file mode 100644 index 0000000000000000000000000000000000000000..4fdc8b42f40332520174dfd60584ddfe7d68f6a2 --- /dev/null +++ b/generation_config.json @@ -0,0 +1,10 @@ +{ + "_from_model_config": true, + "eos_token_id": [ + 151329, + 151336, + 151338 + ], + "pad_token_id": 151329, + "transformers_version": "4.54.1" +} diff --git a/model-00001-of-00046.safetensors b/model-00001-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..437ecfbaac0d65b8f057de19ed6e773b969db556 --- /dev/null +++ b/model-00001-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d45776392254b275a24e244328e0f6cbce58a31dae011c96560f7c656fcd1c2e +size 4899547528 diff --git a/model-00002-of-00046.safetensors b/model-00002-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..b1c08364f91fb996026a10606c364e376eb0a591 --- /dev/null +++ b/model-00002-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f156975edce2bebc2424265823b7206ef4d01942a5b287060b21072fff5f630 +size 4682987888 diff --git a/model-00003-of-00046.safetensors b/model-00003-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..0481ed1cfafd7cee9c43c089bff4c05491a7fe67 --- /dev/null +++ b/model-00003-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:216f2d894bcf6c49d8fec4d23ce347c5737828a7f56c9fcce8fdd5b8f09a07e4 +size 4682987888 diff --git a/model-00004-of-00046.safetensors b/model-00004-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..116efbe446d50a571e21c292e620515518bcb5ab --- /dev/null +++ b/model-00004-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ebd54e8e5b07c3a92c428d86167908e43df3238d0787d0605bbc647cfa3807d +size 4682987888 diff --git a/model-00005-of-00046.safetensors b/model-00005-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..7f2cd384efba37ed99a069198b6e6bd2e1b1dbea --- /dev/null +++ b/model-00005-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:800c75f575211194ceb2459d75711b2e52a5ce9c368e39e2fc6842552d5bbeec +size 4682987888 diff --git a/model-00006-of-00046.safetensors b/model-00006-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..5b33cbae923e9cd7defdd2f8b71220a0bf78e1a0 --- /dev/null +++ b/model-00006-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a0555893367e37ff2fff426272903404743574de456c20d72a6eb01bb76f9638 +size 4682987888 diff --git a/model-00007-of-00046.safetensors b/model-00007-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..4d0d03498ef5cdad0b3ead178fc8409d060ba0d5 --- /dev/null +++ b/model-00007-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a0d3b02e2d94d6f706ecb171b15c7d31f0a8ca8127ebf65ce1475d1a9adae248 +size 4682987888 diff --git a/model-00008-of-00046.safetensors b/model-00008-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..2ee187507171b99f7ad0a342a4c4e18b8217573d --- /dev/null +++ b/model-00008-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:263f71ee54b5c440b7277922fb1d2366fb5c573bae182c4ab7fb0b6ac0369162 +size 4682987888 diff --git a/model-00009-of-00046.safetensors b/model-00009-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..5e0369f9142f807729f419e6074fbe66d56464ef --- /dev/null +++ b/model-00009-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b825805e3185f279ee194ab2c8261abf547ed01d40971dc1758578da0e43743b +size 4682987888 diff --git a/model-00010-of-00046.safetensors b/model-00010-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..fe644851bb86e9bc699142c4cd4d04221cad9bb3 --- /dev/null +++ b/model-00010-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae61902a0b3805a5b4fbe99cc28280bdbc897d13b10549c784c8d7f5bdb9bdc3 +size 4682987912 diff --git a/model-00011-of-00046.safetensors b/model-00011-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..1d66c858c31c157cfacc90d87567fb1b9559c4ad --- /dev/null +++ b/model-00011-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:95ee704695042ffb44b599b327f51f3a630cbec23831ffa25003386b32990926 +size 4682987904 diff --git a/model-00012-of-00046.safetensors b/model-00012-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..feec884c3d7f8e54decea9ea65647cc1bd3b33fc --- /dev/null +++ b/model-00012-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:445e13c51c454d556b4390de5431f49afd128d1eed971b4ac29676bb67e15295 +size 4682987904 diff --git a/model-00013-of-00046.safetensors b/model-00013-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..59ee3687185dbc34a99eebda1c731607c77301d5 --- /dev/null +++ b/model-00013-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7326b4961c34c17f812e5e19ee55ab1fd694fc68f8e98819e96e862999b5d442 +size 4682987904 diff --git a/model-00014-of-00046.safetensors b/model-00014-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..f30cee8e8ab0d4f6a2dd8f763f200b33cec97d67 --- /dev/null +++ b/model-00014-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfc8befb7da9721cb8528fad81e012ab89b2828fede9a283a7ed20a4332e9746 +size 4682987904 diff --git a/model-00015-of-00046.safetensors b/model-00015-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..c144cb3be742132b7f4dcf1c037701d9dd0565a1 --- /dev/null +++ b/model-00015-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22015ca4df121eb8cfc5acd01354fc369fcf947f51b27652b6d04bba9cb9696b +size 4682987904 diff --git a/model-00016-of-00046.safetensors b/model-00016-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..2373ea8f82febab98705da463858e8935e1919e7 --- /dev/null +++ b/model-00016-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:780a49d1d3e54e7b37b45b9efc0d02eec3140cefe4845bbd077d2c4a71039c59 +size 4682987904 diff --git a/model-00017-of-00046.safetensors b/model-00017-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..de97ede637e3a070a889992ff111bf5ec622b73c --- /dev/null +++ b/model-00017-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0be7537161cee75fbff97df03d9e585104f976b31fb73a098f8975b33b3111c +size 4682987904 diff --git a/model-00018-of-00046.safetensors b/model-00018-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..9f881688f0fc57a63961e6eaf70acefa064b43c8 --- /dev/null +++ b/model-00018-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5528044fab3e165d495b05dfe2076fbaf06457083eecf508b28cee9b3b4ed5f1 +size 4682987904 diff --git a/model-00019-of-00046.safetensors b/model-00019-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..9f511c6d385e46fb0c4b8ebd4a1cc25099b9fd02 --- /dev/null +++ b/model-00019-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f750c39a564577349c7705ec95cd4aeb73624d100df86ad95f7b8b350c2e660 +size 4682987904 diff --git a/model-00020-of-00046.safetensors b/model-00020-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..1b2a3f23c4d3b29ff5b782ee85f4298d2fa824c7 --- /dev/null +++ b/model-00020-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0ce649f5393c57a81707a26439f82d89db5df2bb0e4ffc7b2874192e7a0735c1 +size 4682987904 diff --git a/model-00021-of-00046.safetensors b/model-00021-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..4eb2e6236449b9503f00468c7dd54368b67836fb --- /dev/null +++ b/model-00021-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c67d951bdc8567d6e03d2ca9cd69779a96afeb090edb8e257d78fcd0ffcb33e5 +size 4682987904 diff --git a/model-00022-of-00046.safetensors b/model-00022-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..bd734e30689e7af1dc4cde2b613193a526d39fd9 --- /dev/null +++ b/model-00022-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d1ba8741ebe985e32c17ef26e06526223d306d73ac15f7a6600c24a22e9111ac +size 4682987904 diff --git a/model-00023-of-00046.safetensors b/model-00023-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..b910a11c3f71194a6d9ef2e744f1ee2c35fa037a --- /dev/null +++ b/model-00023-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7de865761fae8c7e3c92fc7e7af3e7ba14a8846c4a97944e410181fc451d2d7 +size 4682987904 diff --git a/model-00024-of-00046.safetensors b/model-00024-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..2f65920443109e2e32358b267d73f2e5c681f30b --- /dev/null +++ b/model-00024-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d1f833392d772aab9f079972ace909b94e28c5c895668f153e35bb9eb100fe8 +size 4682987904 diff --git a/model-00025-of-00046.safetensors b/model-00025-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..e40bd51755d22ececd712dd86985d8a5a23d9258 --- /dev/null +++ b/model-00025-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b734d236f3f095c50c1d1ac72dc8d02ab6a6fd1e90220663a23ea39c1ae591f +size 4682987904 diff --git a/model-00026-of-00046.safetensors b/model-00026-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..b6f1671bf19930ffa5a5ba36ac30f3f944e1d36c --- /dev/null +++ b/model-00026-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:282e19852b5b56b728be3aee8b8f41d516347c4f55722eefa59ac7dc270adfe2 +size 4682987904 diff --git a/model-00027-of-00046.safetensors b/model-00027-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..2e6a0fedd725ff7dd7baac2bed4fbea51b175993 --- /dev/null +++ b/model-00027-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1ca59588d218b55bb4c7cb765788c668a05f1a7acaa8eb50b1864c915b004f96 +size 4682987904 diff --git a/model-00028-of-00046.safetensors b/model-00028-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..e9588c4d7e40facbeeafa3ef05bfea1242707acb --- /dev/null +++ b/model-00028-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28c33a4dce7f4bab03c1816cb0548e3dd18dafd71a990837b5e943649da04b91 +size 4682987904 diff --git a/model-00029-of-00046.safetensors b/model-00029-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..762bd997b6dc68f947d6503a28daf921bb9a2728 --- /dev/null +++ b/model-00029-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f10451b115af4d6c831155d8abce79905c06f5bd42db9551224d2260c2573c37 +size 4682987904 diff --git a/model-00030-of-00046.safetensors b/model-00030-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..754db4b57dd4f9c19e6262a83b4cb178bb9f435b --- /dev/null +++ b/model-00030-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:07c29107055802d27415e2220abf4ac727202bc3abdf8e607c75b4603e8185c2 +size 4682987904 diff --git a/model-00031-of-00046.safetensors b/model-00031-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..fe2c8e6d43fd666396ed22cc8b03256bb117362e --- /dev/null +++ b/model-00031-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d3b8c0fabd37def5075c9cc4510a78f181ae12a4b15c0ea0d9b0907ca8512fce +size 4682987904 diff --git a/model-00032-of-00046.safetensors b/model-00032-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..bfa2570700764c5b5e13d1bfea3ec94c2b15513d --- /dev/null +++ b/model-00032-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ec8480d163b94b1f321309a505ac1d3ea48b3f1fa86ba9ad7df0b3c9112ef36 +size 4682987904 diff --git a/model-00033-of-00046.safetensors b/model-00033-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..3d3687a8dfd88cef03460f680eb0e81d1548ef06 --- /dev/null +++ b/model-00033-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8519f57ab1fbd15324f8939503c61328ae8a60940e892192ca19a927f85bb7ea +size 4682987904 diff --git a/model-00034-of-00046.safetensors b/model-00034-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..dc2d0b6cfd9fd399ce79a9da25ceb80088b90c4d --- /dev/null +++ b/model-00034-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5c8076078d3ccdbdec4d375ad01e65b8c741b35e83bf772f52667b5facf492d3 +size 4682987904 diff --git a/model-00035-of-00046.safetensors b/model-00035-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..b436990b9b0377f7c99208a4289211386c2e259f --- /dev/null +++ b/model-00035-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d64eca561f4471bdb4438150f7a67b147d6acdc1b028cc0b8770ea979c390136 +size 4682987904 diff --git a/model-00036-of-00046.safetensors b/model-00036-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..9ccac20ae344cea383169e0e4f711e4abc2eca2e --- /dev/null +++ b/model-00036-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:79bbc64f7704ff01f30bb3b9038c5a23bb9d068a44577616db7e8854faee8dd3 +size 4682987904 diff --git a/model-00037-of-00046.safetensors b/model-00037-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..dfac5bed87a8ea4f6f7db54b53e81e4e8cb8a1fe --- /dev/null +++ b/model-00037-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:af65b309aa1d7e7e9bec62a56dd40544b19e595eae1071510a66817ff5c2bbef +size 4682987904 diff --git a/model-00038-of-00046.safetensors b/model-00038-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..3324566793412a309258294194235296c8ab16da --- /dev/null +++ b/model-00038-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e1607ec1d64f4b46a26770af361e5be819f919d2aab0b0f4f82fac3753f3ff0a +size 4682987904 diff --git a/model-00039-of-00046.safetensors b/model-00039-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..0ac6bd98f70eaf3940d289b15bb60ac362fc6570 --- /dev/null +++ b/model-00039-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca51aec4dc1b1b456ee324edfa7f4b51c0f74fa80c6458111f6523408adb5dcc +size 4682987904 diff --git a/model-00040-of-00046.safetensors b/model-00040-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..da5e8fbc0b0ff9faa7c96f204334544a4b349117 --- /dev/null +++ b/model-00040-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fcea05440633d1a87c820d1f31c95bd80b372d6937560422153a224dcc966738 +size 4682987904 diff --git a/model-00041-of-00046.safetensors b/model-00041-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..13222fac58ee5e19b92bb197b2740a1c9ce6899c --- /dev/null +++ b/model-00041-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:16d275875245d7c920608dba86e718c3d351a92e4a02d48973647748087e7f75 +size 4682987904 diff --git a/model-00042-of-00046.safetensors b/model-00042-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..e5be5817cf2908acf2214c37a615ec8e82f2f021 --- /dev/null +++ b/model-00042-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:37547c91b22403a1044f3cfc7dc227aae89d483b8103292da9038ace6d50c539 +size 4682987904 diff --git a/model-00043-of-00046.safetensors b/model-00043-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..36e7e0ec3c6e95a6a69503ce8b5d042b76216712 --- /dev/null +++ b/model-00043-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a326957d379158303e37b2ea9f51db985fd0f56d3b5d5343736ad20d943bc84d +size 4682987904 diff --git a/model-00044-of-00046.safetensors b/model-00044-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..28a48a9ba1914e5c54c8513ca7072367c72e9fbf --- /dev/null +++ b/model-00044-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:46ea1d2d23665d8be7493be796b10b3fd2b9ae6193c935f8fd4f6f6489733c4e +size 4682987904 diff --git a/model-00045-of-00046.safetensors b/model-00045-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..9b56dc9f35936e4f385991b6e9efa8e1c81fd934 --- /dev/null +++ b/model-00045-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a3661c735da2ec4079933445b8a001444c760092d3e31d387d4ec7e2c0e9512 +size 4682987904 diff --git a/model-00046-of-00046.safetensors b/model-00046-of-00046.safetensors new file mode 100644 index 0000000000000000000000000000000000000000..29f5b4001500120e3c4ec7c6acadeefb2ec33f77 --- /dev/null +++ b/model-00046-of-00046.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4fae46a9168075e1566974bfa1d7dd2fab9edb477edc6b4965564475ca192c7a +size 2753586856 diff --git a/model.safetensors.index.json b/model.safetensors.index.json new file mode 100644 index 0000000000000000000000000000000000000000..543b9fbe6df5a7e8c9e1ae59dcbee90a2c7f8b46 --- /dev/null +++ b/model.safetensors.index.json @@ -0,0 +1,743 @@ +{ + "metadata": { + "total_parameters": 106852245504, + "total_size": 213704514048 + }, + "weight_map": { + "lm_head.weight": "model-00046-of-00046.safetensors", + "model.embed_tokens.weight": "model-00001-of-00046.safetensors", + "model.layers.0.input_layernorm.weight": "model-00001-of-00046.safetensors", + "model.layers.0.mlp.down_proj.weight": "model-00001-of-00046.safetensors", + "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00046.safetensors", + "model.layers.0.mlp.up_proj.weight": "model-00001-of-00046.safetensors", + "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00046.safetensors", + "model.layers.0.self_attn.k_proj.bias": "model-00001-of-00046.safetensors", + "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00046.safetensors", + "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00046.safetensors", + "model.layers.0.self_attn.q_proj.bias": "model-00001-of-00046.safetensors", + "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00046.safetensors", + "model.layers.0.self_attn.v_proj.bias": "model-00001-of-00046.safetensors", + "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00046.safetensors", + "model.layers.1.input_layernorm.weight": "model-00002-of-00046.safetensors", + "model.layers.1.mlp.gate.e_score_correction_bias": "model-00002-of-00046.safetensors", + "model.layers.1.mlp.gate.weight": "model-00002-of-00046.safetensors", + "model.layers.1.mlp.moe_mlp.experts.weight": "model-00001-of-00046.safetensors", + "model.layers.1.mlp.moe_mlp.output_experts.weight": "model-00002-of-00046.safetensors", + "model.layers.1.mlp.shared_experts.down_proj.weight": "model-00002-of-00046.safetensors", + "model.layers.1.mlp.shared_experts.gate_proj.weight": "model-00002-of-00046.safetensors", + "model.layers.1.mlp.shared_experts.up_proj.weight": "model-00002-of-00046.safetensors", + "model.layers.1.post_attention_layernorm.weight": "model-00002-of-00046.safetensors", + "model.layers.1.self_attn.k_proj.bias": "model-00001-of-00046.safetensors", + "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00046.safetensors", + "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00046.safetensors", + "model.layers.1.self_attn.q_proj.bias": "model-00001-of-00046.safetensors", + "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00046.safetensors", + "model.layers.1.self_attn.v_proj.bias": "model-00001-of-00046.safetensors", + "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00046.safetensors", + "model.layers.10.input_layernorm.weight": "model-00011-of-00046.safetensors", + "model.layers.10.mlp.gate.e_score_correction_bias": "model-00011-of-00046.safetensors", + "model.layers.10.mlp.gate.weight": "model-00011-of-00046.safetensors", + "model.layers.10.mlp.moe_mlp.experts.weight": "model-00010-of-00046.safetensors", + "model.layers.10.mlp.moe_mlp.output_experts.weight": "model-00011-of-00046.safetensors", + "model.layers.10.mlp.shared_experts.down_proj.weight": "model-00011-of-00046.safetensors", + "model.layers.10.mlp.shared_experts.gate_proj.weight": "model-00011-of-00046.safetensors", + "model.layers.10.mlp.shared_experts.up_proj.weight": "model-00011-of-00046.safetensors", + "model.layers.10.post_attention_layernorm.weight": "model-00011-of-00046.safetensors", + "model.layers.10.self_attn.k_proj.bias": "model-00010-of-00046.safetensors", + "model.layers.10.self_attn.k_proj.weight": "model-00010-of-00046.safetensors", + "model.layers.10.self_attn.o_proj.weight": "model-00010-of-00046.safetensors", + "model.layers.10.self_attn.q_proj.bias": "model-00010-of-00046.safetensors", + "model.layers.10.self_attn.q_proj.weight": "model-00010-of-00046.safetensors", + "model.layers.10.self_attn.v_proj.bias": "model-00010-of-00046.safetensors", + "model.layers.10.self_attn.v_proj.weight": "model-00010-of-00046.safetensors", + "model.layers.11.input_layernorm.weight": "model-00012-of-00046.safetensors", + "model.layers.11.mlp.gate.e_score_correction_bias": "model-00012-of-00046.safetensors", + "model.layers.11.mlp.gate.weight": "model-00012-of-00046.safetensors", + "model.layers.11.mlp.moe_mlp.experts.weight": "model-00011-of-00046.safetensors", + "model.layers.11.mlp.moe_mlp.output_experts.weight": "model-00012-of-00046.safetensors", + "model.layers.11.mlp.shared_experts.down_proj.weight": "model-00012-of-00046.safetensors", + "model.layers.11.mlp.shared_experts.gate_proj.weight": "model-00012-of-00046.safetensors", + "model.layers.11.mlp.shared_experts.up_proj.weight": "model-00012-of-00046.safetensors", + "model.layers.11.post_attention_layernorm.weight": "model-00012-of-00046.safetensors", + "model.layers.11.self_attn.k_proj.bias": "model-00011-of-00046.safetensors", + "model.layers.11.self_attn.k_proj.weight": "model-00011-of-00046.safetensors", + "model.layers.11.self_attn.o_proj.weight": "model-00011-of-00046.safetensors", + "model.layers.11.self_attn.q_proj.bias": "model-00011-of-00046.safetensors", + "model.layers.11.self_attn.q_proj.weight": "model-00011-of-00046.safetensors", + "model.layers.11.self_attn.v_proj.bias": "model-00011-of-00046.safetensors", + "model.layers.11.self_attn.v_proj.weight": "model-00011-of-00046.safetensors", + "model.layers.12.input_layernorm.weight": "model-00013-of-00046.safetensors", + "model.layers.12.mlp.gate.e_score_correction_bias": "model-00013-of-00046.safetensors", + "model.layers.12.mlp.gate.weight": "model-00013-of-00046.safetensors", + "model.layers.12.mlp.moe_mlp.experts.weight": "model-00012-of-00046.safetensors", + "model.layers.12.mlp.moe_mlp.output_experts.weight": "model-00013-of-00046.safetensors", + "model.layers.12.mlp.shared_experts.down_proj.weight": "model-00013-of-00046.safetensors", + "model.layers.12.mlp.shared_experts.gate_proj.weight": "model-00013-of-00046.safetensors", + "model.layers.12.mlp.shared_experts.up_proj.weight": "model-00013-of-00046.safetensors", + "model.layers.12.post_attention_layernorm.weight": "model-00013-of-00046.safetensors", + "model.layers.12.self_attn.k_proj.bias": "model-00012-of-00046.safetensors", + "model.layers.12.self_attn.k_proj.weight": "model-00012-of-00046.safetensors", + "model.layers.12.self_attn.o_proj.weight": "model-00012-of-00046.safetensors", + "model.layers.12.self_attn.q_proj.bias": "model-00012-of-00046.safetensors", + "model.layers.12.self_attn.q_proj.weight": "model-00012-of-00046.safetensors", + "model.layers.12.self_attn.v_proj.bias": "model-00012-of-00046.safetensors", + "model.layers.12.self_attn.v_proj.weight": "model-00012-of-00046.safetensors", + "model.layers.13.input_layernorm.weight": "model-00014-of-00046.safetensors", + "model.layers.13.mlp.gate.e_score_correction_bias": "model-00014-of-00046.safetensors", + "model.layers.13.mlp.gate.weight": "model-00014-of-00046.safetensors", + "model.layers.13.mlp.moe_mlp.experts.weight": "model-00013-of-00046.safetensors", + "model.layers.13.mlp.moe_mlp.output_experts.weight": "model-00014-of-00046.safetensors", + "model.layers.13.mlp.shared_experts.down_proj.weight": "model-00014-of-00046.safetensors", + "model.layers.13.mlp.shared_experts.gate_proj.weight": "model-00014-of-00046.safetensors", + "model.layers.13.mlp.shared_experts.up_proj.weight": "model-00014-of-00046.safetensors", + "model.layers.13.post_attention_layernorm.weight": "model-00014-of-00046.safetensors", + "model.layers.13.self_attn.k_proj.bias": "model-00013-of-00046.safetensors", + "model.layers.13.self_attn.k_proj.weight": "model-00013-of-00046.safetensors", + "model.layers.13.self_attn.o_proj.weight": "model-00013-of-00046.safetensors", + "model.layers.13.self_attn.q_proj.bias": "model-00013-of-00046.safetensors", + "model.layers.13.self_attn.q_proj.weight": "model-00013-of-00046.safetensors", + "model.layers.13.self_attn.v_proj.bias": "model-00013-of-00046.safetensors", + "model.layers.13.self_attn.v_proj.weight": "model-00013-of-00046.safetensors", + "model.layers.14.input_layernorm.weight": "model-00015-of-00046.safetensors", + "model.layers.14.mlp.gate.e_score_correction_bias": "model-00015-of-00046.safetensors", + "model.layers.14.mlp.gate.weight": "model-00015-of-00046.safetensors", + "model.layers.14.mlp.moe_mlp.experts.weight": "model-00014-of-00046.safetensors", + "model.layers.14.mlp.moe_mlp.output_experts.weight": "model-00015-of-00046.safetensors", + "model.layers.14.mlp.shared_experts.down_proj.weight": "model-00015-of-00046.safetensors", + "model.layers.14.mlp.shared_experts.gate_proj.weight": "model-00015-of-00046.safetensors", + "model.layers.14.mlp.shared_experts.up_proj.weight": "model-00015-of-00046.safetensors", + "model.layers.14.post_attention_layernorm.weight": "model-00015-of-00046.safetensors", + "model.layers.14.self_attn.k_proj.bias": "model-00014-of-00046.safetensors", + "model.layers.14.self_attn.k_proj.weight": "model-00014-of-00046.safetensors", + "model.layers.14.self_attn.o_proj.weight": "model-00014-of-00046.safetensors", + "model.layers.14.self_attn.q_proj.bias": "model-00014-of-00046.safetensors", + "model.layers.14.self_attn.q_proj.weight": "model-00014-of-00046.safetensors", + "model.layers.14.self_attn.v_proj.bias": "model-00014-of-00046.safetensors", + "model.layers.14.self_attn.v_proj.weight": "model-00014-of-00046.safetensors", + "model.layers.15.input_layernorm.weight": "model-00016-of-00046.safetensors", + "model.layers.15.mlp.gate.e_score_correction_bias": "model-00016-of-00046.safetensors", + "model.layers.15.mlp.gate.weight": "model-00016-of-00046.safetensors", + "model.layers.15.mlp.moe_mlp.experts.weight": "model-00015-of-00046.safetensors", + "model.layers.15.mlp.moe_mlp.output_experts.weight": "model-00016-of-00046.safetensors", + "model.layers.15.mlp.shared_experts.down_proj.weight": "model-00016-of-00046.safetensors", + "model.layers.15.mlp.shared_experts.gate_proj.weight": "model-00016-of-00046.safetensors", + "model.layers.15.mlp.shared_experts.up_proj.weight": "model-00016-of-00046.safetensors", + "model.layers.15.post_attention_layernorm.weight": "model-00016-of-00046.safetensors", + "model.layers.15.self_attn.k_proj.bias": "model-00015-of-00046.safetensors", + "model.layers.15.self_attn.k_proj.weight": "model-00015-of-00046.safetensors", + "model.layers.15.self_attn.o_proj.weight": "model-00015-of-00046.safetensors", + "model.layers.15.self_attn.q_proj.bias": "model-00015-of-00046.safetensors", + "model.layers.15.self_attn.q_proj.weight": "model-00015-of-00046.safetensors", + "model.layers.15.self_attn.v_proj.bias": "model-00015-of-00046.safetensors", + "model.layers.15.self_attn.v_proj.weight": "model-00015-of-00046.safetensors", + "model.layers.16.input_layernorm.weight": "model-00017-of-00046.safetensors", + "model.layers.16.mlp.gate.e_score_correction_bias": "model-00017-of-00046.safetensors", + "model.layers.16.mlp.gate.weight": "model-00017-of-00046.safetensors", + "model.layers.16.mlp.moe_mlp.experts.weight": "model-00016-of-00046.safetensors", + "model.layers.16.mlp.moe_mlp.output_experts.weight": "model-00017-of-00046.safetensors", + "model.layers.16.mlp.shared_experts.down_proj.weight": "model-00017-of-00046.safetensors", + "model.layers.16.mlp.shared_experts.gate_proj.weight": "model-00017-of-00046.safetensors", + "model.layers.16.mlp.shared_experts.up_proj.weight": "model-00017-of-00046.safetensors", + "model.layers.16.post_attention_layernorm.weight": "model-00017-of-00046.safetensors", + "model.layers.16.self_attn.k_proj.bias": "model-00016-of-00046.safetensors", + "model.layers.16.self_attn.k_proj.weight": "model-00016-of-00046.safetensors", + "model.layers.16.self_attn.o_proj.weight": "model-00016-of-00046.safetensors", + "model.layers.16.self_attn.q_proj.bias": "model-00016-of-00046.safetensors", + "model.layers.16.self_attn.q_proj.weight": "model-00016-of-00046.safetensors", + "model.layers.16.self_attn.v_proj.bias": "model-00016-of-00046.safetensors", + "model.layers.16.self_attn.v_proj.weight": "model-00016-of-00046.safetensors", + "model.layers.17.input_layernorm.weight": "model-00018-of-00046.safetensors", + "model.layers.17.mlp.gate.e_score_correction_bias": "model-00018-of-00046.safetensors", + "model.layers.17.mlp.gate.weight": "model-00018-of-00046.safetensors", + "model.layers.17.mlp.moe_mlp.experts.weight": "model-00017-of-00046.safetensors", + "model.layers.17.mlp.moe_mlp.output_experts.weight": "model-00018-of-00046.safetensors", + "model.layers.17.mlp.shared_experts.down_proj.weight": "model-00018-of-00046.safetensors", + "model.layers.17.mlp.shared_experts.gate_proj.weight": "model-00018-of-00046.safetensors", + "model.layers.17.mlp.shared_experts.up_proj.weight": "model-00018-of-00046.safetensors", + "model.layers.17.post_attention_layernorm.weight": "model-00018-of-00046.safetensors", + "model.layers.17.self_attn.k_proj.bias": "model-00017-of-00046.safetensors", + "model.layers.17.self_attn.k_proj.weight": "model-00017-of-00046.safetensors", + "model.layers.17.self_attn.o_proj.weight": "model-00017-of-00046.safetensors", + "model.layers.17.self_attn.q_proj.bias": "model-00017-of-00046.safetensors", + "model.layers.17.self_attn.q_proj.weight": "model-00017-of-00046.safetensors", + "model.layers.17.self_attn.v_proj.bias": "model-00017-of-00046.safetensors", + "model.layers.17.self_attn.v_proj.weight": "model-00017-of-00046.safetensors", + "model.layers.18.input_layernorm.weight": "model-00019-of-00046.safetensors", + "model.layers.18.mlp.gate.e_score_correction_bias": "model-00019-of-00046.safetensors", + "model.layers.18.mlp.gate.weight": "model-00019-of-00046.safetensors", + "model.layers.18.mlp.moe_mlp.experts.weight": "model-00018-of-00046.safetensors", + "model.layers.18.mlp.moe_mlp.output_experts.weight": "model-00019-of-00046.safetensors", + "model.layers.18.mlp.shared_experts.down_proj.weight": "model-00019-of-00046.safetensors", + "model.layers.18.mlp.shared_experts.gate_proj.weight": "model-00019-of-00046.safetensors", + "model.layers.18.mlp.shared_experts.up_proj.weight": "model-00019-of-00046.safetensors", + "model.layers.18.post_attention_layernorm.weight": "model-00019-of-00046.safetensors", + "model.layers.18.self_attn.k_proj.bias": "model-00018-of-00046.safetensors", + "model.layers.18.self_attn.k_proj.weight": "model-00018-of-00046.safetensors", + "model.layers.18.self_attn.o_proj.weight": "model-00018-of-00046.safetensors", + "model.layers.18.self_attn.q_proj.bias": "model-00018-of-00046.safetensors", + "model.layers.18.self_attn.q_proj.weight": "model-00018-of-00046.safetensors", + "model.layers.18.self_attn.v_proj.bias": "model-00018-of-00046.safetensors", + "model.layers.18.self_attn.v_proj.weight": "model-00018-of-00046.safetensors", + "model.layers.19.input_layernorm.weight": "model-00020-of-00046.safetensors", + "model.layers.19.mlp.gate.e_score_correction_bias": "model-00020-of-00046.safetensors", + "model.layers.19.mlp.gate.weight": "model-00020-of-00046.safetensors", + "model.layers.19.mlp.moe_mlp.experts.weight": "model-00019-of-00046.safetensors", + "model.layers.19.mlp.moe_mlp.output_experts.weight": "model-00020-of-00046.safetensors", + "model.layers.19.mlp.shared_experts.down_proj.weight": "model-00020-of-00046.safetensors", + "model.layers.19.mlp.shared_experts.gate_proj.weight": "model-00020-of-00046.safetensors", + "model.layers.19.mlp.shared_experts.up_proj.weight": "model-00020-of-00046.safetensors", + "model.layers.19.post_attention_layernorm.weight": "model-00020-of-00046.safetensors", + "model.layers.19.self_attn.k_proj.bias": "model-00019-of-00046.safetensors", + "model.layers.19.self_attn.k_proj.weight": "model-00019-of-00046.safetensors", + "model.layers.19.self_attn.o_proj.weight": "model-00019-of-00046.safetensors", + "model.layers.19.self_attn.q_proj.bias": "model-00019-of-00046.safetensors", + "model.layers.19.self_attn.q_proj.weight": "model-00019-of-00046.safetensors", + "model.layers.19.self_attn.v_proj.bias": "model-00019-of-00046.safetensors", + "model.layers.19.self_attn.v_proj.weight": "model-00019-of-00046.safetensors", + "model.layers.2.input_layernorm.weight": "model-00003-of-00046.safetensors", + "model.layers.2.mlp.gate.e_score_correction_bias": "model-00003-of-00046.safetensors", + "model.layers.2.mlp.gate.weight": "model-00003-of-00046.safetensors", + "model.layers.2.mlp.moe_mlp.experts.weight": "model-00002-of-00046.safetensors", + "model.layers.2.mlp.moe_mlp.output_experts.weight": "model-00003-of-00046.safetensors", + "model.layers.2.mlp.shared_experts.down_proj.weight": "model-00003-of-00046.safetensors", + "model.layers.2.mlp.shared_experts.gate_proj.weight": "model-00003-of-00046.safetensors", + "model.layers.2.mlp.shared_experts.up_proj.weight": "model-00003-of-00046.safetensors", + "model.layers.2.post_attention_layernorm.weight": "model-00003-of-00046.safetensors", + "model.layers.2.self_attn.k_proj.bias": "model-00002-of-00046.safetensors", + "model.layers.2.self_attn.k_proj.weight": "model-00002-of-00046.safetensors", + "model.layers.2.self_attn.o_proj.weight": "model-00002-of-00046.safetensors", + "model.layers.2.self_attn.q_proj.bias": "model-00002-of-00046.safetensors", + "model.layers.2.self_attn.q_proj.weight": "model-00002-of-00046.safetensors", + "model.layers.2.self_attn.v_proj.bias": "model-00002-of-00046.safetensors", + "model.layers.2.self_attn.v_proj.weight": "model-00002-of-00046.safetensors", + "model.layers.20.input_layernorm.weight": "model-00021-of-00046.safetensors", + "model.layers.20.mlp.gate.e_score_correction_bias": "model-00021-of-00046.safetensors", + "model.layers.20.mlp.gate.weight": "model-00021-of-00046.safetensors", + "model.layers.20.mlp.moe_mlp.experts.weight": "model-00020-of-00046.safetensors", + "model.layers.20.mlp.moe_mlp.output_experts.weight": "model-00021-of-00046.safetensors", + "model.layers.20.mlp.shared_experts.down_proj.weight": "model-00021-of-00046.safetensors", + "model.layers.20.mlp.shared_experts.gate_proj.weight": "model-00021-of-00046.safetensors", + "model.layers.20.mlp.shared_experts.up_proj.weight": "model-00021-of-00046.safetensors", + "model.layers.20.post_attention_layernorm.weight": "model-00021-of-00046.safetensors", + "model.layers.20.self_attn.k_proj.bias": "model-00020-of-00046.safetensors", + "model.layers.20.self_attn.k_proj.weight": "model-00020-of-00046.safetensors", + "model.layers.20.self_attn.o_proj.weight": "model-00020-of-00046.safetensors", + "model.layers.20.self_attn.q_proj.bias": "model-00020-of-00046.safetensors", + "model.layers.20.self_attn.q_proj.weight": "model-00020-of-00046.safetensors", + "model.layers.20.self_attn.v_proj.bias": "model-00020-of-00046.safetensors", + "model.layers.20.self_attn.v_proj.weight": "model-00020-of-00046.safetensors", + "model.layers.21.input_layernorm.weight": "model-00022-of-00046.safetensors", + "model.layers.21.mlp.gate.e_score_correction_bias": "model-00022-of-00046.safetensors", + "model.layers.21.mlp.gate.weight": "model-00022-of-00046.safetensors", + "model.layers.21.mlp.moe_mlp.experts.weight": "model-00021-of-00046.safetensors", + "model.layers.21.mlp.moe_mlp.output_experts.weight": "model-00022-of-00046.safetensors", + "model.layers.21.mlp.shared_experts.down_proj.weight": "model-00022-of-00046.safetensors", + "model.layers.21.mlp.shared_experts.gate_proj.weight": "model-00022-of-00046.safetensors", + "model.layers.21.mlp.shared_experts.up_proj.weight": "model-00022-of-00046.safetensors", + "model.layers.21.post_attention_layernorm.weight": "model-00022-of-00046.safetensors", + "model.layers.21.self_attn.k_proj.bias": "model-00021-of-00046.safetensors", + "model.layers.21.self_attn.k_proj.weight": "model-00021-of-00046.safetensors", + "model.layers.21.self_attn.o_proj.weight": "model-00021-of-00046.safetensors", + "model.layers.21.self_attn.q_proj.bias": "model-00021-of-00046.safetensors", + "model.layers.21.self_attn.q_proj.weight": "model-00021-of-00046.safetensors", + "model.layers.21.self_attn.v_proj.bias": "model-00021-of-00046.safetensors", + "model.layers.21.self_attn.v_proj.weight": "model-00021-of-00046.safetensors", + "model.layers.22.input_layernorm.weight": "model-00023-of-00046.safetensors", + "model.layers.22.mlp.gate.e_score_correction_bias": "model-00023-of-00046.safetensors", + "model.layers.22.mlp.gate.weight": "model-00023-of-00046.safetensors", + "model.layers.22.mlp.moe_mlp.experts.weight": "model-00022-of-00046.safetensors", + "model.layers.22.mlp.moe_mlp.output_experts.weight": "model-00023-of-00046.safetensors", + "model.layers.22.mlp.shared_experts.down_proj.weight": "model-00023-of-00046.safetensors", + "model.layers.22.mlp.shared_experts.gate_proj.weight": "model-00023-of-00046.safetensors", + "model.layers.22.mlp.shared_experts.up_proj.weight": "model-00023-of-00046.safetensors", + "model.layers.22.post_attention_layernorm.weight": "model-00023-of-00046.safetensors", + "model.layers.22.self_attn.k_proj.bias": "model-00022-of-00046.safetensors", + "model.layers.22.self_attn.k_proj.weight": "model-00022-of-00046.safetensors", + "model.layers.22.self_attn.o_proj.weight": "model-00022-of-00046.safetensors", + "model.layers.22.self_attn.q_proj.bias": "model-00022-of-00046.safetensors", + "model.layers.22.self_attn.q_proj.weight": "model-00022-of-00046.safetensors", + "model.layers.22.self_attn.v_proj.bias": "model-00022-of-00046.safetensors", + "model.layers.22.self_attn.v_proj.weight": "model-00022-of-00046.safetensors", + "model.layers.23.input_layernorm.weight": "model-00024-of-00046.safetensors", + "model.layers.23.mlp.gate.e_score_correction_bias": "model-00024-of-00046.safetensors", + "model.layers.23.mlp.gate.weight": "model-00024-of-00046.safetensors", + "model.layers.23.mlp.moe_mlp.experts.weight": "model-00023-of-00046.safetensors", + "model.layers.23.mlp.moe_mlp.output_experts.weight": "model-00024-of-00046.safetensors", + "model.layers.23.mlp.shared_experts.down_proj.weight": "model-00024-of-00046.safetensors", + "model.layers.23.mlp.shared_experts.gate_proj.weight": "model-00024-of-00046.safetensors", + "model.layers.23.mlp.shared_experts.up_proj.weight": "model-00024-of-00046.safetensors", + "model.layers.23.post_attention_layernorm.weight": "model-00024-of-00046.safetensors", + "model.layers.23.self_attn.k_proj.bias": "model-00023-of-00046.safetensors", + "model.layers.23.self_attn.k_proj.weight": "model-00023-of-00046.safetensors", + "model.layers.23.self_attn.o_proj.weight": "model-00023-of-00046.safetensors", + "model.layers.23.self_attn.q_proj.bias": "model-00023-of-00046.safetensors", + "model.layers.23.self_attn.q_proj.weight": "model-00023-of-00046.safetensors", + "model.layers.23.self_attn.v_proj.bias": "model-00023-of-00046.safetensors", + "model.layers.23.self_attn.v_proj.weight": "model-00023-of-00046.safetensors", + "model.layers.24.input_layernorm.weight": "model-00025-of-00046.safetensors", + "model.layers.24.mlp.gate.e_score_correction_bias": "model-00025-of-00046.safetensors", + "model.layers.24.mlp.gate.weight": "model-00025-of-00046.safetensors", + "model.layers.24.mlp.moe_mlp.experts.weight": "model-00024-of-00046.safetensors", + "model.layers.24.mlp.moe_mlp.output_experts.weight": "model-00025-of-00046.safetensors", + "model.layers.24.mlp.shared_experts.down_proj.weight": "model-00025-of-00046.safetensors", + "model.layers.24.mlp.shared_experts.gate_proj.weight": "model-00025-of-00046.safetensors", + "model.layers.24.mlp.shared_experts.up_proj.weight": "model-00025-of-00046.safetensors", + "model.layers.24.post_attention_layernorm.weight": "model-00025-of-00046.safetensors", + "model.layers.24.self_attn.k_proj.bias": "model-00024-of-00046.safetensors", + "model.layers.24.self_attn.k_proj.weight": "model-00024-of-00046.safetensors", + "model.layers.24.self_attn.o_proj.weight": "model-00024-of-00046.safetensors", + "model.layers.24.self_attn.q_proj.bias": "model-00024-of-00046.safetensors", + "model.layers.24.self_attn.q_proj.weight": "model-00024-of-00046.safetensors", + "model.layers.24.self_attn.v_proj.bias": "model-00024-of-00046.safetensors", + "model.layers.24.self_attn.v_proj.weight": "model-00024-of-00046.safetensors", + "model.layers.25.input_layernorm.weight": "model-00026-of-00046.safetensors", + "model.layers.25.mlp.gate.e_score_correction_bias": "model-00026-of-00046.safetensors", + "model.layers.25.mlp.gate.weight": "model-00026-of-00046.safetensors", + "model.layers.25.mlp.moe_mlp.experts.weight": "model-00025-of-00046.safetensors", + "model.layers.25.mlp.moe_mlp.output_experts.weight": "model-00026-of-00046.safetensors", + "model.layers.25.mlp.shared_experts.down_proj.weight": "model-00026-of-00046.safetensors", + "model.layers.25.mlp.shared_experts.gate_proj.weight": "model-00026-of-00046.safetensors", + "model.layers.25.mlp.shared_experts.up_proj.weight": "model-00026-of-00046.safetensors", + "model.layers.25.post_attention_layernorm.weight": "model-00026-of-00046.safetensors", + "model.layers.25.self_attn.k_proj.bias": "model-00025-of-00046.safetensors", + "model.layers.25.self_attn.k_proj.weight": "model-00025-of-00046.safetensors", + "model.layers.25.self_attn.o_proj.weight": "model-00025-of-00046.safetensors", + "model.layers.25.self_attn.q_proj.bias": "model-00025-of-00046.safetensors", + "model.layers.25.self_attn.q_proj.weight": "model-00025-of-00046.safetensors", + "model.layers.25.self_attn.v_proj.bias": "model-00025-of-00046.safetensors", + "model.layers.25.self_attn.v_proj.weight": "model-00025-of-00046.safetensors", + "model.layers.26.input_layernorm.weight": "model-00027-of-00046.safetensors", + "model.layers.26.mlp.gate.e_score_correction_bias": "model-00027-of-00046.safetensors", + "model.layers.26.mlp.gate.weight": "model-00027-of-00046.safetensors", + "model.layers.26.mlp.moe_mlp.experts.weight": "model-00026-of-00046.safetensors", + "model.layers.26.mlp.moe_mlp.output_experts.weight": "model-00027-of-00046.safetensors", + "model.layers.26.mlp.shared_experts.down_proj.weight": "model-00027-of-00046.safetensors", + "model.layers.26.mlp.shared_experts.gate_proj.weight": "model-00027-of-00046.safetensors", + "model.layers.26.mlp.shared_experts.up_proj.weight": "model-00027-of-00046.safetensors", + "model.layers.26.post_attention_layernorm.weight": "model-00027-of-00046.safetensors", + "model.layers.26.self_attn.k_proj.bias": "model-00026-of-00046.safetensors", + "model.layers.26.self_attn.k_proj.weight": "model-00026-of-00046.safetensors", + "model.layers.26.self_attn.o_proj.weight": "model-00026-of-00046.safetensors", + "model.layers.26.self_attn.q_proj.bias": "model-00026-of-00046.safetensors", + "model.layers.26.self_attn.q_proj.weight": "model-00026-of-00046.safetensors", + "model.layers.26.self_attn.v_proj.bias": "model-00026-of-00046.safetensors", + "model.layers.26.self_attn.v_proj.weight": "model-00026-of-00046.safetensors", + "model.layers.27.input_layernorm.weight": "model-00028-of-00046.safetensors", + "model.layers.27.mlp.gate.e_score_correction_bias": "model-00028-of-00046.safetensors", + "model.layers.27.mlp.gate.weight": "model-00028-of-00046.safetensors", + "model.layers.27.mlp.moe_mlp.experts.weight": "model-00027-of-00046.safetensors", + "model.layers.27.mlp.moe_mlp.output_experts.weight": "model-00028-of-00046.safetensors", + "model.layers.27.mlp.shared_experts.down_proj.weight": "model-00028-of-00046.safetensors", + "model.layers.27.mlp.shared_experts.gate_proj.weight": "model-00028-of-00046.safetensors", + "model.layers.27.mlp.shared_experts.up_proj.weight": "model-00028-of-00046.safetensors", + "model.layers.27.post_attention_layernorm.weight": "model-00028-of-00046.safetensors", + "model.layers.27.self_attn.k_proj.bias": "model-00027-of-00046.safetensors", + "model.layers.27.self_attn.k_proj.weight": "model-00027-of-00046.safetensors", + "model.layers.27.self_attn.o_proj.weight": "model-00027-of-00046.safetensors", + "model.layers.27.self_attn.q_proj.bias": "model-00027-of-00046.safetensors", + "model.layers.27.self_attn.q_proj.weight": "model-00027-of-00046.safetensors", + "model.layers.27.self_attn.v_proj.bias": "model-00027-of-00046.safetensors", + "model.layers.27.self_attn.v_proj.weight": "model-00027-of-00046.safetensors", + "model.layers.28.input_layernorm.weight": "model-00029-of-00046.safetensors", + "model.layers.28.mlp.gate.e_score_correction_bias": "model-00029-of-00046.safetensors", + "model.layers.28.mlp.gate.weight": "model-00029-of-00046.safetensors", + "model.layers.28.mlp.moe_mlp.experts.weight": "model-00028-of-00046.safetensors", + "model.layers.28.mlp.moe_mlp.output_experts.weight": "model-00029-of-00046.safetensors", + "model.layers.28.mlp.shared_experts.down_proj.weight": "model-00029-of-00046.safetensors", + "model.layers.28.mlp.shared_experts.gate_proj.weight": "model-00029-of-00046.safetensors", + "model.layers.28.mlp.shared_experts.up_proj.weight": "model-00029-of-00046.safetensors", + "model.layers.28.post_attention_layernorm.weight": "model-00029-of-00046.safetensors", + "model.layers.28.self_attn.k_proj.bias": "model-00028-of-00046.safetensors", + "model.layers.28.self_attn.k_proj.weight": "model-00028-of-00046.safetensors", + "model.layers.28.self_attn.o_proj.weight": "model-00028-of-00046.safetensors", + "model.layers.28.self_attn.q_proj.bias": "model-00028-of-00046.safetensors", + "model.layers.28.self_attn.q_proj.weight": "model-00028-of-00046.safetensors", + "model.layers.28.self_attn.v_proj.bias": "model-00028-of-00046.safetensors", + "model.layers.28.self_attn.v_proj.weight": "model-00028-of-00046.safetensors", + "model.layers.29.input_layernorm.weight": "model-00030-of-00046.safetensors", + "model.layers.29.mlp.gate.e_score_correction_bias": "model-00030-of-00046.safetensors", + "model.layers.29.mlp.gate.weight": "model-00030-of-00046.safetensors", + "model.layers.29.mlp.moe_mlp.experts.weight": "model-00029-of-00046.safetensors", + "model.layers.29.mlp.moe_mlp.output_experts.weight": "model-00030-of-00046.safetensors", + "model.layers.29.mlp.shared_experts.down_proj.weight": "model-00030-of-00046.safetensors", + "model.layers.29.mlp.shared_experts.gate_proj.weight": "model-00030-of-00046.safetensors", + "model.layers.29.mlp.shared_experts.up_proj.weight": "model-00030-of-00046.safetensors", + "model.layers.29.post_attention_layernorm.weight": "model-00030-of-00046.safetensors", + "model.layers.29.self_attn.k_proj.bias": "model-00029-of-00046.safetensors", + "model.layers.29.self_attn.k_proj.weight": "model-00029-of-00046.safetensors", + "model.layers.29.self_attn.o_proj.weight": "model-00029-of-00046.safetensors", + "model.layers.29.self_attn.q_proj.bias": "model-00029-of-00046.safetensors", + "model.layers.29.self_attn.q_proj.weight": "model-00029-of-00046.safetensors", + "model.layers.29.self_attn.v_proj.bias": "model-00029-of-00046.safetensors", + "model.layers.29.self_attn.v_proj.weight": "model-00029-of-00046.safetensors", + "model.layers.3.input_layernorm.weight": "model-00004-of-00046.safetensors", + "model.layers.3.mlp.gate.e_score_correction_bias": "model-00004-of-00046.safetensors", + "model.layers.3.mlp.gate.weight": "model-00004-of-00046.safetensors", + "model.layers.3.mlp.moe_mlp.experts.weight": "model-00003-of-00046.safetensors", + "model.layers.3.mlp.moe_mlp.output_experts.weight": "model-00004-of-00046.safetensors", + "model.layers.3.mlp.shared_experts.down_proj.weight": "model-00004-of-00046.safetensors", + "model.layers.3.mlp.shared_experts.gate_proj.weight": "model-00004-of-00046.safetensors", + "model.layers.3.mlp.shared_experts.up_proj.weight": "model-00004-of-00046.safetensors", + "model.layers.3.post_attention_layernorm.weight": "model-00004-of-00046.safetensors", + "model.layers.3.self_attn.k_proj.bias": "model-00003-of-00046.safetensors", + "model.layers.3.self_attn.k_proj.weight": "model-00003-of-00046.safetensors", + "model.layers.3.self_attn.o_proj.weight": "model-00003-of-00046.safetensors", + "model.layers.3.self_attn.q_proj.bias": "model-00003-of-00046.safetensors", + "model.layers.3.self_attn.q_proj.weight": "model-00003-of-00046.safetensors", + "model.layers.3.self_attn.v_proj.bias": "model-00003-of-00046.safetensors", + "model.layers.3.self_attn.v_proj.weight": "model-00003-of-00046.safetensors", + "model.layers.30.input_layernorm.weight": "model-00031-of-00046.safetensors", + "model.layers.30.mlp.gate.e_score_correction_bias": "model-00031-of-00046.safetensors", + "model.layers.30.mlp.gate.weight": "model-00031-of-00046.safetensors", + "model.layers.30.mlp.moe_mlp.experts.weight": "model-00030-of-00046.safetensors", + "model.layers.30.mlp.moe_mlp.output_experts.weight": "model-00031-of-00046.safetensors", + "model.layers.30.mlp.shared_experts.down_proj.weight": "model-00031-of-00046.safetensors", + "model.layers.30.mlp.shared_experts.gate_proj.weight": "model-00031-of-00046.safetensors", + "model.layers.30.mlp.shared_experts.up_proj.weight": "model-00031-of-00046.safetensors", + "model.layers.30.post_attention_layernorm.weight": "model-00031-of-00046.safetensors", + "model.layers.30.self_attn.k_proj.bias": "model-00030-of-00046.safetensors", + "model.layers.30.self_attn.k_proj.weight": "model-00030-of-00046.safetensors", + "model.layers.30.self_attn.o_proj.weight": "model-00030-of-00046.safetensors", + "model.layers.30.self_attn.q_proj.bias": "model-00030-of-00046.safetensors", + "model.layers.30.self_attn.q_proj.weight": "model-00030-of-00046.safetensors", + "model.layers.30.self_attn.v_proj.bias": "model-00030-of-00046.safetensors", + "model.layers.30.self_attn.v_proj.weight": "model-00030-of-00046.safetensors", + "model.layers.31.input_layernorm.weight": "model-00032-of-00046.safetensors", + "model.layers.31.mlp.gate.e_score_correction_bias": "model-00032-of-00046.safetensors", + "model.layers.31.mlp.gate.weight": "model-00032-of-00046.safetensors", + "model.layers.31.mlp.moe_mlp.experts.weight": "model-00031-of-00046.safetensors", + "model.layers.31.mlp.moe_mlp.output_experts.weight": "model-00032-of-00046.safetensors", + "model.layers.31.mlp.shared_experts.down_proj.weight": "model-00032-of-00046.safetensors", + "model.layers.31.mlp.shared_experts.gate_proj.weight": "model-00032-of-00046.safetensors", + "model.layers.31.mlp.shared_experts.up_proj.weight": "model-00032-of-00046.safetensors", + "model.layers.31.post_attention_layernorm.weight": "model-00032-of-00046.safetensors", + "model.layers.31.self_attn.k_proj.bias": "model-00031-of-00046.safetensors", + "model.layers.31.self_attn.k_proj.weight": "model-00031-of-00046.safetensors", + "model.layers.31.self_attn.o_proj.weight": "model-00031-of-00046.safetensors", + "model.layers.31.self_attn.q_proj.bias": "model-00031-of-00046.safetensors", + "model.layers.31.self_attn.q_proj.weight": "model-00031-of-00046.safetensors", + "model.layers.31.self_attn.v_proj.bias": "model-00031-of-00046.safetensors", + "model.layers.31.self_attn.v_proj.weight": "model-00031-of-00046.safetensors", + "model.layers.32.input_layernorm.weight": "model-00033-of-00046.safetensors", + "model.layers.32.mlp.gate.e_score_correction_bias": "model-00033-of-00046.safetensors", + "model.layers.32.mlp.gate.weight": "model-00033-of-00046.safetensors", + "model.layers.32.mlp.moe_mlp.experts.weight": "model-00032-of-00046.safetensors", + "model.layers.32.mlp.moe_mlp.output_experts.weight": "model-00033-of-00046.safetensors", + "model.layers.32.mlp.shared_experts.down_proj.weight": "model-00033-of-00046.safetensors", + "model.layers.32.mlp.shared_experts.gate_proj.weight": "model-00033-of-00046.safetensors", + "model.layers.32.mlp.shared_experts.up_proj.weight": "model-00033-of-00046.safetensors", + "model.layers.32.post_attention_layernorm.weight": "model-00033-of-00046.safetensors", + "model.layers.32.self_attn.k_proj.bias": "model-00032-of-00046.safetensors", + "model.layers.32.self_attn.k_proj.weight": "model-00032-of-00046.safetensors", + "model.layers.32.self_attn.o_proj.weight": "model-00032-of-00046.safetensors", + "model.layers.32.self_attn.q_proj.bias": "model-00032-of-00046.safetensors", + "model.layers.32.self_attn.q_proj.weight": "model-00032-of-00046.safetensors", + "model.layers.32.self_attn.v_proj.bias": "model-00032-of-00046.safetensors", + "model.layers.32.self_attn.v_proj.weight": "model-00032-of-00046.safetensors", + "model.layers.33.input_layernorm.weight": "model-00034-of-00046.safetensors", + "model.layers.33.mlp.gate.e_score_correction_bias": "model-00034-of-00046.safetensors", + "model.layers.33.mlp.gate.weight": "model-00034-of-00046.safetensors", + "model.layers.33.mlp.moe_mlp.experts.weight": "model-00033-of-00046.safetensors", + "model.layers.33.mlp.moe_mlp.output_experts.weight": "model-00034-of-00046.safetensors", + "model.layers.33.mlp.shared_experts.down_proj.weight": "model-00034-of-00046.safetensors", + "model.layers.33.mlp.shared_experts.gate_proj.weight": "model-00034-of-00046.safetensors", + "model.layers.33.mlp.shared_experts.up_proj.weight": "model-00034-of-00046.safetensors", + "model.layers.33.post_attention_layernorm.weight": "model-00034-of-00046.safetensors", + "model.layers.33.self_attn.k_proj.bias": "model-00033-of-00046.safetensors", + "model.layers.33.self_attn.k_proj.weight": "model-00033-of-00046.safetensors", + "model.layers.33.self_attn.o_proj.weight": "model-00033-of-00046.safetensors", + "model.layers.33.self_attn.q_proj.bias": "model-00033-of-00046.safetensors", + "model.layers.33.self_attn.q_proj.weight": "model-00033-of-00046.safetensors", + "model.layers.33.self_attn.v_proj.bias": "model-00033-of-00046.safetensors", + "model.layers.33.self_attn.v_proj.weight": "model-00033-of-00046.safetensors", + "model.layers.34.input_layernorm.weight": "model-00035-of-00046.safetensors", + "model.layers.34.mlp.gate.e_score_correction_bias": "model-00035-of-00046.safetensors", + "model.layers.34.mlp.gate.weight": "model-00035-of-00046.safetensors", + "model.layers.34.mlp.moe_mlp.experts.weight": "model-00034-of-00046.safetensors", + "model.layers.34.mlp.moe_mlp.output_experts.weight": "model-00035-of-00046.safetensors", + "model.layers.34.mlp.shared_experts.down_proj.weight": "model-00035-of-00046.safetensors", + "model.layers.34.mlp.shared_experts.gate_proj.weight": "model-00035-of-00046.safetensors", + "model.layers.34.mlp.shared_experts.up_proj.weight": "model-00035-of-00046.safetensors", + "model.layers.34.post_attention_layernorm.weight": "model-00035-of-00046.safetensors", + "model.layers.34.self_attn.k_proj.bias": "model-00034-of-00046.safetensors", + "model.layers.34.self_attn.k_proj.weight": "model-00034-of-00046.safetensors", + "model.layers.34.self_attn.o_proj.weight": "model-00034-of-00046.safetensors", + "model.layers.34.self_attn.q_proj.bias": "model-00034-of-00046.safetensors", + "model.layers.34.self_attn.q_proj.weight": "model-00034-of-00046.safetensors", + "model.layers.34.self_attn.v_proj.bias": "model-00034-of-00046.safetensors", + "model.layers.34.self_attn.v_proj.weight": "model-00034-of-00046.safetensors", + "model.layers.35.input_layernorm.weight": "model-00036-of-00046.safetensors", + "model.layers.35.mlp.gate.e_score_correction_bias": "model-00036-of-00046.safetensors", + "model.layers.35.mlp.gate.weight": "model-00036-of-00046.safetensors", + "model.layers.35.mlp.moe_mlp.experts.weight": "model-00035-of-00046.safetensors", + "model.layers.35.mlp.moe_mlp.output_experts.weight": "model-00036-of-00046.safetensors", + "model.layers.35.mlp.shared_experts.down_proj.weight": "model-00036-of-00046.safetensors", + "model.layers.35.mlp.shared_experts.gate_proj.weight": "model-00036-of-00046.safetensors", + "model.layers.35.mlp.shared_experts.up_proj.weight": "model-00036-of-00046.safetensors", + "model.layers.35.post_attention_layernorm.weight": "model-00036-of-00046.safetensors", + "model.layers.35.self_attn.k_proj.bias": "model-00035-of-00046.safetensors", + "model.layers.35.self_attn.k_proj.weight": "model-00035-of-00046.safetensors", + "model.layers.35.self_attn.o_proj.weight": "model-00035-of-00046.safetensors", + "model.layers.35.self_attn.q_proj.bias": "model-00035-of-00046.safetensors", + "model.layers.35.self_attn.q_proj.weight": "model-00035-of-00046.safetensors", + "model.layers.35.self_attn.v_proj.bias": "model-00035-of-00046.safetensors", + "model.layers.35.self_attn.v_proj.weight": "model-00035-of-00046.safetensors", + "model.layers.36.input_layernorm.weight": "model-00037-of-00046.safetensors", + "model.layers.36.mlp.gate.e_score_correction_bias": "model-00037-of-00046.safetensors", + "model.layers.36.mlp.gate.weight": "model-00037-of-00046.safetensors", + "model.layers.36.mlp.moe_mlp.experts.weight": "model-00036-of-00046.safetensors", + "model.layers.36.mlp.moe_mlp.output_experts.weight": "model-00037-of-00046.safetensors", + "model.layers.36.mlp.shared_experts.down_proj.weight": "model-00037-of-00046.safetensors", + "model.layers.36.mlp.shared_experts.gate_proj.weight": "model-00037-of-00046.safetensors", + "model.layers.36.mlp.shared_experts.up_proj.weight": "model-00037-of-00046.safetensors", + "model.layers.36.post_attention_layernorm.weight": "model-00037-of-00046.safetensors", + "model.layers.36.self_attn.k_proj.bias": "model-00036-of-00046.safetensors", + "model.layers.36.self_attn.k_proj.weight": "model-00036-of-00046.safetensors", + "model.layers.36.self_attn.o_proj.weight": "model-00036-of-00046.safetensors", + "model.layers.36.self_attn.q_proj.bias": "model-00036-of-00046.safetensors", + "model.layers.36.self_attn.q_proj.weight": "model-00036-of-00046.safetensors", + "model.layers.36.self_attn.v_proj.bias": "model-00036-of-00046.safetensors", + "model.layers.36.self_attn.v_proj.weight": "model-00036-of-00046.safetensors", + "model.layers.37.input_layernorm.weight": "model-00038-of-00046.safetensors", + "model.layers.37.mlp.gate.e_score_correction_bias": "model-00038-of-00046.safetensors", + "model.layers.37.mlp.gate.weight": "model-00038-of-00046.safetensors", + "model.layers.37.mlp.moe_mlp.experts.weight": "model-00037-of-00046.safetensors", + "model.layers.37.mlp.moe_mlp.output_experts.weight": "model-00038-of-00046.safetensors", + "model.layers.37.mlp.shared_experts.down_proj.weight": "model-00038-of-00046.safetensors", + "model.layers.37.mlp.shared_experts.gate_proj.weight": "model-00038-of-00046.safetensors", + "model.layers.37.mlp.shared_experts.up_proj.weight": "model-00038-of-00046.safetensors", + "model.layers.37.post_attention_layernorm.weight": "model-00038-of-00046.safetensors", + "model.layers.37.self_attn.k_proj.bias": "model-00037-of-00046.safetensors", + "model.layers.37.self_attn.k_proj.weight": "model-00037-of-00046.safetensors", + "model.layers.37.self_attn.o_proj.weight": "model-00037-of-00046.safetensors", + "model.layers.37.self_attn.q_proj.bias": "model-00037-of-00046.safetensors", + "model.layers.37.self_attn.q_proj.weight": "model-00037-of-00046.safetensors", + "model.layers.37.self_attn.v_proj.bias": "model-00037-of-00046.safetensors", + "model.layers.37.self_attn.v_proj.weight": "model-00037-of-00046.safetensors", + "model.layers.38.input_layernorm.weight": "model-00039-of-00046.safetensors", + "model.layers.38.mlp.gate.e_score_correction_bias": "model-00039-of-00046.safetensors", + "model.layers.38.mlp.gate.weight": "model-00039-of-00046.safetensors", + "model.layers.38.mlp.moe_mlp.experts.weight": "model-00038-of-00046.safetensors", + "model.layers.38.mlp.moe_mlp.output_experts.weight": "model-00039-of-00046.safetensors", + "model.layers.38.mlp.shared_experts.down_proj.weight": "model-00039-of-00046.safetensors", + "model.layers.38.mlp.shared_experts.gate_proj.weight": "model-00039-of-00046.safetensors", + "model.layers.38.mlp.shared_experts.up_proj.weight": "model-00039-of-00046.safetensors", + "model.layers.38.post_attention_layernorm.weight": "model-00039-of-00046.safetensors", + "model.layers.38.self_attn.k_proj.bias": "model-00038-of-00046.safetensors", + "model.layers.38.self_attn.k_proj.weight": "model-00038-of-00046.safetensors", + "model.layers.38.self_attn.o_proj.weight": "model-00038-of-00046.safetensors", + "model.layers.38.self_attn.q_proj.bias": "model-00038-of-00046.safetensors", + "model.layers.38.self_attn.q_proj.weight": "model-00038-of-00046.safetensors", + "model.layers.38.self_attn.v_proj.bias": "model-00038-of-00046.safetensors", + "model.layers.38.self_attn.v_proj.weight": "model-00038-of-00046.safetensors", + "model.layers.39.input_layernorm.weight": "model-00040-of-00046.safetensors", + "model.layers.39.mlp.gate.e_score_correction_bias": "model-00040-of-00046.safetensors", + "model.layers.39.mlp.gate.weight": "model-00040-of-00046.safetensors", + "model.layers.39.mlp.moe_mlp.experts.weight": "model-00039-of-00046.safetensors", + "model.layers.39.mlp.moe_mlp.output_experts.weight": "model-00040-of-00046.safetensors", + "model.layers.39.mlp.shared_experts.down_proj.weight": "model-00040-of-00046.safetensors", + "model.layers.39.mlp.shared_experts.gate_proj.weight": "model-00040-of-00046.safetensors", + "model.layers.39.mlp.shared_experts.up_proj.weight": "model-00040-of-00046.safetensors", + "model.layers.39.post_attention_layernorm.weight": "model-00040-of-00046.safetensors", + "model.layers.39.self_attn.k_proj.bias": "model-00039-of-00046.safetensors", + "model.layers.39.self_attn.k_proj.weight": "model-00039-of-00046.safetensors", + "model.layers.39.self_attn.o_proj.weight": "model-00039-of-00046.safetensors", + "model.layers.39.self_attn.q_proj.bias": "model-00039-of-00046.safetensors", + "model.layers.39.self_attn.q_proj.weight": "model-00039-of-00046.safetensors", + "model.layers.39.self_attn.v_proj.bias": "model-00039-of-00046.safetensors", + "model.layers.39.self_attn.v_proj.weight": "model-00039-of-00046.safetensors", + "model.layers.4.input_layernorm.weight": "model-00005-of-00046.safetensors", + "model.layers.4.mlp.gate.e_score_correction_bias": "model-00005-of-00046.safetensors", + "model.layers.4.mlp.gate.weight": "model-00005-of-00046.safetensors", + "model.layers.4.mlp.moe_mlp.experts.weight": "model-00004-of-00046.safetensors", + "model.layers.4.mlp.moe_mlp.output_experts.weight": "model-00005-of-00046.safetensors", + "model.layers.4.mlp.shared_experts.down_proj.weight": "model-00005-of-00046.safetensors", + "model.layers.4.mlp.shared_experts.gate_proj.weight": "model-00005-of-00046.safetensors", + "model.layers.4.mlp.shared_experts.up_proj.weight": "model-00005-of-00046.safetensors", + "model.layers.4.post_attention_layernorm.weight": "model-00005-of-00046.safetensors", + "model.layers.4.self_attn.k_proj.bias": "model-00004-of-00046.safetensors", + "model.layers.4.self_attn.k_proj.weight": "model-00004-of-00046.safetensors", + "model.layers.4.self_attn.o_proj.weight": "model-00004-of-00046.safetensors", + "model.layers.4.self_attn.q_proj.bias": "model-00004-of-00046.safetensors", + "model.layers.4.self_attn.q_proj.weight": "model-00004-of-00046.safetensors", + "model.layers.4.self_attn.v_proj.bias": "model-00004-of-00046.safetensors", + "model.layers.4.self_attn.v_proj.weight": "model-00004-of-00046.safetensors", + "model.layers.40.input_layernorm.weight": "model-00041-of-00046.safetensors", + "model.layers.40.mlp.gate.e_score_correction_bias": "model-00041-of-00046.safetensors", + "model.layers.40.mlp.gate.weight": "model-00041-of-00046.safetensors", + "model.layers.40.mlp.moe_mlp.experts.weight": "model-00040-of-00046.safetensors", + "model.layers.40.mlp.moe_mlp.output_experts.weight": "model-00041-of-00046.safetensors", + "model.layers.40.mlp.shared_experts.down_proj.weight": "model-00041-of-00046.safetensors", + "model.layers.40.mlp.shared_experts.gate_proj.weight": "model-00041-of-00046.safetensors", + "model.layers.40.mlp.shared_experts.up_proj.weight": "model-00041-of-00046.safetensors", + "model.layers.40.post_attention_layernorm.weight": "model-00041-of-00046.safetensors", + "model.layers.40.self_attn.k_proj.bias": "model-00040-of-00046.safetensors", + "model.layers.40.self_attn.k_proj.weight": "model-00040-of-00046.safetensors", + "model.layers.40.self_attn.o_proj.weight": "model-00040-of-00046.safetensors", + "model.layers.40.self_attn.q_proj.bias": "model-00040-of-00046.safetensors", + "model.layers.40.self_attn.q_proj.weight": "model-00040-of-00046.safetensors", + "model.layers.40.self_attn.v_proj.bias": "model-00040-of-00046.safetensors", + "model.layers.40.self_attn.v_proj.weight": "model-00040-of-00046.safetensors", + "model.layers.41.input_layernorm.weight": "model-00042-of-00046.safetensors", + "model.layers.41.mlp.gate.e_score_correction_bias": "model-00042-of-00046.safetensors", + "model.layers.41.mlp.gate.weight": "model-00042-of-00046.safetensors", + "model.layers.41.mlp.moe_mlp.experts.weight": "model-00041-of-00046.safetensors", + "model.layers.41.mlp.moe_mlp.output_experts.weight": "model-00042-of-00046.safetensors", + "model.layers.41.mlp.shared_experts.down_proj.weight": "model-00042-of-00046.safetensors", + "model.layers.41.mlp.shared_experts.gate_proj.weight": "model-00042-of-00046.safetensors", + "model.layers.41.mlp.shared_experts.up_proj.weight": "model-00042-of-00046.safetensors", + "model.layers.41.post_attention_layernorm.weight": "model-00042-of-00046.safetensors", + "model.layers.41.self_attn.k_proj.bias": "model-00041-of-00046.safetensors", + "model.layers.41.self_attn.k_proj.weight": "model-00041-of-00046.safetensors", + "model.layers.41.self_attn.o_proj.weight": "model-00041-of-00046.safetensors", + "model.layers.41.self_attn.q_proj.bias": "model-00041-of-00046.safetensors", + "model.layers.41.self_attn.q_proj.weight": "model-00041-of-00046.safetensors", + "model.layers.41.self_attn.v_proj.bias": "model-00041-of-00046.safetensors", + "model.layers.41.self_attn.v_proj.weight": "model-00041-of-00046.safetensors", + "model.layers.42.input_layernorm.weight": "model-00043-of-00046.safetensors", + "model.layers.42.mlp.gate.e_score_correction_bias": "model-00043-of-00046.safetensors", + "model.layers.42.mlp.gate.weight": "model-00043-of-00046.safetensors", + "model.layers.42.mlp.moe_mlp.experts.weight": "model-00042-of-00046.safetensors", + "model.layers.42.mlp.moe_mlp.output_experts.weight": "model-00043-of-00046.safetensors", + "model.layers.42.mlp.shared_experts.down_proj.weight": "model-00043-of-00046.safetensors", + "model.layers.42.mlp.shared_experts.gate_proj.weight": "model-00043-of-00046.safetensors", + "model.layers.42.mlp.shared_experts.up_proj.weight": "model-00043-of-00046.safetensors", + "model.layers.42.post_attention_layernorm.weight": "model-00043-of-00046.safetensors", + "model.layers.42.self_attn.k_proj.bias": "model-00042-of-00046.safetensors", + "model.layers.42.self_attn.k_proj.weight": "model-00042-of-00046.safetensors", + "model.layers.42.self_attn.o_proj.weight": "model-00042-of-00046.safetensors", + "model.layers.42.self_attn.q_proj.bias": "model-00042-of-00046.safetensors", + "model.layers.42.self_attn.q_proj.weight": "model-00042-of-00046.safetensors", + "model.layers.42.self_attn.v_proj.bias": "model-00042-of-00046.safetensors", + "model.layers.42.self_attn.v_proj.weight": "model-00042-of-00046.safetensors", + "model.layers.43.input_layernorm.weight": "model-00044-of-00046.safetensors", + "model.layers.43.mlp.gate.e_score_correction_bias": "model-00044-of-00046.safetensors", + "model.layers.43.mlp.gate.weight": "model-00044-of-00046.safetensors", + "model.layers.43.mlp.moe_mlp.experts.weight": "model-00043-of-00046.safetensors", + "model.layers.43.mlp.moe_mlp.output_experts.weight": "model-00044-of-00046.safetensors", + "model.layers.43.mlp.shared_experts.down_proj.weight": "model-00044-of-00046.safetensors", + "model.layers.43.mlp.shared_experts.gate_proj.weight": "model-00044-of-00046.safetensors", + "model.layers.43.mlp.shared_experts.up_proj.weight": "model-00044-of-00046.safetensors", + "model.layers.43.post_attention_layernorm.weight": "model-00044-of-00046.safetensors", + "model.layers.43.self_attn.k_proj.bias": "model-00043-of-00046.safetensors", + "model.layers.43.self_attn.k_proj.weight": "model-00043-of-00046.safetensors", + "model.layers.43.self_attn.o_proj.weight": "model-00043-of-00046.safetensors", + "model.layers.43.self_attn.q_proj.bias": "model-00043-of-00046.safetensors", + "model.layers.43.self_attn.q_proj.weight": "model-00043-of-00046.safetensors", + "model.layers.43.self_attn.v_proj.bias": "model-00043-of-00046.safetensors", + "model.layers.43.self_attn.v_proj.weight": "model-00043-of-00046.safetensors", + "model.layers.44.input_layernorm.weight": "model-00045-of-00046.safetensors", + "model.layers.44.mlp.gate.e_score_correction_bias": "model-00045-of-00046.safetensors", + "model.layers.44.mlp.gate.weight": "model-00045-of-00046.safetensors", + "model.layers.44.mlp.moe_mlp.experts.weight": "model-00044-of-00046.safetensors", + "model.layers.44.mlp.moe_mlp.output_experts.weight": "model-00045-of-00046.safetensors", + "model.layers.44.mlp.shared_experts.down_proj.weight": "model-00045-of-00046.safetensors", + "model.layers.44.mlp.shared_experts.gate_proj.weight": "model-00045-of-00046.safetensors", + "model.layers.44.mlp.shared_experts.up_proj.weight": "model-00045-of-00046.safetensors", + "model.layers.44.post_attention_layernorm.weight": "model-00045-of-00046.safetensors", + "model.layers.44.self_attn.k_proj.bias": "model-00044-of-00046.safetensors", + "model.layers.44.self_attn.k_proj.weight": "model-00044-of-00046.safetensors", + "model.layers.44.self_attn.o_proj.weight": "model-00044-of-00046.safetensors", + "model.layers.44.self_attn.q_proj.bias": "model-00044-of-00046.safetensors", + "model.layers.44.self_attn.q_proj.weight": "model-00044-of-00046.safetensors", + "model.layers.44.self_attn.v_proj.bias": "model-00044-of-00046.safetensors", + "model.layers.44.self_attn.v_proj.weight": "model-00044-of-00046.safetensors", + "model.layers.45.input_layernorm.weight": "model-00046-of-00046.safetensors", + "model.layers.45.mlp.gate.e_score_correction_bias": "model-00046-of-00046.safetensors", + "model.layers.45.mlp.gate.weight": "model-00046-of-00046.safetensors", + "model.layers.45.mlp.moe_mlp.experts.weight": "model-00045-of-00046.safetensors", + "model.layers.45.mlp.moe_mlp.output_experts.weight": "model-00046-of-00046.safetensors", + "model.layers.45.mlp.shared_experts.down_proj.weight": "model-00046-of-00046.safetensors", + "model.layers.45.mlp.shared_experts.gate_proj.weight": "model-00046-of-00046.safetensors", + "model.layers.45.mlp.shared_experts.up_proj.weight": "model-00046-of-00046.safetensors", + "model.layers.45.post_attention_layernorm.weight": "model-00046-of-00046.safetensors", + "model.layers.45.self_attn.k_proj.bias": "model-00045-of-00046.safetensors", + "model.layers.45.self_attn.k_proj.weight": "model-00045-of-00046.safetensors", + "model.layers.45.self_attn.o_proj.weight": "model-00045-of-00046.safetensors", + "model.layers.45.self_attn.q_proj.bias": "model-00045-of-00046.safetensors", + "model.layers.45.self_attn.q_proj.weight": "model-00045-of-00046.safetensors", + "model.layers.45.self_attn.v_proj.bias": "model-00045-of-00046.safetensors", + "model.layers.45.self_attn.v_proj.weight": "model-00045-of-00046.safetensors", + "model.layers.5.input_layernorm.weight": "model-00006-of-00046.safetensors", + "model.layers.5.mlp.gate.e_score_correction_bias": "model-00006-of-00046.safetensors", + "model.layers.5.mlp.gate.weight": "model-00006-of-00046.safetensors", + "model.layers.5.mlp.moe_mlp.experts.weight": "model-00005-of-00046.safetensors", + "model.layers.5.mlp.moe_mlp.output_experts.weight": "model-00006-of-00046.safetensors", + "model.layers.5.mlp.shared_experts.down_proj.weight": "model-00006-of-00046.safetensors", + "model.layers.5.mlp.shared_experts.gate_proj.weight": "model-00006-of-00046.safetensors", + "model.layers.5.mlp.shared_experts.up_proj.weight": "model-00006-of-00046.safetensors", + "model.layers.5.post_attention_layernorm.weight": "model-00006-of-00046.safetensors", + "model.layers.5.self_attn.k_proj.bias": "model-00005-of-00046.safetensors", + "model.layers.5.self_attn.k_proj.weight": "model-00005-of-00046.safetensors", + "model.layers.5.self_attn.o_proj.weight": "model-00005-of-00046.safetensors", + "model.layers.5.self_attn.q_proj.bias": "model-00005-of-00046.safetensors", + "model.layers.5.self_attn.q_proj.weight": "model-00005-of-00046.safetensors", + "model.layers.5.self_attn.v_proj.bias": "model-00005-of-00046.safetensors", + "model.layers.5.self_attn.v_proj.weight": "model-00005-of-00046.safetensors", + "model.layers.6.input_layernorm.weight": "model-00007-of-00046.safetensors", + "model.layers.6.mlp.gate.e_score_correction_bias": "model-00007-of-00046.safetensors", + "model.layers.6.mlp.gate.weight": "model-00007-of-00046.safetensors", + "model.layers.6.mlp.moe_mlp.experts.weight": "model-00006-of-00046.safetensors", + "model.layers.6.mlp.moe_mlp.output_experts.weight": "model-00007-of-00046.safetensors", + "model.layers.6.mlp.shared_experts.down_proj.weight": "model-00007-of-00046.safetensors", + "model.layers.6.mlp.shared_experts.gate_proj.weight": "model-00007-of-00046.safetensors", + "model.layers.6.mlp.shared_experts.up_proj.weight": "model-00007-of-00046.safetensors", + "model.layers.6.post_attention_layernorm.weight": "model-00007-of-00046.safetensors", + "model.layers.6.self_attn.k_proj.bias": "model-00006-of-00046.safetensors", + "model.layers.6.self_attn.k_proj.weight": "model-00006-of-00046.safetensors", + "model.layers.6.self_attn.o_proj.weight": "model-00006-of-00046.safetensors", + "model.layers.6.self_attn.q_proj.bias": "model-00006-of-00046.safetensors", + "model.layers.6.self_attn.q_proj.weight": "model-00006-of-00046.safetensors", + "model.layers.6.self_attn.v_proj.bias": "model-00006-of-00046.safetensors", + "model.layers.6.self_attn.v_proj.weight": "model-00006-of-00046.safetensors", + "model.layers.7.input_layernorm.weight": "model-00008-of-00046.safetensors", + "model.layers.7.mlp.gate.e_score_correction_bias": "model-00008-of-00046.safetensors", + "model.layers.7.mlp.gate.weight": "model-00008-of-00046.safetensors", + "model.layers.7.mlp.moe_mlp.experts.weight": "model-00007-of-00046.safetensors", + "model.layers.7.mlp.moe_mlp.output_experts.weight": "model-00008-of-00046.safetensors", + "model.layers.7.mlp.shared_experts.down_proj.weight": "model-00008-of-00046.safetensors", + "model.layers.7.mlp.shared_experts.gate_proj.weight": "model-00008-of-00046.safetensors", + "model.layers.7.mlp.shared_experts.up_proj.weight": "model-00008-of-00046.safetensors", + "model.layers.7.post_attention_layernorm.weight": "model-00008-of-00046.safetensors", + "model.layers.7.self_attn.k_proj.bias": "model-00007-of-00046.safetensors", + "model.layers.7.self_attn.k_proj.weight": "model-00007-of-00046.safetensors", + "model.layers.7.self_attn.o_proj.weight": "model-00007-of-00046.safetensors", + "model.layers.7.self_attn.q_proj.bias": "model-00007-of-00046.safetensors", + "model.layers.7.self_attn.q_proj.weight": "model-00007-of-00046.safetensors", + "model.layers.7.self_attn.v_proj.bias": "model-00007-of-00046.safetensors", + "model.layers.7.self_attn.v_proj.weight": "model-00007-of-00046.safetensors", + "model.layers.8.input_layernorm.weight": "model-00009-of-00046.safetensors", + "model.layers.8.mlp.gate.e_score_correction_bias": "model-00009-of-00046.safetensors", + "model.layers.8.mlp.gate.weight": "model-00009-of-00046.safetensors", + "model.layers.8.mlp.moe_mlp.experts.weight": "model-00008-of-00046.safetensors", + "model.layers.8.mlp.moe_mlp.output_experts.weight": "model-00009-of-00046.safetensors", + "model.layers.8.mlp.shared_experts.down_proj.weight": "model-00009-of-00046.safetensors", + "model.layers.8.mlp.shared_experts.gate_proj.weight": "model-00009-of-00046.safetensors", + "model.layers.8.mlp.shared_experts.up_proj.weight": "model-00009-of-00046.safetensors", + "model.layers.8.post_attention_layernorm.weight": "model-00009-of-00046.safetensors", + "model.layers.8.self_attn.k_proj.bias": "model-00008-of-00046.safetensors", + "model.layers.8.self_attn.k_proj.weight": "model-00008-of-00046.safetensors", + "model.layers.8.self_attn.o_proj.weight": "model-00008-of-00046.safetensors", + "model.layers.8.self_attn.q_proj.bias": "model-00008-of-00046.safetensors", + "model.layers.8.self_attn.q_proj.weight": "model-00008-of-00046.safetensors", + "model.layers.8.self_attn.v_proj.bias": "model-00008-of-00046.safetensors", + "model.layers.8.self_attn.v_proj.weight": "model-00008-of-00046.safetensors", + "model.layers.9.input_layernorm.weight": "model-00010-of-00046.safetensors", + "model.layers.9.mlp.gate.e_score_correction_bias": "model-00010-of-00046.safetensors", + "model.layers.9.mlp.gate.weight": "model-00010-of-00046.safetensors", + "model.layers.9.mlp.moe_mlp.experts.weight": "model-00009-of-00046.safetensors", + "model.layers.9.mlp.moe_mlp.output_experts.weight": "model-00010-of-00046.safetensors", + "model.layers.9.mlp.shared_experts.down_proj.weight": "model-00010-of-00046.safetensors", + "model.layers.9.mlp.shared_experts.gate_proj.weight": "model-00010-of-00046.safetensors", + "model.layers.9.mlp.shared_experts.up_proj.weight": "model-00010-of-00046.safetensors", + "model.layers.9.post_attention_layernorm.weight": "model-00010-of-00046.safetensors", + "model.layers.9.self_attn.k_proj.bias": "model-00009-of-00046.safetensors", + "model.layers.9.self_attn.k_proj.weight": "model-00009-of-00046.safetensors", + "model.layers.9.self_attn.o_proj.weight": "model-00009-of-00046.safetensors", + "model.layers.9.self_attn.q_proj.bias": "model-00009-of-00046.safetensors", + "model.layers.9.self_attn.q_proj.weight": "model-00009-of-00046.safetensors", + "model.layers.9.self_attn.v_proj.bias": "model-00009-of-00046.safetensors", + "model.layers.9.self_attn.v_proj.weight": "model-00009-of-00046.safetensors", + "model.norm.weight": "model-00046-of-00046.safetensors" + } +} diff --git a/modeling_glm4_shared_moe.py b/modeling_glm4_shared_moe.py new file mode 100644 index 0000000000000000000000000000000000000000..ca69415c8b96189226c56566f2acc5d5528fad22 --- /dev/null +++ b/modeling_glm4_shared_moe.py @@ -0,0 +1,642 @@ +# coding=utf-8 +# Copyright 2025 The ZhipuAI Inc. team and HuggingFace Inc. team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Callable, Optional, Union + +import torch +import torch.nn.functional as F +from torch import nn + +from transformers.activations import ACT2FN +from transformers.cache_utils import Cache, DynamicCache +from transformers.generation import GenerationMixin +from transformers.integrations import use_kernel_forward_from_hub +from transformers.masking_utils import create_causal_mask +from transformers.modeling_flash_attention_utils import FlashAttentionKwargs +from transformers.modeling_layers import GradientCheckpointingLayer +from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast +from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update +from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel +from transformers.processing_utils import Unpack +from transformers.utils import TransformersKwargs, auto_docstring, can_return_tuple +from transformers.utils.deprecation import deprecate_kwarg +from transformers.utils.generic import check_model_inputs +from .configuration_glm4_shared_moe import Glm4SharedMoeConfig + +import scattermoe + +# Liger Patch # +from liger_kernel.transformers.rms_norm import LigerRMSNorm as Glm4MoeRMSNorm +from liger_kernel.transformers.model.loss_utils import LigerForCausalLMLoss + + +def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor: + """ + This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch, + num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim) + """ + batch, num_key_value_heads, slen, head_dim = hidden_states.shape + if n_rep == 1: + return hidden_states + hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim) + return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim) + + +def eager_attention_forward( + module: nn.Module, + query: torch.Tensor, + key: torch.Tensor, + value: torch.Tensor, + attention_mask: Optional[torch.Tensor], + scaling: float, + dropout: float = 0.0, + **kwargs: Unpack[TransformersKwargs], +): + key_states = repeat_kv(key, module.num_key_value_groups) + value_states = repeat_kv(value, module.num_key_value_groups) + + attn_weights = torch.matmul(query, key_states.transpose(2, 3)) * scaling + if attention_mask is not None: + causal_mask = attention_mask[:, :, :, : key_states.shape[-2]] + attn_weights = attn_weights + causal_mask + + attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype) + attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training) + attn_output = torch.matmul(attn_weights, value_states) + attn_output = attn_output.transpose(1, 2).contiguous() + + return attn_output, attn_weights + + +def rotate_half(x): + """Rotates half the hidden dims of the input.""" + x1 = x[..., : x.shape[-1] // 2] + x2 = x[..., x.shape[-1] // 2 :] + return torch.cat((-x2, x1), dim=-1) + + +def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1): + """Applies Rotary Position Embedding to the query and key tensors. + + Args: + q (`torch.Tensor`): The query tensor. + k (`torch.Tensor`): The key tensor. + cos (`torch.Tensor`): The cosine part of the rotary embedding. + sin (`torch.Tensor`): The sine part of the rotary embedding. + position_ids (`torch.Tensor`, *optional*): + Deprecated and unused. + unsqueeze_dim (`int`, *optional*, defaults to 1): + The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and + sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note + that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and + k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes + cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have + the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2. + Returns: + `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding. + """ + cos = cos.unsqueeze(unsqueeze_dim) + sin = sin.unsqueeze(unsqueeze_dim) + + # Keep half or full tensor for later concatenation + rotary_dim = cos.shape[-1] + q_rot, q_pass = q[..., :rotary_dim], q[..., rotary_dim:] + k_rot, k_pass = k[..., :rotary_dim], k[..., rotary_dim:] + + # Apply rotary embeddings on the first half or full tensor + q_embed = (q_rot * cos) + (rotate_half(q_rot) * sin) + k_embed = (k_rot * cos) + (rotate_half(k_rot) * sin) + + # Concatenate back to full shape + q_embed = torch.cat([q_embed, q_pass], dim=-1) + k_embed = torch.cat([k_embed, k_pass], dim=-1) + return q_embed, k_embed + + +class Glm4MoeAttention(nn.Module): + """Multi-headed attention from 'Attention Is All You Need' paper""" + + def __init__(self, config: Glm4SharedMoeConfig, layer_idx: Optional[int] = None): + super().__init__() + self.config = config + self.layer_idx = layer_idx + self.head_dim = getattr(config, "head_dim", config.hidden_size // config.num_attention_heads) + self.num_key_value_groups = config.num_attention_heads // config.num_key_value_heads + self.scaling = self.head_dim**-0.5 + self.rope_scaling = config.rope_scaling + self.attention_dropout = config.attention_dropout + self.is_causal = True + + self.q_proj = nn.Linear( + config.hidden_size, config.num_attention_heads * self.head_dim, bias=config.attention_bias + ) + self.k_proj = nn.Linear( + config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias + ) + self.v_proj = nn.Linear( + config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias + ) + self.o_proj = nn.Linear(config.num_attention_heads * self.head_dim, config.hidden_size, bias=False) + self.use_qk_norm = config.use_qk_norm + if self.use_qk_norm: + self.q_norm = Glm4MoeRMSNorm(self.head_dim, eps=config.rms_norm_eps) + self.k_norm = Glm4MoeRMSNorm(self.head_dim, eps=config.rms_norm_eps) + + @deprecate_kwarg("past_key_value", new_name="past_key_values", version="4.58") + def forward( + self, + hidden_states: torch.Tensor, + position_embeddings: tuple[torch.Tensor, torch.Tensor], + attention_mask: Optional[torch.Tensor], + past_key_values: Optional[Cache] = None, + cache_position: Optional[torch.LongTensor] = None, + **kwargs: Unpack[FlashAttentionKwargs], + ) -> tuple[torch.Tensor, Optional[torch.Tensor]]: + input_shape = hidden_states.shape[:-1] + hidden_shape = (*input_shape, -1, self.head_dim) + + query_states = self.q_proj(hidden_states).view(hidden_shape) + key_states = self.k_proj(hidden_states).view(hidden_shape) + value_states = self.v_proj(hidden_states).view(hidden_shape) + + if self.use_qk_norm: # main diff from Llama + query_states = self.q_norm(query_states) + key_states = self.k_norm(key_states) + + query_states = query_states.transpose(1, 2) + key_states = key_states.transpose(1, 2) + value_states = value_states.transpose(1, 2) + + cos, sin = position_embeddings + query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin) + + if past_key_values is not None: + # sin and cos are specific to RoPE models; position_ids needed for the static cache + cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position} + key_states, value_states = past_key_values.update(key_states, value_states, self.layer_idx, cache_kwargs) + + attention_interface: Callable = eager_attention_forward + if self.config._attn_implementation != "eager": + attention_interface = ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation] + + attn_output, attn_weights = attention_interface( + self, + query_states, + key_states, + value_states, + attention_mask, + dropout=0.0 if not self.training else self.attention_dropout, + scaling=self.scaling, + **kwargs, + ) + + attn_output = attn_output.reshape(*input_shape, -1).contiguous() + attn_output = self.o_proj(attn_output) + return attn_output, attn_weights + + +class Glm4MoeMLP(nn.Module): + def __init__(self, config, hidden_size=None, intermediate_size=None): + super().__init__() + self.config = config + self.hidden_size = config.hidden_size if hidden_size is None else hidden_size + self.intermediate_size = config.intermediate_size if intermediate_size is None else intermediate_size + + self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False) + self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False) + self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False) + self.act_fn = ACT2FN[config.hidden_act] + + def forward(self, x): + down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x)) + return down_proj + + +class Glm4MoeTopkRouter2(nn.Module): + def __init__(self, config: Glm4SharedMoeConfig): + super().__init__() + self.config = config + self.top_k = config.num_experts_per_tok + self.n_routed_experts = config.n_routed_experts + self.routed_scaling_factor = config.routed_scaling_factor + self.n_group = config.n_group + self.topk_group = config.topk_group + self.norm_topk_prob = config.norm_topk_prob + + self.weight = nn.Parameter(torch.empty((self.n_routed_experts, config.hidden_size))) + self.register_buffer("e_score_correction_bias", torch.zeros((self.n_routed_experts), dtype=torch.float32)) + + def forward(self, hidden_states): + hidden_states = hidden_states.view(-1, self.config.hidden_size) + router_logits = F.linear(hidden_states.type(torch.float32), self.weight.type(torch.float32)) + scores = router_logits.sigmoid() + scores2 = scores + self.e_score_correction_bias.unsqueeze(0).to(scores.device) + _, selected_experts = torch.topk( + scores2, self.top_k, dim=-1 + ) + routing_weights = scores.gather(1, selected_experts) + if self.norm_topk_prob: + denominator = routing_weights.sum(dim=-1, keepdim=True) + 1e-20 + routing_weights /= denominator + routing_weights = routing_weights * self.routed_scaling_factor + return selected_experts, routing_weights + + +class Glm4MoeTopkRouter(nn.Module): + def __init__(self, config: Glm4SharedMoeConfig): + super().__init__() + self.config = config + self.top_k = config.num_experts_per_tok + self.n_routed_experts = config.n_routed_experts + self.routed_scaling_factor = config.routed_scaling_factor + self.n_group = config.n_group + self.topk_group = config.topk_group + self.norm_topk_prob = config.norm_topk_prob + + self.weight = nn.Parameter(torch.empty((self.n_routed_experts, config.hidden_size))) + self.register_buffer("e_score_correction_bias", torch.zeros((self.n_routed_experts), dtype=torch.float32)) + + @torch.no_grad() + def get_topk_indices(self, scores): + scores_for_choice = scores.view(-1, self.n_routed_experts) + self.e_score_correction_bias.unsqueeze(0).to(scores.device) + group_scores = ( + scores_for_choice.view(-1, self.n_group, self.n_routed_experts // self.n_group) + .topk(2, dim=-1)[0] + .sum(dim=-1) + ) + group_idx = torch.topk(group_scores, k=self.topk_group, dim=-1, sorted=False)[1] + group_mask = torch.zeros_like(group_scores) + group_mask.scatter_(1, group_idx, 1) + score_mask = ( + group_mask.unsqueeze(-1) + .expand(-1, self.n_group, self.n_routed_experts // self.n_group) + .reshape(-1, self.n_routed_experts) + ) + scores_for_choice = scores_for_choice.masked_fill(~score_mask.bool(), 0.0) + topk_indices = torch.topk(scores_for_choice, k=self.top_k, dim=-1, sorted=False)[1] + return topk_indices + + def forward(self, hidden_states): + hidden_states = hidden_states.view(-1, self.config.hidden_size) + router_logits = F.linear(hidden_states.type(torch.float32), self.weight.type(torch.float32)) + scores = router_logits.sigmoid() + topk_indices = self.get_topk_indices(scores) + topk_weights = scores.gather(1, topk_indices) + if self.norm_topk_prob: + denominator = topk_weights.sum(dim=-1, keepdim=True) + 1e-20 + topk_weights /= denominator + topk_weights = topk_weights * self.routed_scaling_factor + return topk_indices, topk_weights + + +@use_kernel_forward_from_hub("RMSNorm") +class Glm4MoeRMSNorm2(nn.Module): + def __init__(self, hidden_size, eps=1e-6): + """ + Glm4MoeRMSNorm is equivalent to T5LayerNorm + """ + super().__init__() + self.weight = nn.Parameter(torch.ones(hidden_size)) + self.variance_epsilon = eps + + def forward(self, hidden_states): + input_dtype = hidden_states.dtype + hidden_states = hidden_states.to(torch.float32) + variance = hidden_states.pow(2).mean(-1, keepdim=True) + hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon) + return self.weight * hidden_states.to(input_dtype) + + def extra_repr(self): + return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}" + + +class Glm4MoeMoE(nn.Module): + """ + A mixed expert module containing shared experts. + """ + + def __init__(self, config): + super().__init__() + self.config = config + self.moe_mlp = scattermoe.mlp.GLUMLP( + input_size=self.config.hidden_size, + hidden_size=self.config.moe_intermediate_size, + num_experts=self.config.n_routed_experts, + top_k=self.config.num_experts_per_tok, + activation=ACT2FN[config.hidden_act], + ) + self.gate = Glm4MoeTopkRouter(config) + self.shared_experts = Glm4MoeMLP( + config=config, intermediate_size=config.moe_intermediate_size * config.n_shared_experts + ) + + def forward(self, hidden_states): + residuals = hidden_states + orig_shape = hidden_states.shape + topk_indices, topk_weights = self.gate(hidden_states) + hidden_states = hidden_states.view(-1, hidden_states.shape[-1]) + topk_weights = topk_weights.to(torch.bfloat16) + hs_0 = self.moe_mlp(hidden_states, topk_weights, topk_indices).view(*orig_shape) + res = hs_0 + self.shared_experts(residuals) + return res + + +class Glm4MoeDecoderLayer(GradientCheckpointingLayer): + def __init__(self, config: Glm4SharedMoeConfig, layer_idx: int): + super().__init__() + self.hidden_size = config.hidden_size + + self.self_attn = Glm4MoeAttention(config=config, layer_idx=layer_idx) + + if layer_idx >= config.first_k_dense_replace: + self.mlp = Glm4MoeMoE(config) + else: + self.mlp = Glm4MoeMLP(config) + + self.input_layernorm = Glm4MoeRMSNorm(config.hidden_size, eps=config.rms_norm_eps) + self.post_attention_layernorm = Glm4MoeRMSNorm(config.hidden_size, eps=config.rms_norm_eps) + + @deprecate_kwarg("past_key_value", new_name="past_key_values", version="4.58") + def forward( + self, + hidden_states: torch.Tensor, + attention_mask: Optional[torch.Tensor] = None, + position_ids: Optional[torch.LongTensor] = None, + past_key_values: Optional[Cache] = None, + use_cache: Optional[bool] = False, + cache_position: Optional[torch.LongTensor] = None, + position_embeddings: Optional[tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC + **kwargs: Unpack[TransformersKwargs], + ) -> torch.Tensor: + residual = hidden_states + hidden_states = self.input_layernorm(hidden_states) + # Self Attention + hidden_states, _ = self.self_attn( + hidden_states=hidden_states, + attention_mask=attention_mask, + position_ids=position_ids, + past_key_values=past_key_values, + use_cache=use_cache, + cache_position=cache_position, + position_embeddings=position_embeddings, + **kwargs, + ) + hidden_states = residual + hidden_states + + # Fully Connected + residual = hidden_states + hidden_states = self.post_attention_layernorm(hidden_states) + hidden_states = self.mlp(hidden_states) + hidden_states = residual + hidden_states + return hidden_states + + +@auto_docstring +class Glm4SharedMoePreTrainedModel(PreTrainedModel): + config: Glm4SharedMoeConfig + base_model_prefix = "model" + supports_gradient_checkpointing = True + _no_split_modules = ["Glm4MoeDecoderLayer"] + _skip_keys_device_placement = ["past_key_values"] + _supports_flash_attn = True + _supports_sdpa = True + _supports_flex_attn = True + _can_compile_fullgraph = False + _supports_attention_backend = True + _can_record_outputs = { + "hidden_states": Glm4MoeDecoderLayer, + "attentions": Glm4MoeAttention, + } + + def _init_weights(self, module): + super()._init_weights(module) + if isinstance(module, Glm4MoeTopkRouter): + module.weight.data.normal_(mean=0.0, std=self.config.initializer_range) + + +class Glm4MoeRotaryEmbedding(nn.Module): + inv_freq: torch.Tensor # fix linting for `register_buffer` + + def __init__(self, config: Glm4SharedMoeConfig, device=None): + super().__init__() + # BC: "rope_type" was originally "type" + if hasattr(config, "rope_scaling") and isinstance(config.rope_scaling, dict): + self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type")) + else: + self.rope_type = "default" + self.max_seq_len_cached = config.max_position_embeddings + self.original_max_seq_len = config.max_position_embeddings + + self.config = config + self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type] + + inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device) + self.register_buffer("inv_freq", inv_freq, persistent=False) + self.original_inv_freq = self.inv_freq + + @torch.no_grad() + @dynamic_rope_update # power user: used with advanced RoPE types (e.g. dynamic rope) + def forward(self, x, position_ids): + inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device) + position_ids_expanded = position_ids[:, None, :].float() + + device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu" + with torch.autocast(device_type=device_type, enabled=False): # Force float32 + freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2) + emb = torch.cat((freqs, freqs), dim=-1) + cos = emb.cos() * self.attention_scaling + sin = emb.sin() * self.attention_scaling + + return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype) + + +@auto_docstring +class Glm4SharedMoeModel(Glm4SharedMoePreTrainedModel): + _keys_to_ignore_on_load_unexpected = [r"model\.layers\.92.*", r"model\.layers\.46.*"] + + def __init__(self, config: Glm4SharedMoeConfig): + super().__init__(config) + self.padding_idx = config.pad_token_id + self.vocab_size = config.vocab_size + + self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx) + self.layers = nn.ModuleList( + [Glm4MoeDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)] + ) + self.norm = Glm4MoeRMSNorm(config.hidden_size, eps=config.rms_norm_eps) + self.rotary_emb = Glm4MoeRotaryEmbedding(config=config) + self.gradient_checkpointing = False + + # Initialize weights and apply final processing + self.post_init() + + @check_model_inputs + @auto_docstring + def forward( + self, + input_ids: Optional[torch.LongTensor] = None, + attention_mask: Optional[torch.Tensor] = None, + position_ids: Optional[torch.LongTensor] = None, + past_key_values: Optional[Cache] = None, + inputs_embeds: Optional[torch.FloatTensor] = None, + cache_position: Optional[torch.LongTensor] = None, + use_cache: Optional[bool] = None, + **kwargs: Unpack[TransformersKwargs], + ) -> BaseModelOutputWithPast: + if (input_ids is None) ^ (inputs_embeds is not None): + raise ValueError("You must specify exactly one of input_ids or inputs_embeds") + + if inputs_embeds is None: + inputs_embeds: torch.Tensor = self.embed_tokens(input_ids) + + if use_cache and past_key_values is None: + past_key_values = DynamicCache(config=self.config) + + if cache_position is None: + past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0 + cache_position: torch.Tensor = torch.arange( + past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device + ) + + if position_ids is None: + position_ids = cache_position.unsqueeze(0) + + causal_mask = create_causal_mask( + config=self.config, + input_embeds=inputs_embeds, + attention_mask=attention_mask, + cache_position=cache_position, + past_key_values=past_key_values, + position_ids=position_ids, + ) + + hidden_states = inputs_embeds + position_embeddings = self.rotary_emb(hidden_states, position_ids) + + for decoder_layer in self.layers[: self.config.num_hidden_layers]: + hidden_states = decoder_layer( + hidden_states, + attention_mask=causal_mask, + position_ids=position_ids, + past_key_values=past_key_values, + cache_position=cache_position, + position_embeddings=position_embeddings, + **kwargs, + ) + + hidden_states = self.norm(hidden_states) + return BaseModelOutputWithPast( + last_hidden_state=hidden_states, + past_key_values=past_key_values, + ) + + +@auto_docstring +class Glm4SharedMoeForCausalLM(Glm4SharedMoePreTrainedModel, GenerationMixin): + _tied_weights_keys = ["lm_head.weight"] + _tp_plan = {"lm_head": "colwise_rep"} + _pp_plan = {"lm_head": (["hidden_states"], ["logits"])} + + def __init__(self, config): + super().__init__(config) + self.model = Glm4SharedMoeModel(config) + self.vocab_size = config.vocab_size + self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False) + + # Initialize weights and apply final processing + self.post_init() + + def set_decoder(self, decoder): + self.model = decoder + + def get_decoder(self): + return self.model + + @can_return_tuple + @auto_docstring + def forward( + self, + input_ids: Optional[torch.LongTensor] = None, + attention_mask: Optional[torch.Tensor] = None, + position_ids: Optional[torch.LongTensor] = None, + past_key_values: Optional[Cache] = None, + inputs_embeds: Optional[torch.FloatTensor] = None, + labels: Optional[torch.LongTensor] = None, + use_cache: Optional[bool] = None, + cache_position: Optional[torch.LongTensor] = None, + logits_to_keep: Union[int, torch.Tensor] = 0, + **kwargs: Unpack[TransformersKwargs], + ) -> CausalLMOutputWithPast: + r""" + Example: + + ```python + >>> from transformers import AutoTokenizer, Glm4MoeForCausalLM + + >>> model = Glm4MoeForCausalLM.from_pretrained("meta-glm4_moe/Glm4Moe-2-7b-hf") + >>> tokenizer = AutoTokenizer.from_pretrained("meta-glm4_moe/Glm4Moe-2-7b-hf") + + >>> prompt = "Hey, are you conscious? Can you talk to me?" + >>> inputs = tokenizer(prompt, return_tensors="pt") + + >>> # Generate + >>> generate_ids = model.generate(inputs.input_ids, max_length=30) + >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0] + "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you." + ```""" + outputs: BaseModelOutputWithPast = self.model( + input_ids=input_ids, + attention_mask=attention_mask, + position_ids=position_ids, + past_key_values=past_key_values, + inputs_embeds=inputs_embeds, + use_cache=use_cache, + cache_position=cache_position, + **kwargs, + ) + + hidden_states = outputs.last_hidden_state + # Only compute necessary logits, and do not upcast them to float if we are not computing the loss + slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep + kept_hidden_states = hidden_states[:, slice_indices, :] + shift_labels = kwargs.pop("shift_labels", None) + logits = None + loss = None + + skip_logits = self.training and (labels is not None or shift_labels is not None) + if skip_logits: + loss = LigerForCausalLMLoss( + hidden_states=kept_hidden_states, + lm_head_weight=self.lm_head.weight, + labels=labels, + shift_labels=shift_labels, + hidden_size=self.config.hidden_size, + **kwargs, + ) + else: + logits = self.lm_head(hidden_states[:, slice_indices, :]) + if labels is not None: + loss = self.loss_function(logits=logits, labels=labels, vocab_size=self.config.vocab_size, **kwargs) + + return CausalLMOutputWithPast( + loss=loss, + logits=logits, + past_key_values=outputs.past_key_values, + hidden_states=outputs.hidden_states, + attentions=outputs.attentions, + ) + + +__all__ = ["Glm4SharedMoePreTrainedModel", "Glm4SharedMoeModel", "Glm4SharedMoeForCausalLM"] diff --git a/modeling_glm4_shared_moe.py.bak b/modeling_glm4_shared_moe.py.bak new file mode 100644 index 0000000000000000000000000000000000000000..3d817cf1d5ae8f99cffee80cd09a91dd7ff611cc --- /dev/null +++ b/modeling_glm4_shared_moe.py.bak @@ -0,0 +1,628 @@ +# coding=utf-8 +# Copyright 2025 The ZhipuAI Inc. team and HuggingFace Inc. team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Callable, Optional, Union + +import torch +import torch.nn.functional as F +from torch import nn + +from transformers.activations import ACT2FN +from transformers.cache_utils import Cache, DynamicCache +from transformers.generation import GenerationMixin +from transformers.integrations import use_kernel_forward_from_hub +from transformers.masking_utils import create_causal_mask +from transformers.modeling_flash_attention_utils import FlashAttentionKwargs +from transformers.modeling_layers import GradientCheckpointingLayer +from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast +from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update +from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel +from transformers.processing_utils import Unpack +from transformers.utils import TransformersKwargs, auto_docstring, can_return_tuple +from transformers.utils.deprecation import deprecate_kwarg +from transformers.utils.generic import check_model_inputs +from .configuration_glm4_shared_moe import Glm4SharedMoeConfig + +import scattermoe + + +def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor: + """ + This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch, + num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim) + """ + batch, num_key_value_heads, slen, head_dim = hidden_states.shape + if n_rep == 1: + return hidden_states + hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim) + return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim) + + +def eager_attention_forward( + module: nn.Module, + query: torch.Tensor, + key: torch.Tensor, + value: torch.Tensor, + attention_mask: Optional[torch.Tensor], + scaling: float, + dropout: float = 0.0, + **kwargs: Unpack[TransformersKwargs], +): + key_states = repeat_kv(key, module.num_key_value_groups) + value_states = repeat_kv(value, module.num_key_value_groups) + + attn_weights = torch.matmul(query, key_states.transpose(2, 3)) * scaling + if attention_mask is not None: + causal_mask = attention_mask[:, :, :, : key_states.shape[-2]] + attn_weights = attn_weights + causal_mask + + attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype) + attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training) + attn_output = torch.matmul(attn_weights, value_states) + attn_output = attn_output.transpose(1, 2).contiguous() + + return attn_output, attn_weights + + +def rotate_half(x): + """Rotates half the hidden dims of the input.""" + x1 = x[..., : x.shape[-1] // 2] + x2 = x[..., x.shape[-1] // 2 :] + return torch.cat((-x2, x1), dim=-1) + + +def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1): + """Applies Rotary Position Embedding to the query and key tensors. + + Args: + q (`torch.Tensor`): The query tensor. + k (`torch.Tensor`): The key tensor. + cos (`torch.Tensor`): The cosine part of the rotary embedding. + sin (`torch.Tensor`): The sine part of the rotary embedding. + position_ids (`torch.Tensor`, *optional*): + Deprecated and unused. + unsqueeze_dim (`int`, *optional*, defaults to 1): + The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and + sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note + that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and + k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes + cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have + the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2. + Returns: + `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding. + """ + cos = cos.unsqueeze(unsqueeze_dim) + sin = sin.unsqueeze(unsqueeze_dim) + + # Keep half or full tensor for later concatenation + rotary_dim = cos.shape[-1] + q_rot, q_pass = q[..., :rotary_dim], q[..., rotary_dim:] + k_rot, k_pass = k[..., :rotary_dim], k[..., rotary_dim:] + + # Apply rotary embeddings on the first half or full tensor + q_embed = (q_rot * cos) + (rotate_half(q_rot) * sin) + k_embed = (k_rot * cos) + (rotate_half(k_rot) * sin) + + # Concatenate back to full shape + q_embed = torch.cat([q_embed, q_pass], dim=-1) + k_embed = torch.cat([k_embed, k_pass], dim=-1) + return q_embed, k_embed + + +class Glm4MoeAttention(nn.Module): + """Multi-headed attention from 'Attention Is All You Need' paper""" + + def __init__(self, config: Glm4SharedMoeConfig, layer_idx: Optional[int] = None): + super().__init__() + self.config = config + self.layer_idx = layer_idx + self.head_dim = getattr(config, "head_dim", config.hidden_size // config.num_attention_heads) + self.num_key_value_groups = config.num_attention_heads // config.num_key_value_heads + self.scaling = self.head_dim**-0.5 + self.rope_scaling = config.rope_scaling + self.attention_dropout = config.attention_dropout + self.is_causal = True + + self.q_proj = nn.Linear( + config.hidden_size, config.num_attention_heads * self.head_dim, bias=config.attention_bias + ) + self.k_proj = nn.Linear( + config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias + ) + self.v_proj = nn.Linear( + config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias + ) + self.o_proj = nn.Linear(config.num_attention_heads * self.head_dim, config.hidden_size, bias=False) + self.use_qk_norm = config.use_qk_norm + if self.use_qk_norm: + self.q_norm = Glm4MoeRMSNorm(self.head_dim, eps=config.rms_norm_eps) + self.k_norm = Glm4MoeRMSNorm(self.head_dim, eps=config.rms_norm_eps) + + @deprecate_kwarg("past_key_value", new_name="past_key_values", version="4.58") + def forward( + self, + hidden_states: torch.Tensor, + position_embeddings: tuple[torch.Tensor, torch.Tensor], + attention_mask: Optional[torch.Tensor], + past_key_values: Optional[Cache] = None, + cache_position: Optional[torch.LongTensor] = None, + **kwargs: Unpack[FlashAttentionKwargs], + ) -> tuple[torch.Tensor, Optional[torch.Tensor]]: + input_shape = hidden_states.shape[:-1] + hidden_shape = (*input_shape, -1, self.head_dim) + + query_states = self.q_proj(hidden_states).view(hidden_shape) + key_states = self.k_proj(hidden_states).view(hidden_shape) + value_states = self.v_proj(hidden_states).view(hidden_shape) + + if self.use_qk_norm: # main diff from Llama + query_states = self.q_norm(query_states) + key_states = self.k_norm(key_states) + + query_states = query_states.transpose(1, 2) + key_states = key_states.transpose(1, 2) + value_states = value_states.transpose(1, 2) + + cos, sin = position_embeddings + query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin) + + if past_key_values is not None: + # sin and cos are specific to RoPE models; position_ids needed for the static cache + cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position} + key_states, value_states = past_key_values.update(key_states, value_states, self.layer_idx, cache_kwargs) + + attention_interface: Callable = eager_attention_forward + if self.config._attn_implementation != "eager": + attention_interface = ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation] + + attn_output, attn_weights = attention_interface( + self, + query_states, + key_states, + value_states, + attention_mask, + dropout=0.0 if not self.training else self.attention_dropout, + scaling=self.scaling, + **kwargs, + ) + + attn_output = attn_output.reshape(*input_shape, -1).contiguous() + attn_output = self.o_proj(attn_output) + return attn_output, attn_weights + + +class Glm4MoeMLP(nn.Module): + def __init__(self, config, hidden_size=None, intermediate_size=None): + super().__init__() + self.config = config + self.hidden_size = config.hidden_size if hidden_size is None else hidden_size + self.intermediate_size = config.intermediate_size if intermediate_size is None else intermediate_size + + self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False) + self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False) + self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False) + self.act_fn = ACT2FN[config.hidden_act] + + def forward(self, x): + down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x)) + return down_proj + + +class Glm4MoeTopkRouter(nn.Module): + def __init__(self, config: Glm4SharedMoeConfig): + super().__init__() + self.config = config + self.top_k = config.num_experts_per_tok + self.n_routed_experts = config.n_routed_experts + self.routed_scaling_factor = config.routed_scaling_factor + self.n_group = config.n_group + self.topk_group = config.topk_group + self.norm_topk_prob = config.norm_topk_prob + + self.weight = nn.Parameter(torch.empty((self.n_routed_experts, config.hidden_size))) + self.register_buffer("e_score_correction_bias", torch.zeros((self.n_routed_experts), dtype=torch.float32)) + + @torch.no_grad() + def get_topk_indices(self, scores): + scores_for_choice = scores.view(-1, self.n_routed_experts) + self.e_score_correction_bias.unsqueeze(0).to(scores.device) + group_scores = ( + scores_for_choice.view(-1, self.n_group, self.n_routed_experts // self.n_group) + .topk(2, dim=-1)[0] + .sum(dim=-1) + ) + group_idx = torch.topk(group_scores, k=self.topk_group, dim=-1, sorted=False)[1] + group_mask = torch.zeros_like(group_scores) + group_mask.scatter_(1, group_idx, 1) + score_mask = ( + group_mask.unsqueeze(-1) + .expand(-1, self.n_group, self.n_routed_experts // self.n_group) + .reshape(-1, self.n_routed_experts) + ) + scores_for_choice = scores_for_choice.masked_fill(~score_mask.bool(), 0.0) + topk_indices = torch.topk(scores_for_choice, k=self.top_k, dim=-1, sorted=False)[1] + return topk_indices + + def forward(self, hidden_states): + hidden_states = hidden_states.view(-1, self.config.hidden_size) + router_logits = F.linear(hidden_states.type(torch.float32), self.weight.type(torch.float32)) + scores = router_logits.sigmoid() + topk_indices = self.get_topk_indices(scores) + topk_weights = scores.gather(1, topk_indices) + if self.norm_topk_prob: + denominator = topk_weights.sum(dim=-1, keepdim=True) + 1e-20 + topk_weights /= denominator + topk_weights = topk_weights * self.routed_scaling_factor + return topk_indices, topk_weights + + +@use_kernel_forward_from_hub("RMSNorm") +class Glm4MoeRMSNorm(nn.Module): + def __init__(self, hidden_size, eps=1e-6): + """ + Glm4MoeRMSNorm is equivalent to T5LayerNorm + """ + super().__init__() + self.weight = nn.Parameter(torch.ones(hidden_size)) + self.variance_epsilon = eps + + def forward(self, hidden_states): + input_dtype = hidden_states.dtype + hidden_states = hidden_states.to(torch.float32) + variance = hidden_states.pow(2).mean(-1, keepdim=True) + hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon) + return self.weight * hidden_states.to(input_dtype) + + def extra_repr(self): + return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}" + + +class Glm4MoeMoE(nn.Module): + """ + A mixed expert module containing shared experts. + """ + + def __init__(self, config): + super().__init__() + self.config = config + # self.experts = nn.ModuleList( + # [ + # Glm4MoeMLP(config, intermediate_size=config.moe_intermediate_size) + # for _ in range(config.n_routed_experts) + # ] + # ) + self.moe_mlp = scattermoe.mlp.GLUMLP( + input_size=self.config.hidden_size, + hidden_size=self.config.moe_intermediate_size, + num_experts=self.config.n_routed_experts, + top_k=self.config.num_experts_per_tok, + activation=ACT2FN[config.hidden_act], + ) + self.gate = Glm4MoeTopkRouter(config) + self.shared_experts = Glm4MoeMLP( + config=config, intermediate_size=config.moe_intermediate_size * config.n_shared_experts + ) + + #def moe(self, hidden_states: torch.Tensor, topk_indices: torch.Tensor, topk_weights: torch.Tensor): + # final_hidden_states = torch.zeros_like(hidden_states, dtype=topk_weights.dtype) + # expert_mask = torch.nn.functional.one_hot(topk_indices, num_classes=len(self.experts)) + # expert_mask = expert_mask.permute(2, 0, 1) + + # for expert_idx in range(len(self.experts)): + # expert = self.experts[expert_idx] + # mask = expert_mask[expert_idx] + # token_indices, weight_indices = torch.where(mask) + + # if token_indices.numel() > 0: + # expert_weights = topk_weights[token_indices, weight_indices] + # expert_input = hidden_states[token_indices] + # expert_output = expert(expert_input) + # weighted_output = expert_output * expert_weights.unsqueeze(-1) + # final_hidden_states.index_add_(0, token_indices, weighted_output) + + #bsz, seq_len, h = hidden_states.shape + #hidden_states = hidden_states.view(-1, hidden_states.shape[-1]) + + + # in original deepseek, the output of the experts are gathered once we leave this module + # thus the moe module is itelsf an IsolatedParallel module + # and all expert are "local" meaning we shard but we don't gather + #return final_hidden_states.type(hidden_states.dtype) + + def forward(self, hidden_states): + # residuals = hidden_states + # orig_shape = hidden_states.shape + bsz, seq_len, h = hidden_states.shape + topk_indices, topk_weights = self.gate(hidden_states) + hidden_states = hidden_states.view(-1, hidden_states.shape[-1]) + # hidden_states = self.moe(hidden_states, topk_indices, topk_weights).view(*orig_shape) + hidden_states = self.moe_mlp(hidden_states, topk_weights.to(torch.bfloat16), topk_indices) + hidden_states = hidden_states + self.shared_experts(hidden_states) + hidden_states = hidden_states.reshape(bsz, seq_len, h) + return hidden_states + + +class Glm4MoeDecoderLayer(GradientCheckpointingLayer): + def __init__(self, config: Glm4SharedMoeConfig, layer_idx: int): + super().__init__() + self.hidden_size = config.hidden_size + + self.self_attn = Glm4MoeAttention(config=config, layer_idx=layer_idx) + + if layer_idx >= config.first_k_dense_replace: + self.mlp = Glm4MoeMoE(config) + else: + self.mlp = Glm4MoeMLP(config) + + self.input_layernorm = Glm4MoeRMSNorm(config.hidden_size, eps=config.rms_norm_eps) + self.post_attention_layernorm = Glm4MoeRMSNorm(config.hidden_size, eps=config.rms_norm_eps) + + @deprecate_kwarg("past_key_value", new_name="past_key_values", version="4.58") + def forward( + self, + hidden_states: torch.Tensor, + attention_mask: Optional[torch.Tensor] = None, + position_ids: Optional[torch.LongTensor] = None, + past_key_values: Optional[Cache] = None, + use_cache: Optional[bool] = False, + cache_position: Optional[torch.LongTensor] = None, + position_embeddings: Optional[tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC + **kwargs: Unpack[TransformersKwargs], + ) -> torch.Tensor: + residual = hidden_states + hidden_states = self.input_layernorm(hidden_states) + # Self Attention + hidden_states, _ = self.self_attn( + hidden_states=hidden_states, + attention_mask=attention_mask, + position_ids=position_ids, + past_key_values=past_key_values, + use_cache=use_cache, + cache_position=cache_position, + position_embeddings=position_embeddings, + **kwargs, + ) + hidden_states = residual + hidden_states + + # Fully Connected + residual = hidden_states + hidden_states = self.post_attention_layernorm(hidden_states) + hidden_states = self.mlp(hidden_states) + hidden_states = residual + hidden_states + return hidden_states + + +@auto_docstring +class Glm4SharedMoePreTrainedModel(PreTrainedModel): + config: Glm4SharedMoeConfig + base_model_prefix = "model" + supports_gradient_checkpointing = True + _no_split_modules = ["Glm4MoeDecoderLayer"] + _skip_keys_device_placement = ["past_key_values"] + _supports_flash_attn = True + _supports_sdpa = True + _supports_flex_attn = True + _can_compile_fullgraph = False + _supports_attention_backend = True + _can_record_outputs = { + "hidden_states": Glm4MoeDecoderLayer, + "attentions": Glm4MoeAttention, + } + + def _init_weights(self, module): + super()._init_weights(module) + if isinstance(module, Glm4MoeTopkRouter): + module.weight.data.normal_(mean=0.0, std=self.config.initializer_range) + + +class Glm4MoeRotaryEmbedding(nn.Module): + inv_freq: torch.Tensor # fix linting for `register_buffer` + + def __init__(self, config: Glm4SharedMoeConfig, device=None): + super().__init__() + # BC: "rope_type" was originally "type" + if hasattr(config, "rope_scaling") and isinstance(config.rope_scaling, dict): + self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type")) + else: + self.rope_type = "default" + self.max_seq_len_cached = config.max_position_embeddings + self.original_max_seq_len = config.max_position_embeddings + + self.config = config + self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type] + + inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device) + self.register_buffer("inv_freq", inv_freq, persistent=False) + self.original_inv_freq = self.inv_freq + + @torch.no_grad() + @dynamic_rope_update # power user: used with advanced RoPE types (e.g. dynamic rope) + def forward(self, x, position_ids): + inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device) + position_ids_expanded = position_ids[:, None, :].float() + + device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu" + with torch.autocast(device_type=device_type, enabled=False): # Force float32 + freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2) + emb = torch.cat((freqs, freqs), dim=-1) + cos = emb.cos() * self.attention_scaling + sin = emb.sin() * self.attention_scaling + + return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype) + + +@auto_docstring +class Glm4SharedMoeModel(Glm4SharedMoePreTrainedModel): + _keys_to_ignore_on_load_unexpected = [r"model\.layers\.92.*", r"model\.layers\.46.*"] + + def __init__(self, config: Glm4SharedMoeConfig): + super().__init__(config) + self.padding_idx = config.pad_token_id + self.vocab_size = config.vocab_size + + self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx) + self.layers = nn.ModuleList( + [Glm4MoeDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)] + ) + self.norm = Glm4MoeRMSNorm(config.hidden_size, eps=config.rms_norm_eps) + self.rotary_emb = Glm4MoeRotaryEmbedding(config=config) + self.gradient_checkpointing = False + + # Initialize weights and apply final processing + self.post_init() + + @check_model_inputs + @auto_docstring + def forward( + self, + input_ids: Optional[torch.LongTensor] = None, + attention_mask: Optional[torch.Tensor] = None, + position_ids: Optional[torch.LongTensor] = None, + past_key_values: Optional[Cache] = None, + inputs_embeds: Optional[torch.FloatTensor] = None, + cache_position: Optional[torch.LongTensor] = None, + use_cache: Optional[bool] = None, + **kwargs: Unpack[TransformersKwargs], + ) -> BaseModelOutputWithPast: + if (input_ids is None) ^ (inputs_embeds is not None): + raise ValueError("You must specify exactly one of input_ids or inputs_embeds") + + if inputs_embeds is None: + inputs_embeds: torch.Tensor = self.embed_tokens(input_ids) + + if use_cache and past_key_values is None: + past_key_values = DynamicCache(config=self.config) + + if cache_position is None: + past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0 + cache_position: torch.Tensor = torch.arange( + past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device + ) + + if position_ids is None: + position_ids = cache_position.unsqueeze(0) + + causal_mask = create_causal_mask( + config=self.config, + input_embeds=inputs_embeds, + attention_mask=attention_mask, + cache_position=cache_position, + past_key_values=past_key_values, + position_ids=position_ids, + ) + + hidden_states = inputs_embeds + position_embeddings = self.rotary_emb(hidden_states, position_ids) + + for decoder_layer in self.layers[: self.config.num_hidden_layers]: + hidden_states = decoder_layer( + hidden_states, + attention_mask=causal_mask, + position_ids=position_ids, + past_key_values=past_key_values, + cache_position=cache_position, + position_embeddings=position_embeddings, + **kwargs, + ) + + hidden_states = self.norm(hidden_states) + return BaseModelOutputWithPast( + last_hidden_state=hidden_states, + past_key_values=past_key_values, + ) + + +@auto_docstring +class Glm4SharedMoeForCausalLM(Glm4SharedMoePreTrainedModel, GenerationMixin): + _tied_weights_keys = ["lm_head.weight"] + _tp_plan = {"lm_head": "colwise_rep"} + _pp_plan = {"lm_head": (["hidden_states"], ["logits"])} + + def __init__(self, config): + super().__init__(config) + self.model = Glm4SharedMoeModel(config) + self.vocab_size = config.vocab_size + self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False) + + # Initialize weights and apply final processing + self.post_init() + + def set_decoder(self, decoder): + self.model = decoder + + def get_decoder(self): + return self.model + + @can_return_tuple + @auto_docstring + def forward( + self, + input_ids: Optional[torch.LongTensor] = None, + attention_mask: Optional[torch.Tensor] = None, + position_ids: Optional[torch.LongTensor] = None, + past_key_values: Optional[Cache] = None, + inputs_embeds: Optional[torch.FloatTensor] = None, + labels: Optional[torch.LongTensor] = None, + use_cache: Optional[bool] = None, + cache_position: Optional[torch.LongTensor] = None, + logits_to_keep: Union[int, torch.Tensor] = 0, + **kwargs: Unpack[TransformersKwargs], + ) -> CausalLMOutputWithPast: + r""" + Example: + + ```python + >>> from transformers import AutoTokenizer, Glm4MoeForCausalLM + + >>> model = Glm4MoeForCausalLM.from_pretrained("meta-glm4_moe/Glm4Moe-2-7b-hf") + >>> tokenizer = AutoTokenizer.from_pretrained("meta-glm4_moe/Glm4Moe-2-7b-hf") + + >>> prompt = "Hey, are you conscious? Can you talk to me?" + >>> inputs = tokenizer(prompt, return_tensors="pt") + + >>> # Generate + >>> generate_ids = model.generate(inputs.input_ids, max_length=30) + >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0] + "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you." + ```""" + outputs: BaseModelOutputWithPast = self.model( + input_ids=input_ids, + attention_mask=attention_mask, + position_ids=position_ids, + past_key_values=past_key_values, + inputs_embeds=inputs_embeds, + use_cache=use_cache, + cache_position=cache_position, + **kwargs, + ) + + hidden_states = outputs.last_hidden_state + # Only compute necessary logits, and do not upcast them to float if we are not computing the loss + slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep + logits = self.lm_head(hidden_states[:, slice_indices, :]) + + loss = None + if labels is not None: + loss = self.loss_function(logits=logits, labels=labels, vocab_size=self.config.vocab_size, **kwargs) + + return CausalLMOutputWithPast( + loss=loss, + logits=logits, + past_key_values=outputs.past_key_values, + hidden_states=outputs.hidden_states, + attentions=outputs.attentions, + ) + + +__all__ = ["Glm4SharedMoePreTrainedModel", "Glm4SharedMoeModel", "Glm4SharedMoeForCausalLM"] diff --git a/tokenizer.json b/tokenizer.json new file mode 100644 index 0000000000000000000000000000000000000000..43a71efad1ab3f7e4d66d1e48e7cc44f68f21f3a --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9340665016419c825c4bdabbcc9acc43b7ca2c68ce142724afa829abb1be5efd +size 19970699 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000000000000000000000000000000000000..053f12c9b03d5acbcc921042ea0c87a6baa5d3f7 --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,325 @@ +{ + "added_tokens_decoder": { + "151329": { + "content": "<|endoftext|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151330": { + "content": "[MASK]", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151331": { + "content": "[gMASK]", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151332": { + "content": "[sMASK]", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151333": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151334": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151335": { + "content": "<|system|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151336": { + "content": "<|user|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151337": { + "content": "<|assistant|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151338": { + "content": "<|observation|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151339": { + "content": "<|begin_of_image|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151340": { + "content": "<|end_of_image|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151341": { + "content": "<|begin_of_video|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151342": { + "content": "<|end_of_video|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151343": { + "content": "<|begin_of_audio|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151344": { + "content": "<|end_of_audio|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151345": { + "content": "<|begin_of_transcription|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151346": { + "content": "<|end_of_transcription|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151347": { + "content": "<|code_prefix|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151348": { + "content": "<|code_middle|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151349": { + "content": "<|code_suffix|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151350": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + }, + "151351": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + }, + "151352": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + }, + "151353": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + }, + "151354": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + }, + "151355": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + }, + "151356": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + }, + "151357": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + }, + "151358": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + }, + "151359": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + }, + "151360": { + "content": "/nothink", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "151361": { + "content": "<|begin_of_box|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + }, + "151362": { + "content": "<|end_of_box|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + }, + "151363": { + "content": "<|image|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + }, + "151364": { + "content": "<|video|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": false + } + }, + "additional_special_tokens": [ + "<|endoftext|>", + "[MASK]", + "[gMASK]", + "[sMASK]", + "", + "", + "<|system|>", + "<|user|>", + "<|assistant|>", + "<|observation|>", + "<|begin_of_image|>", + "<|end_of_image|>", + "<|begin_of_video|>", + "<|end_of_video|>", + "<|begin_of_audio|>", + "<|end_of_audio|>", + "<|begin_of_transcription|>", + "<|end_of_transcription|>", + "<|code_prefix|>", + "<|code_middle|>", + "<|code_suffix|>", + "/nothink" + ], + "clean_up_tokenization_spaces": false, + "do_lower_case": false, + "eos_token": "<|endoftext|>", + "extra_special_tokens": {}, + "model_max_length": 128000, + "pad_token": "<|endoftext|>", + "padding_side": "left", + "remove_space": false, + "tokenizer_class": "PreTrainedTokenizer" +}