OceanLabs
/

roskosmos19 commited on
Commit
8955bf3
·
verified ·
1 Parent(s): d9bbf45

Delete configuration_k2_horizon.py

Browse files
Files changed (1) hide show
  1. configuration_k2_horizon.py +0 -96
configuration_k2_horizon.py DELETED
@@ -1,96 +0,0 @@
1
- # Copyright 2024 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- """K2Horizon model configuration"""
15
-
16
- from huggingface_hub.dataclasses import strict
17
-
18
- from transformers.configuration_utils import PreTrainedConfig
19
- from transformers.modeling_rope_utils import RopeParameters
20
-
21
-
22
- @strict
23
- class K2HorizonConfig(PreTrainedConfig):
24
- r"""
25
- decoder_sparse_step (`int`, *optional*, defaults to 1):
26
- The frequency of the MoE layer.
27
- mlp_only_layers (`list[int]`, *optional*, defaults to `[]`):
28
- Indicate which layers use K2HorizonMLP rather than K2HorizonSparseMoeBlock
29
- The list contains layer index, from 0 to num_layers-1 if we have num_layers layers
30
- If `mlp_only_layers` is empty, `decoder_sparse_step` is used to determine the sparsity.
31
-
32
- ```python
33
- >>> from transformers import K2HorizonModel, K2HorizonConfig
34
-
35
- >>> # Initializing a K2Horizon style configuration
36
- >>> configuration = K2HorizonConfig()
37
- >>> model = K2HorizonModel(configuration)
38
-
39
- >>> # Accessing the model configuration
40
- >>> configuration = model.config
41
- ```
42
- """
43
-
44
- model_type = "k2_horizon"
45
- keys_to_ignore_at_inference = ["past_key_values"]
46
-
47
- vocab_size: int = 151936
48
- hidden_size: int = 2048
49
- intermediate_size: int = 6144
50
- num_hidden_layers: int = 24
51
- num_attention_heads: int = 32
52
- num_key_value_heads: int = 4
53
- hidden_act: str = "silu"
54
- max_position_embeddings: int = 32768
55
- initializer_range: float = 0.02
56
- rms_norm_eps: float = 1e-6
57
- use_cache: bool = True
58
- tie_word_embeddings: bool = False
59
- rope_parameters: RopeParameters | dict | None = None
60
- attention_bias: bool = False
61
- use_sliding_window: bool = False
62
- sliding_window: int | None = 4096
63
- attention_dropout: float | int = 0.0
64
- decoder_sparse_step: int = 1
65
- moe_intermediate_size: int = 768
66
- num_experts_per_tok: int = 8
67
- num_experts: int = 128
68
- norm_topk_prob: bool = False
69
- output_router_logits: bool = False
70
- router_aux_loss_coef: float = 0.001
71
- mlp_only_layers: list[int] | None = None
72
- pad_token_id: int | None = None
73
- bos_token_id: int | None = None
74
- eos_token_id: int | list[int] | None = None
75
-
76
- head_dim: int = 128
77
- query_key_norm: bool = True
78
- moe_gate_bias: bool = False
79
- layernorm_num_groups: int = 1
80
- num_shared_experts: int = 0
81
- router_score_func: str = "softmax"
82
- router_scaling_factor: float | None = 1.0
83
- rope_head_dim: int | None = None
84
- attention_gate_func: str | None = None
85
- mova_num_experts: int = 0
86
- mova_num_experts_per_tok: int = 0
87
-
88
- def __post_init__(self, **kwargs):
89
- self.sliding_window = self.sliding_window if self.use_sliding_window else None
90
- self.mlp_only_layers = [] if self.mlp_only_layers is None else self.mlp_only_layers
91
- if self.router_scaling_factor is None:
92
- self.router_scaling_factor = 1.0
93
- super().__post_init__(**kwargs)
94
-
95
-
96
- __all__ = ["K2HorizonConfig"]