Add files using upload-large-folder tool
Browse files- README.md +59 -3
- config.json +37 -0
- configuration_rwkv_hybrid.py +252 -0
- figures/architecture.png +0 -0
- generation_config.json +6 -0
- hybrid_cache.py +154 -0
- model-00001-of-00007.safetensors +3 -0
- model-00002-of-00007.safetensors +3 -0
- model-00003-of-00007.safetensors +3 -0
- model-00004-of-00007.safetensors +3 -0
- model-00005-of-00007.safetensors +3 -0
- model-00006-of-00007.safetensors +3 -0
- model-00007-of-00007.safetensors +3 -0
- model.safetensors.index.json +822 -0
- modeling_rwkv_hybrid.py +632 -0
- test_gradio.py +80 -0
- tokenizer.json +0 -0
- tokenizer_config.json +207 -0
- vocab.json +0 -0
- wkv.py +522 -0
README.md
CHANGED
@@ -1,3 +1,59 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ARWKV-7B-GATE-MLP (Preview 0.1)
|
2 |
+
|
3 |
+
<img src="./figures/architecture.png" alt="ARWKV Hybrid Architecture" width="30%">
|
4 |
+
|
5 |
+
*Preview version with RWKV-7 time mixing and Transformer MLP*
|
6 |
+
|
7 |
+
## 📌 Overview
|
8 |
+
|
9 |
+
**ALL YOU NEED IS RWKV**
|
10 |
+
|
11 |
+
This is an **early preview** of our 7B parameter hybrid RNN-Transformer model, trained on 2k context length through 3-stage knowledge distillation from Qwen2.5-7B-Instruct. While being a foundational version, it demonstrates:
|
12 |
+
|
13 |
+
- ✅ RWKV-7's efficient recurrence mechanism
|
14 |
+
- ✅ No self-attention, fully O(n)
|
15 |
+
- ✅ Constant VRAM usage
|
16 |
+
- ✅ Single-GPU trainability
|
17 |
+
|
18 |
+
**Roadmap Notice**: We will soon open-source different enhanced versions with:
|
19 |
+
- 🚀 16k+ context capability
|
20 |
+
- 🧮 Math-specific improvements
|
21 |
+
- 📚 RL enhanced reasoning model
|
22 |
+
|
23 |
+
## How to use
|
24 |
+
```shell
|
25 |
+
pip3 install --upgrade rwkv-fla transformers
|
26 |
+
```
|
27 |
+
|
28 |
+
```python
|
29 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
30 |
+
|
31 |
+
|
32 |
+
model = AutoModelForCausalLM.from_pretrained(
|
33 |
+
"RWKV-Red-Team/ARWKV-7B-Preview-0.1",
|
34 |
+
device_map="auto",
|
35 |
+
torch_dtype=torch.float16,
|
36 |
+
trust_remote_code=True,
|
37 |
+
)
|
38 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
39 |
+
"RWKV-Red-Team/ARWKV-7B-Preview-0.1"
|
40 |
+
)
|
41 |
+
```
|
42 |
+
|
43 |
+
## 🔑 Key Features
|
44 |
+
| Component | Specification | Note |
|
45 |
+
|-----------|---------------|------|
|
46 |
+
| Architecture | RWKV-7 TimeMix + SwiGLU | Hybrid design |
|
47 |
+
| Context Window | 2048 training CTX | *Preview limitation* |
|
48 |
+
| Training Tokens | 40M | Distillation-focused |
|
49 |
+
| Precision | FP16 inference recommended | 15%↑ vs BF16 |
|
50 |
+
|
51 |
+
## 🏗️ Architecture Highlights
|
52 |
+
### Core Modification Flow
|
53 |
+
```diff
|
54 |
+
Qwen2.5 Decoder Layer:
|
55 |
+
- Grouped Query Attention
|
56 |
+
+ RWKV-7 Time Mixing (Eq.3)
|
57 |
+
- RoPE Positional Encoding
|
58 |
+
+ State Recurrence
|
59 |
+
= Hybrid Layer Output
|
config.json
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"RwkvHybridForCausalLM"
|
4 |
+
],
|
5 |
+
"auto_map": {
|
6 |
+
"AutoConfig": "configuration_rwkv_hybrid.RwkvHybridConfig",
|
7 |
+
"AutoModelForCausalLM": "modeling_rwkv_hybrid.RwkvHybridForCausalLM"
|
8 |
+
},
|
9 |
+
"attention_dropout": 0.0,
|
10 |
+
"bos_token_id": 151643,
|
11 |
+
"eos_token_id": 151645,
|
12 |
+
"head_size": 64,
|
13 |
+
"head_size_divisor": 8,
|
14 |
+
"hidden_act": "silu",
|
15 |
+
"hidden_size": 3584,
|
16 |
+
"initializer_range": 0.02,
|
17 |
+
"intermediate_size": 18944,
|
18 |
+
"max_position_embeddings": 32768,
|
19 |
+
"max_window_layers": 28,
|
20 |
+
"model_type": "rwkv_hybrid",
|
21 |
+
"num_attention_heads": 28,
|
22 |
+
"num_hidden_layers": 28,
|
23 |
+
"num_key_value_heads": 4,
|
24 |
+
"rms_norm_eps": 1e-06,
|
25 |
+
"rope_scaling": null,
|
26 |
+
"rope_theta": 1000000.0,
|
27 |
+
"sliding_window": null,
|
28 |
+
"tie_word_embeddings": false,
|
29 |
+
"torch_dtype": "float16",
|
30 |
+
"transformers_version": "4.49.0.dev0",
|
31 |
+
"use_cache": true,
|
32 |
+
"use_sliding_window": false,
|
33 |
+
"vocab_size": 152064,
|
34 |
+
"wkv_has_gate": true,
|
35 |
+
"wkv_has_group_norm": false,
|
36 |
+
"wkv_version": 7
|
37 |
+
}
|
configuration_rwkv_hybrid.py
ADDED
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2025 RWKV team. All rights reserved.
|
3 |
+
# Copyright 2024 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.
|
4 |
+
#
|
5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
# you may not use this file except in compliance with the License.
|
7 |
+
# You may obtain a copy of the License at
|
8 |
+
#
|
9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
#
|
11 |
+
# Unless required by applicable law or agreed to in writing, software
|
12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
# See the License for the specific language governing permissions and
|
15 |
+
# limitations under the License.
|
16 |
+
"""RwkvHybrid model configuration"""
|
17 |
+
|
18 |
+
from transformers.configuration_utils import PretrainedConfig
|
19 |
+
from transformers.modeling_rope_utils import rope_config_validation
|
20 |
+
from transformers.utils import logging
|
21 |
+
from typing import Optional, Union, List
|
22 |
+
|
23 |
+
|
24 |
+
logger = logging.get_logger(__name__)
|
25 |
+
|
26 |
+
|
27 |
+
class RwkvHybridConfig(PretrainedConfig):
|
28 |
+
r"""
|
29 |
+
This is the configuration class to store the configuration of a [`RwkvHybridModel`]. It is used to instantiate a
|
30 |
+
RwkvHybrid model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
31 |
+
with the defaults will yield a similar configuration to that of
|
32 |
+
RwkvHybrid-7B-beta.
|
33 |
+
|
34 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
35 |
+
documentation from [`PretrainedConfig`] for more information.
|
36 |
+
|
37 |
+
|
38 |
+
Args:
|
39 |
+
vocab_size (`int`, *optional*, defaults to 151936):
|
40 |
+
Vocabulary size of the RwkvHybrid model. Defines the number of different tokens that can be represented by the
|
41 |
+
`inputs_ids` passed when calling [`RwkvHybridModel`]
|
42 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
43 |
+
Dimension of the hidden representations.
|
44 |
+
intermediate_size (`int`, *optional*, defaults to 22016):
|
45 |
+
Dimension of the MLP representations.
|
46 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
47 |
+
Number of hidden layers in the Transformer encoder.
|
48 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
49 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
50 |
+
num_key_value_heads (`int`, *optional*, defaults to 32):
|
51 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
52 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
53 |
+
`num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
54 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
55 |
+
by meanpooling all the original heads within that group. For more details checkout [this
|
56 |
+
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to `32`.
|
57 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
58 |
+
The non-linear activation function (function or string) in the decoder.
|
59 |
+
max_position_embeddings (`int`, *optional*, defaults to 32768):
|
60 |
+
The maximum sequence length that this model might ever be used with.
|
61 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
62 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
63 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-06):
|
64 |
+
The epsilon used by the rms normalization layers.
|
65 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
66 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
67 |
+
relevant if `config.is_decoder=True`.
|
68 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
69 |
+
Whether the model's input and output word embeddings should be tied.
|
70 |
+
rope_theta (`float`, *optional*, defaults to 10000.0):
|
71 |
+
The base period of the RoPE embeddings.
|
72 |
+
rope_scaling (`Dict`, *optional*):
|
73 |
+
Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
|
74 |
+
and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
|
75 |
+
accordingly.
|
76 |
+
Expected contents:
|
77 |
+
`rope_type` (`str`):
|
78 |
+
The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
|
79 |
+
'llama3'], with 'default' being the original RoPE implementation.
|
80 |
+
`factor` (`float`, *optional*):
|
81 |
+
Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
|
82 |
+
most scaling types, a `factor` of x will enable the model to handle sequences of length x *
|
83 |
+
original maximum pre-trained length.
|
84 |
+
`original_max_position_embeddings` (`int`, *optional*):
|
85 |
+
Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
|
86 |
+
pretraining.
|
87 |
+
`attention_factor` (`float`, *optional*):
|
88 |
+
Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
|
89 |
+
computation. If unspecified, it defaults to value recommended by the implementation, using the
|
90 |
+
`factor` field to infer the suggested value.
|
91 |
+
`beta_fast` (`float`, *optional*):
|
92 |
+
Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
|
93 |
+
ramp function. If unspecified, it defaults to 32.
|
94 |
+
`beta_slow` (`float`, *optional*):
|
95 |
+
Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
|
96 |
+
ramp function. If unspecified, it defaults to 1.
|
97 |
+
`short_factor` (`List[float]`, *optional*):
|
98 |
+
Only used with 'longrope'. The scaling factor to be applied to short contexts (<
|
99 |
+
`original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
|
100 |
+
size divided by the number of attention heads divided by 2
|
101 |
+
`long_factor` (`List[float]`, *optional*):
|
102 |
+
Only used with 'longrope'. The scaling factor to be applied to long contexts (<
|
103 |
+
`original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
|
104 |
+
size divided by the number of attention heads divided by 2
|
105 |
+
`low_freq_factor` (`float`, *optional*):
|
106 |
+
Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
|
107 |
+
`high_freq_factor` (`float`, *optional*):
|
108 |
+
Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
|
109 |
+
use_sliding_window (`bool`, *optional*, defaults to `False`):
|
110 |
+
Whether to use sliding window attention.
|
111 |
+
sliding_window (`int`, *optional*, defaults to 4096):
|
112 |
+
Sliding window attention (SWA) window size. If not specified, will default to `4096`.
|
113 |
+
max_window_layers (`int`, *optional*, defaults to 28):
|
114 |
+
The number of layers that use SWA (Sliding Window Attention). The bottom layers use SWA while the top use full attention.
|
115 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
116 |
+
The dropout ratio for the attention probabilities.
|
117 |
+
head_size (`int`, *optional*, defaults to 64):
|
118 |
+
Dimensionality of each RWKV attention head. Defines the hidden dimension size for RWKV attention mechanisms.
|
119 |
+
head_size_divisor (`int`, *optional*, defaults to 8):
|
120 |
+
Constraint for head_size initialization, typically set to the square root of head_size. Ensures divisibility
|
121 |
+
between hidden_size and head_size.
|
122 |
+
wkv_version (`int`, *optional*, defaults to 7):
|
123 |
+
Version of RWKV attention implementation. Currently supports:
|
124 |
+
- 6: Original implementation requiring `wkv_has_gate=True` and `wkv_use_vfirst=False`
|
125 |
+
- 7: Improved version requiring `wkv_use_vfirst=True`
|
126 |
+
wkv_has_gate (`bool`, *optional*, defaults to False):
|
127 |
+
Whether to include gating mechanism in RWKV attention. Required for version 6.
|
128 |
+
wkv_has_group_norm (`bool`, *optional*, defaults to True):
|
129 |
+
Whether to apply group normalization in RWKV attention layers.
|
130 |
+
wkv_use_vfirst (`bool`, *optional*, defaults to True):
|
131 |
+
Whether to prioritize value projection in RWKV attention computation. Required for version 7.
|
132 |
+
wkv_layers (`Union[str, List[int]]`, *optional*, defaults to None):
|
133 |
+
Specifies which layers use RWKV attention:
|
134 |
+
- `"full"` or `None`: All layers use RWKV
|
135 |
+
- List of integers: Only specified layers (e.g., `[0,1,2]`) use RWKV attention
|
136 |
+
|
137 |
+
```python
|
138 |
+
>>> from transformers import RwkvHybridModel, RwkvHybridConfig
|
139 |
+
|
140 |
+
>>> # Initializing a RwkvHybrid style configuration
|
141 |
+
>>> configuration = RwkvHybridConfig()
|
142 |
+
|
143 |
+
>>> # Initializing a model from the RwkvHybrid-7B style configuration
|
144 |
+
>>> model = RwkvHybridModel(configuration)
|
145 |
+
|
146 |
+
>>> # Accessing the model configuration
|
147 |
+
>>> configuration = model.config
|
148 |
+
```"""
|
149 |
+
|
150 |
+
model_type = "rwkv_hybrid"
|
151 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
152 |
+
|
153 |
+
# Default tensor parallel plan for base model `RwkvHybrid`
|
154 |
+
base_model_tp_plan = {
|
155 |
+
"layers.*.self_attn.q_proj": "colwise",
|
156 |
+
"layers.*.self_attn.k_proj": "colwise",
|
157 |
+
"layers.*.self_attn.v_proj": "colwise",
|
158 |
+
"layers.*.self_attn.o_proj": "rowwise",
|
159 |
+
"layers.*.mlp.gate_proj": "colwise",
|
160 |
+
"layers.*.mlp.up_proj": "colwise",
|
161 |
+
"layers.*.mlp.down_proj": "rowwise",
|
162 |
+
}
|
163 |
+
|
164 |
+
def __init__(
|
165 |
+
self,
|
166 |
+
vocab_size: int = 151936,
|
167 |
+
hidden_size: int = 4096,
|
168 |
+
intermediate_size: int = 22016,
|
169 |
+
num_hidden_layers: int = 32,
|
170 |
+
num_attention_heads: int = 32,
|
171 |
+
num_key_value_heads: int = 32,
|
172 |
+
head_size: int = 64,
|
173 |
+
head_size_divisor: int = 8,
|
174 |
+
hidden_act: str = "silu",
|
175 |
+
max_position_embeddings: int = 32768,
|
176 |
+
initializer_range: float = 0.02,
|
177 |
+
rms_norm_eps: float = 1e-6,
|
178 |
+
use_cache: bool = True,
|
179 |
+
tie_word_embeddings: bool = False,
|
180 |
+
rope_theta: float = 10000.0,
|
181 |
+
rope_scaling: Optional[dict] = None,
|
182 |
+
use_sliding_window: bool = False,
|
183 |
+
sliding_window: int = 4096,
|
184 |
+
max_window_layers: int = 28,
|
185 |
+
attention_dropout: float = 0.0,
|
186 |
+
wkv_version: int = 7,
|
187 |
+
wkv_has_gate: bool = False,
|
188 |
+
wkv_has_group_norm: bool = True,
|
189 |
+
wkv_use_vfirst: bool = True,
|
190 |
+
wkv_layers: Optional[Union[str, List[int]]] = None,
|
191 |
+
**kwargs,
|
192 |
+
):
|
193 |
+
self.vocab_size = vocab_size
|
194 |
+
self.max_position_embeddings = max_position_embeddings
|
195 |
+
self.hidden_size = hidden_size
|
196 |
+
self.intermediate_size = intermediate_size
|
197 |
+
self.num_hidden_layers = num_hidden_layers
|
198 |
+
self.num_wkv_heads = hidden_size // head_size
|
199 |
+
assert hidden_size % head_size == 0, "hidden_size must be divisible by head_size"
|
200 |
+
self.num_attention_heads = num_attention_heads
|
201 |
+
self.use_sliding_window = use_sliding_window
|
202 |
+
self.sliding_window = sliding_window if use_sliding_window else None
|
203 |
+
self.max_window_layers = max_window_layers
|
204 |
+
self.head_size = head_size
|
205 |
+
self.head_size_divisor = head_size_divisor
|
206 |
+
self.wkv_version = wkv_version
|
207 |
+
|
208 |
+
self.wkv_has_gate = wkv_has_gate
|
209 |
+
self.wkv_has_group_norm = wkv_has_group_norm
|
210 |
+
self.wkv_use_vfirst = wkv_use_vfirst
|
211 |
+
|
212 |
+
if self.wkv_version == 7:
|
213 |
+
assert self.wkv_use_vfirst, "wkv_use_vfirst must be True for wkv_version 7"
|
214 |
+
elif self.wkv_version == 6:
|
215 |
+
assert self.wkv_has_gate, "wkv_has_gate must be True for wkv_version 6"
|
216 |
+
assert not self.wkv_use_vfirst, "wkv_use_vfirst must be False for wkv_version 6"
|
217 |
+
else:
|
218 |
+
raise NotImplementedError(f"Unsupported wkv_version: {self.wkv_version}, \
|
219 |
+
wkv_version must be 6 or 7")
|
220 |
+
|
221 |
+
if wkv_layers == "full" or wkv_layers == None:
|
222 |
+
self.wkv_layers = list(range(num_hidden_layers))
|
223 |
+
elif isinstance(wkv_layers, list):
|
224 |
+
if all(isinstance(layer, int) for layer in wkv_layers):
|
225 |
+
self.wkv_layers = wkv_layers
|
226 |
+
else:
|
227 |
+
raise ValueError("All elements in wkv_layers must be integers.")
|
228 |
+
else:
|
229 |
+
raise TypeError("wkv_layers must be either 'full', None, or a list of integers.")
|
230 |
+
|
231 |
+
# for backward compatibility
|
232 |
+
if num_key_value_heads is None:
|
233 |
+
num_key_value_heads = num_attention_heads
|
234 |
+
|
235 |
+
self.num_key_value_heads = num_key_value_heads
|
236 |
+
self.hidden_act = hidden_act
|
237 |
+
self.initializer_range = initializer_range
|
238 |
+
self.rms_norm_eps = rms_norm_eps
|
239 |
+
self.use_cache = use_cache
|
240 |
+
self.rope_theta = rope_theta
|
241 |
+
self.rope_scaling = rope_scaling
|
242 |
+
self.attention_dropout = attention_dropout
|
243 |
+
# Validate the correctness of rotary position embeddings parameters
|
244 |
+
# BC: if there is a 'type' field, move it to 'rope_type'.
|
245 |
+
if self.rope_scaling is not None and "type" in self.rope_scaling:
|
246 |
+
self.rope_scaling["rope_type"] = self.rope_scaling["type"]
|
247 |
+
rope_config_validation(self)
|
248 |
+
|
249 |
+
super().__init__(
|
250 |
+
tie_word_embeddings=tie_word_embeddings,
|
251 |
+
**kwargs,
|
252 |
+
)
|
figures/architecture.png
ADDED
generation_config.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 151643,
|
4 |
+
"eos_token_id": 151645,
|
5 |
+
"transformers_version": "4.48.0.dev0"
|
6 |
+
}
|
hybrid_cache.py
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from typing import Any, Dict, Optional, Union
|
3 |
+
from transformers.cache_utils import DynamicCache
|
4 |
+
|
5 |
+
|
6 |
+
class TimeMixState:
|
7 |
+
def __init__(self, shift_state: torch.Tensor, wkv_state: torch.Tensor):
|
8 |
+
self.shift_state = shift_state
|
9 |
+
self.wkv_state = wkv_state
|
10 |
+
|
11 |
+
|
12 |
+
class ChannelMixState:
|
13 |
+
def __init__(self, shift_state: torch.Tensor):
|
14 |
+
self.shift_state = shift_state
|
15 |
+
|
16 |
+
|
17 |
+
class BlockState:
|
18 |
+
def __init__(self, time_mix_state: TimeMixState,
|
19 |
+
channel_mix_state: ChannelMixState):
|
20 |
+
self.time_mix_state = time_mix_state
|
21 |
+
self.channel_mix_state = channel_mix_state
|
22 |
+
|
23 |
+
|
24 |
+
class BlockStateList:
|
25 |
+
def __init__(self, shift_states, wkv_states):
|
26 |
+
self.wkv_states = wkv_states
|
27 |
+
self.shift_states = shift_states
|
28 |
+
|
29 |
+
@staticmethod
|
30 |
+
def create(N, B, C, H, device, dtype):
|
31 |
+
result = BlockStateList.empty(N, B, C, H, device, dtype)
|
32 |
+
result.wkv_states[:] = 0
|
33 |
+
result.wkv_states[:] = 0
|
34 |
+
result.shift_states[:] = 0
|
35 |
+
return result
|
36 |
+
|
37 |
+
@staticmethod
|
38 |
+
def empty(N, B, C, H, device, dtype):
|
39 |
+
wkv_states = torch.empty((N, B, H, C//H, C//H),
|
40 |
+
device=device,
|
41 |
+
dtype=torch.bfloat16)
|
42 |
+
shift_states = torch.empty((N, 2, B, C), device=device, dtype=dtype)
|
43 |
+
return BlockStateList(shift_states, wkv_states)
|
44 |
+
|
45 |
+
def __getitem__(self, layer: int):
|
46 |
+
return BlockState(
|
47 |
+
TimeMixState(self.shift_states[layer, 0], self.wkv_states[layer]),
|
48 |
+
ChannelMixState(self.shift_states[layer, 1]))
|
49 |
+
|
50 |
+
def __setitem__(self, layer: int, state: BlockState):
|
51 |
+
self.shift_states[layer, 0] = state.time_mix_state.shift_state
|
52 |
+
self.wkv_states[layer] = state.time_mix_state.wkv_state
|
53 |
+
self.shift_states[layer, 1] = state.channel_mix_state.shift_state
|
54 |
+
|
55 |
+
|
56 |
+
class HybridCache(DynamicCache):
|
57 |
+
def __init__(self) -> None:
|
58 |
+
super().__init__()
|
59 |
+
self.rwkv_layers = set()
|
60 |
+
|
61 |
+
def __repr__(self) -> str:
|
62 |
+
rwkv_layers = f"HybridCache(rwkv_layers={self.rwkv_layers})"
|
63 |
+
# count the number of key_cache and value_cache
|
64 |
+
key_cache_count = sum(len(cache) for cache in self.key_cache)
|
65 |
+
value_cache_count = sum(len(cache) for cache in self.value_cache)
|
66 |
+
count_info = rwkv_layers + \
|
67 |
+
f", key_cache_count={key_cache_count}, value_cache_count={value_cache_count}"
|
68 |
+
memories = 0
|
69 |
+
seq_length = self.get_seq_length()
|
70 |
+
for cache in self.value_cache:
|
71 |
+
for data in cache:
|
72 |
+
if not isinstance(data, torch.Tensor):
|
73 |
+
memories += data.time_mix_state.wkv_state.numel()
|
74 |
+
else:
|
75 |
+
memories += data.numel()
|
76 |
+
count_info += f", memories={memories / 1024/1024}MB, seq_length={seq_length}"
|
77 |
+
return count_info
|
78 |
+
|
79 |
+
def update(self,
|
80 |
+
key_states: Union[int, torch.Tensor],
|
81 |
+
value_states: Union[torch.Tensor, BlockState],
|
82 |
+
layer_idx: int,
|
83 |
+
cache_kwargs: Optional[Dict[str, Any]] = None):
|
84 |
+
if isinstance(key_states, int) and not isinstance(value_states, torch.Tensor):
|
85 |
+
self.rwkv_layers.add(layer_idx)
|
86 |
+
if layer_idx >= len(self.key_cache):
|
87 |
+
self.key_cache.append([])
|
88 |
+
self.value_cache.append([])
|
89 |
+
|
90 |
+
if len(self.key_cache[layer_idx]) == 0:
|
91 |
+
self.key_cache[layer_idx].append(key_states)
|
92 |
+
self.value_cache[layer_idx].append(value_states)
|
93 |
+
else:
|
94 |
+
self.key_cache[layer_idx][0] = self.key_cache[layer_idx][0]+key_states
|
95 |
+
self.value_cache[layer_idx][0] = value_states
|
96 |
+
|
97 |
+
return key_states, value_states
|
98 |
+
|
99 |
+
return super().update(key_states, value_states, layer_idx, cache_kwargs)
|
100 |
+
|
101 |
+
def get_seq_length(self, layer_idx: Optional[int] = 0):
|
102 |
+
if layer_idx in self.rwkv_layers:
|
103 |
+
return self.key_cache[layer_idx][0]
|
104 |
+
return super().get_seq_length(layer_idx)
|
105 |
+
|
106 |
+
def get_max_length(self):
|
107 |
+
return super().get_max_length()
|
108 |
+
|
109 |
+
def reorder_cache(self, beam_idx):
|
110 |
+
return super().reorder_cache(beam_idx)
|
111 |
+
|
112 |
+
def __getitem__(self, item):
|
113 |
+
if item in self.rwkv_layers:
|
114 |
+
return self.value_cache[item]
|
115 |
+
return super().__getitem__(item)
|
116 |
+
|
117 |
+
def offload_to_cpu(self):
|
118 |
+
for cache in self.value_cache:
|
119 |
+
for data in cache:
|
120 |
+
if isinstance(data, torch.Tensor):
|
121 |
+
data.cpu()
|
122 |
+
else:
|
123 |
+
data.time_mix_state.wkv_state.cpu()
|
124 |
+
data.time_mix_state.shift_state.cpu()
|
125 |
+
|
126 |
+
def offload_to_cuda(self, device: str):
|
127 |
+
for cache in self.value_cache:
|
128 |
+
for data in cache:
|
129 |
+
if isinstance(data, torch.Tensor):
|
130 |
+
data.cuda(device)
|
131 |
+
else:
|
132 |
+
data.time_mix_state.wkv_state.cuda(device)
|
133 |
+
data.time_mix_state.shift_state.cuda(device)
|
134 |
+
|
135 |
+
def offload_to_device(self, device_type: str, device_id: int = 0):
|
136 |
+
for cache in self.value_cache:
|
137 |
+
for data in cache:
|
138 |
+
if isinstance(data, torch.Tensor):
|
139 |
+
method = getattr(data, device_type)
|
140 |
+
if device_type == 'cpu':
|
141 |
+
method()
|
142 |
+
else:
|
143 |
+
method(device_id)
|
144 |
+
else:
|
145 |
+
wkv_state_method = getattr(
|
146 |
+
data.time_mix_state.wkv_state, device_type)
|
147 |
+
shift_state_method = getattr(
|
148 |
+
data.time_mix_state.shift_state, device_type)
|
149 |
+
if device_type == 'cpu':
|
150 |
+
wkv_state_method()
|
151 |
+
shift_state_method()
|
152 |
+
else:
|
153 |
+
wkv_state_method(device_id)
|
154 |
+
shift_state_method(device_id)
|
model-00001-of-00007.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c8c13c712edc185ad5f3cbb70d1be8cf614ea758d46955d4d0457188c25f419f
|
3 |
+
size 4994557640
|
model-00002-of-00007.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6b580e7029be7d39e4611398571615478e406e0ecf102a64cf5604d9d9c948a8
|
3 |
+
size 4872049040
|
model-00003-of-00007.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d3a17bf7ef65b25ca36667d241da976d2b8a92415c50518a97b7bbfc555cc133
|
3 |
+
size 4872049096
|
model-00004-of-00007.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3ddef2d83f1b62d76e83e7b1c9ee6664de10d03e0a3ba9b0fafb0bd4fb2dc8ab
|
3 |
+
size 4989489432
|
model-00005-of-00007.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:59ba5eef2db961008887debbe34115f5883d85b0de30da22d213e6dfa1e25791
|
3 |
+
size 4812208032
|
model-00006-of-00007.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b8876934389ca0245be337ccb042ba0fb39e1172edb1826c915c56107d0c2639
|
3 |
+
size 4872049184
|
model-00007-of-00007.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:813be839a70ed5c89a7242e95bd690c954cb1530d7a284b5dce4dd74d76b2c7f
|
3 |
+
size 3751921648
|
model.safetensors.index.json
ADDED
@@ -0,0 +1,822 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"metadata": {
|
3 |
+
"total_size": 33164228608
|
4 |
+
},
|
5 |
+
"weight_map": {
|
6 |
+
"lm_head.weight": "model-00007-of-00007.safetensors",
|
7 |
+
"model.embed_tokens.weight": "model-00001-of-00007.safetensors",
|
8 |
+
"model.layers.0.input_layernorm.weight": "model-00001-of-00007.safetensors",
|
9 |
+
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00007.safetensors",
|
10 |
+
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00007.safetensors",
|
11 |
+
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00007.safetensors",
|
12 |
+
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00007.safetensors",
|
13 |
+
"model.layers.0.self_attn.time_mixer.a0": "model-00001-of-00007.safetensors",
|
14 |
+
"model.layers.0.self_attn.time_mixer.a1": "model-00001-of-00007.safetensors",
|
15 |
+
"model.layers.0.self_attn.time_mixer.a2": "model-00001-of-00007.safetensors",
|
16 |
+
"model.layers.0.self_attn.time_mixer.g1": "model-00001-of-00007.safetensors",
|
17 |
+
"model.layers.0.self_attn.time_mixer.g2": "model-00001-of-00007.safetensors",
|
18 |
+
"model.layers.0.self_attn.time_mixer.k_a": "model-00001-of-00007.safetensors",
|
19 |
+
"model.layers.0.self_attn.time_mixer.k_k": "model-00001-of-00007.safetensors",
|
20 |
+
"model.layers.0.self_attn.time_mixer.key.weight": "model-00001-of-00007.safetensors",
|
21 |
+
"model.layers.0.self_attn.time_mixer.output.weight": "model-00001-of-00007.safetensors",
|
22 |
+
"model.layers.0.self_attn.time_mixer.r_k": "model-00001-of-00007.safetensors",
|
23 |
+
"model.layers.0.self_attn.time_mixer.receptance.weight": "model-00001-of-00007.safetensors",
|
24 |
+
"model.layers.0.self_attn.time_mixer.v0": "model-00001-of-00007.safetensors",
|
25 |
+
"model.layers.0.self_attn.time_mixer.v1": "model-00001-of-00007.safetensors",
|
26 |
+
"model.layers.0.self_attn.time_mixer.v2": "model-00001-of-00007.safetensors",
|
27 |
+
"model.layers.0.self_attn.time_mixer.value.weight": "model-00001-of-00007.safetensors",
|
28 |
+
"model.layers.0.self_attn.time_mixer.w0": "model-00001-of-00007.safetensors",
|
29 |
+
"model.layers.0.self_attn.time_mixer.w1": "model-00001-of-00007.safetensors",
|
30 |
+
"model.layers.0.self_attn.time_mixer.w2": "model-00001-of-00007.safetensors",
|
31 |
+
"model.layers.0.self_attn.time_mixer.x_a": "model-00001-of-00007.safetensors",
|
32 |
+
"model.layers.0.self_attn.time_mixer.x_g": "model-00001-of-00007.safetensors",
|
33 |
+
"model.layers.0.self_attn.time_mixer.x_k": "model-00001-of-00007.safetensors",
|
34 |
+
"model.layers.0.self_attn.time_mixer.x_r": "model-00001-of-00007.safetensors",
|
35 |
+
"model.layers.0.self_attn.time_mixer.x_v": "model-00001-of-00007.safetensors",
|
36 |
+
"model.layers.0.self_attn.time_mixer.x_w": "model-00001-of-00007.safetensors",
|
37 |
+
"model.layers.1.input_layernorm.weight": "model-00001-of-00007.safetensors",
|
38 |
+
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00007.safetensors",
|
39 |
+
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00007.safetensors",
|
40 |
+
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00007.safetensors",
|
41 |
+
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00007.safetensors",
|
42 |
+
"model.layers.1.self_attn.time_mixer.a0": "model-00001-of-00007.safetensors",
|
43 |
+
"model.layers.1.self_attn.time_mixer.a1": "model-00001-of-00007.safetensors",
|
44 |
+
"model.layers.1.self_attn.time_mixer.a2": "model-00001-of-00007.safetensors",
|
45 |
+
"model.layers.1.self_attn.time_mixer.g1": "model-00001-of-00007.safetensors",
|
46 |
+
"model.layers.1.self_attn.time_mixer.g2": "model-00001-of-00007.safetensors",
|
47 |
+
"model.layers.1.self_attn.time_mixer.k_a": "model-00001-of-00007.safetensors",
|
48 |
+
"model.layers.1.self_attn.time_mixer.k_k": "model-00001-of-00007.safetensors",
|
49 |
+
"model.layers.1.self_attn.time_mixer.key.weight": "model-00001-of-00007.safetensors",
|
50 |
+
"model.layers.1.self_attn.time_mixer.output.weight": "model-00001-of-00007.safetensors",
|
51 |
+
"model.layers.1.self_attn.time_mixer.r_k": "model-00001-of-00007.safetensors",
|
52 |
+
"model.layers.1.self_attn.time_mixer.receptance.weight": "model-00001-of-00007.safetensors",
|
53 |
+
"model.layers.1.self_attn.time_mixer.v0": "model-00001-of-00007.safetensors",
|
54 |
+
"model.layers.1.self_attn.time_mixer.v1": "model-00001-of-00007.safetensors",
|
55 |
+
"model.layers.1.self_attn.time_mixer.v2": "model-00001-of-00007.safetensors",
|
56 |
+
"model.layers.1.self_attn.time_mixer.value.weight": "model-00001-of-00007.safetensors",
|
57 |
+
"model.layers.1.self_attn.time_mixer.w0": "model-00001-of-00007.safetensors",
|
58 |
+
"model.layers.1.self_attn.time_mixer.w1": "model-00001-of-00007.safetensors",
|
59 |
+
"model.layers.1.self_attn.time_mixer.w2": "model-00001-of-00007.safetensors",
|
60 |
+
"model.layers.1.self_attn.time_mixer.x_a": "model-00001-of-00007.safetensors",
|
61 |
+
"model.layers.1.self_attn.time_mixer.x_g": "model-00001-of-00007.safetensors",
|
62 |
+
"model.layers.1.self_attn.time_mixer.x_k": "model-00001-of-00007.safetensors",
|
63 |
+
"model.layers.1.self_attn.time_mixer.x_r": "model-00001-of-00007.safetensors",
|
64 |
+
"model.layers.1.self_attn.time_mixer.x_v": "model-00001-of-00007.safetensors",
|
65 |
+
"model.layers.1.self_attn.time_mixer.x_w": "model-00001-of-00007.safetensors",
|
66 |
+
"model.layers.10.input_layernorm.weight": "model-00003-of-00007.safetensors",
|
67 |
+
"model.layers.10.mlp.down_proj.weight": "model-00003-of-00007.safetensors",
|
68 |
+
"model.layers.10.mlp.gate_proj.weight": "model-00003-of-00007.safetensors",
|
69 |
+
"model.layers.10.mlp.up_proj.weight": "model-00003-of-00007.safetensors",
|
70 |
+
"model.layers.10.post_attention_layernorm.weight": "model-00003-of-00007.safetensors",
|
71 |
+
"model.layers.10.self_attn.time_mixer.a0": "model-00003-of-00007.safetensors",
|
72 |
+
"model.layers.10.self_attn.time_mixer.a1": "model-00003-of-00007.safetensors",
|
73 |
+
"model.layers.10.self_attn.time_mixer.a2": "model-00003-of-00007.safetensors",
|
74 |
+
"model.layers.10.self_attn.time_mixer.g1": "model-00003-of-00007.safetensors",
|
75 |
+
"model.layers.10.self_attn.time_mixer.g2": "model-00003-of-00007.safetensors",
|
76 |
+
"model.layers.10.self_attn.time_mixer.k_a": "model-00003-of-00007.safetensors",
|
77 |
+
"model.layers.10.self_attn.time_mixer.k_k": "model-00003-of-00007.safetensors",
|
78 |
+
"model.layers.10.self_attn.time_mixer.key.weight": "model-00003-of-00007.safetensors",
|
79 |
+
"model.layers.10.self_attn.time_mixer.output.weight": "model-00003-of-00007.safetensors",
|
80 |
+
"model.layers.10.self_attn.time_mixer.r_k": "model-00003-of-00007.safetensors",
|
81 |
+
"model.layers.10.self_attn.time_mixer.receptance.weight": "model-00003-of-00007.safetensors",
|
82 |
+
"model.layers.10.self_attn.time_mixer.v0": "model-00003-of-00007.safetensors",
|
83 |
+
"model.layers.10.self_attn.time_mixer.v1": "model-00003-of-00007.safetensors",
|
84 |
+
"model.layers.10.self_attn.time_mixer.v2": "model-00003-of-00007.safetensors",
|
85 |
+
"model.layers.10.self_attn.time_mixer.value.weight": "model-00003-of-00007.safetensors",
|
86 |
+
"model.layers.10.self_attn.time_mixer.w0": "model-00003-of-00007.safetensors",
|
87 |
+
"model.layers.10.self_attn.time_mixer.w1": "model-00003-of-00007.safetensors",
|
88 |
+
"model.layers.10.self_attn.time_mixer.w2": "model-00003-of-00007.safetensors",
|
89 |
+
"model.layers.10.self_attn.time_mixer.x_a": "model-00003-of-00007.safetensors",
|
90 |
+
"model.layers.10.self_attn.time_mixer.x_g": "model-00003-of-00007.safetensors",
|
91 |
+
"model.layers.10.self_attn.time_mixer.x_k": "model-00003-of-00007.safetensors",
|
92 |
+
"model.layers.10.self_attn.time_mixer.x_r": "model-00003-of-00007.safetensors",
|
93 |
+
"model.layers.10.self_attn.time_mixer.x_v": "model-00003-of-00007.safetensors",
|
94 |
+
"model.layers.10.self_attn.time_mixer.x_w": "model-00003-of-00007.safetensors",
|
95 |
+
"model.layers.11.input_layernorm.weight": "model-00003-of-00007.safetensors",
|
96 |
+
"model.layers.11.mlp.down_proj.weight": "model-00003-of-00007.safetensors",
|
97 |
+
"model.layers.11.mlp.gate_proj.weight": "model-00003-of-00007.safetensors",
|
98 |
+
"model.layers.11.mlp.up_proj.weight": "model-00003-of-00007.safetensors",
|
99 |
+
"model.layers.11.post_attention_layernorm.weight": "model-00003-of-00007.safetensors",
|
100 |
+
"model.layers.11.self_attn.time_mixer.a0": "model-00003-of-00007.safetensors",
|
101 |
+
"model.layers.11.self_attn.time_mixer.a1": "model-00003-of-00007.safetensors",
|
102 |
+
"model.layers.11.self_attn.time_mixer.a2": "model-00003-of-00007.safetensors",
|
103 |
+
"model.layers.11.self_attn.time_mixer.g1": "model-00003-of-00007.safetensors",
|
104 |
+
"model.layers.11.self_attn.time_mixer.g2": "model-00003-of-00007.safetensors",
|
105 |
+
"model.layers.11.self_attn.time_mixer.k_a": "model-00003-of-00007.safetensors",
|
106 |
+
"model.layers.11.self_attn.time_mixer.k_k": "model-00003-of-00007.safetensors",
|
107 |
+
"model.layers.11.self_attn.time_mixer.key.weight": "model-00003-of-00007.safetensors",
|
108 |
+
"model.layers.11.self_attn.time_mixer.output.weight": "model-00003-of-00007.safetensors",
|
109 |
+
"model.layers.11.self_attn.time_mixer.r_k": "model-00003-of-00007.safetensors",
|
110 |
+
"model.layers.11.self_attn.time_mixer.receptance.weight": "model-00003-of-00007.safetensors",
|
111 |
+
"model.layers.11.self_attn.time_mixer.v0": "model-00003-of-00007.safetensors",
|
112 |
+
"model.layers.11.self_attn.time_mixer.v1": "model-00003-of-00007.safetensors",
|
113 |
+
"model.layers.11.self_attn.time_mixer.v2": "model-00003-of-00007.safetensors",
|
114 |
+
"model.layers.11.self_attn.time_mixer.value.weight": "model-00003-of-00007.safetensors",
|
115 |
+
"model.layers.11.self_attn.time_mixer.w0": "model-00003-of-00007.safetensors",
|
116 |
+
"model.layers.11.self_attn.time_mixer.w1": "model-00003-of-00007.safetensors",
|
117 |
+
"model.layers.11.self_attn.time_mixer.w2": "model-00003-of-00007.safetensors",
|
118 |
+
"model.layers.11.self_attn.time_mixer.x_a": "model-00003-of-00007.safetensors",
|
119 |
+
"model.layers.11.self_attn.time_mixer.x_g": "model-00003-of-00007.safetensors",
|
120 |
+
"model.layers.11.self_attn.time_mixer.x_k": "model-00003-of-00007.safetensors",
|
121 |
+
"model.layers.11.self_attn.time_mixer.x_r": "model-00003-of-00007.safetensors",
|
122 |
+
"model.layers.11.self_attn.time_mixer.x_v": "model-00003-of-00007.safetensors",
|
123 |
+
"model.layers.11.self_attn.time_mixer.x_w": "model-00003-of-00007.safetensors",
|
124 |
+
"model.layers.12.input_layernorm.weight": "model-00004-of-00007.safetensors",
|
125 |
+
"model.layers.12.mlp.down_proj.weight": "model-00004-of-00007.safetensors",
|
126 |
+
"model.layers.12.mlp.gate_proj.weight": "model-00004-of-00007.safetensors",
|
127 |
+
"model.layers.12.mlp.up_proj.weight": "model-00004-of-00007.safetensors",
|
128 |
+
"model.layers.12.post_attention_layernorm.weight": "model-00004-of-00007.safetensors",
|
129 |
+
"model.layers.12.self_attn.time_mixer.a0": "model-00003-of-00007.safetensors",
|
130 |
+
"model.layers.12.self_attn.time_mixer.a1": "model-00003-of-00007.safetensors",
|
131 |
+
"model.layers.12.self_attn.time_mixer.a2": "model-00003-of-00007.safetensors",
|
132 |
+
"model.layers.12.self_attn.time_mixer.g1": "model-00003-of-00007.safetensors",
|
133 |
+
"model.layers.12.self_attn.time_mixer.g2": "model-00003-of-00007.safetensors",
|
134 |
+
"model.layers.12.self_attn.time_mixer.k_a": "model-00003-of-00007.safetensors",
|
135 |
+
"model.layers.12.self_attn.time_mixer.k_k": "model-00003-of-00007.safetensors",
|
136 |
+
"model.layers.12.self_attn.time_mixer.key.weight": "model-00003-of-00007.safetensors",
|
137 |
+
"model.layers.12.self_attn.time_mixer.output.weight": "model-00003-of-00007.safetensors",
|
138 |
+
"model.layers.12.self_attn.time_mixer.r_k": "model-00003-of-00007.safetensors",
|
139 |
+
"model.layers.12.self_attn.time_mixer.receptance.weight": "model-00003-of-00007.safetensors",
|
140 |
+
"model.layers.12.self_attn.time_mixer.v0": "model-00003-of-00007.safetensors",
|
141 |
+
"model.layers.12.self_attn.time_mixer.v1": "model-00003-of-00007.safetensors",
|
142 |
+
"model.layers.12.self_attn.time_mixer.v2": "model-00003-of-00007.safetensors",
|
143 |
+
"model.layers.12.self_attn.time_mixer.value.weight": "model-00003-of-00007.safetensors",
|
144 |
+
"model.layers.12.self_attn.time_mixer.w0": "model-00003-of-00007.safetensors",
|
145 |
+
"model.layers.12.self_attn.time_mixer.w1": "model-00003-of-00007.safetensors",
|
146 |
+
"model.layers.12.self_attn.time_mixer.w2": "model-00003-of-00007.safetensors",
|
147 |
+
"model.layers.12.self_attn.time_mixer.x_a": "model-00003-of-00007.safetensors",
|
148 |
+
"model.layers.12.self_attn.time_mixer.x_g": "model-00003-of-00007.safetensors",
|
149 |
+
"model.layers.12.self_attn.time_mixer.x_k": "model-00003-of-00007.safetensors",
|
150 |
+
"model.layers.12.self_attn.time_mixer.x_r": "model-00003-of-00007.safetensors",
|
151 |
+
"model.layers.12.self_attn.time_mixer.x_v": "model-00003-of-00007.safetensors",
|
152 |
+
"model.layers.12.self_attn.time_mixer.x_w": "model-00003-of-00007.safetensors",
|
153 |
+
"model.layers.13.input_layernorm.weight": "model-00004-of-00007.safetensors",
|
154 |
+
"model.layers.13.mlp.down_proj.weight": "model-00004-of-00007.safetensors",
|
155 |
+
"model.layers.13.mlp.gate_proj.weight": "model-00004-of-00007.safetensors",
|
156 |
+
"model.layers.13.mlp.up_proj.weight": "model-00004-of-00007.safetensors",
|
157 |
+
"model.layers.13.post_attention_layernorm.weight": "model-00004-of-00007.safetensors",
|
158 |
+
"model.layers.13.self_attn.time_mixer.a0": "model-00004-of-00007.safetensors",
|
159 |
+
"model.layers.13.self_attn.time_mixer.a1": "model-00004-of-00007.safetensors",
|
160 |
+
"model.layers.13.self_attn.time_mixer.a2": "model-00004-of-00007.safetensors",
|
161 |
+
"model.layers.13.self_attn.time_mixer.g1": "model-00004-of-00007.safetensors",
|
162 |
+
"model.layers.13.self_attn.time_mixer.g2": "model-00004-of-00007.safetensors",
|
163 |
+
"model.layers.13.self_attn.time_mixer.k_a": "model-00004-of-00007.safetensors",
|
164 |
+
"model.layers.13.self_attn.time_mixer.k_k": "model-00004-of-00007.safetensors",
|
165 |
+
"model.layers.13.self_attn.time_mixer.key.weight": "model-00004-of-00007.safetensors",
|
166 |
+
"model.layers.13.self_attn.time_mixer.output.weight": "model-00004-of-00007.safetensors",
|
167 |
+
"model.layers.13.self_attn.time_mixer.r_k": "model-00004-of-00007.safetensors",
|
168 |
+
"model.layers.13.self_attn.time_mixer.receptance.weight": "model-00004-of-00007.safetensors",
|
169 |
+
"model.layers.13.self_attn.time_mixer.v0": "model-00004-of-00007.safetensors",
|
170 |
+
"model.layers.13.self_attn.time_mixer.v1": "model-00004-of-00007.safetensors",
|
171 |
+
"model.layers.13.self_attn.time_mixer.v2": "model-00004-of-00007.safetensors",
|
172 |
+
"model.layers.13.self_attn.time_mixer.value.weight": "model-00004-of-00007.safetensors",
|
173 |
+
"model.layers.13.self_attn.time_mixer.w0": "model-00004-of-00007.safetensors",
|
174 |
+
"model.layers.13.self_attn.time_mixer.w1": "model-00004-of-00007.safetensors",
|
175 |
+
"model.layers.13.self_attn.time_mixer.w2": "model-00004-of-00007.safetensors",
|
176 |
+
"model.layers.13.self_attn.time_mixer.x_a": "model-00004-of-00007.safetensors",
|
177 |
+
"model.layers.13.self_attn.time_mixer.x_g": "model-00004-of-00007.safetensors",
|
178 |
+
"model.layers.13.self_attn.time_mixer.x_k": "model-00004-of-00007.safetensors",
|
179 |
+
"model.layers.13.self_attn.time_mixer.x_r": "model-00004-of-00007.safetensors",
|
180 |
+
"model.layers.13.self_attn.time_mixer.x_v": "model-00004-of-00007.safetensors",
|
181 |
+
"model.layers.13.self_attn.time_mixer.x_w": "model-00004-of-00007.safetensors",
|
182 |
+
"model.layers.14.input_layernorm.weight": "model-00004-of-00007.safetensors",
|
183 |
+
"model.layers.14.mlp.down_proj.weight": "model-00004-of-00007.safetensors",
|
184 |
+
"model.layers.14.mlp.gate_proj.weight": "model-00004-of-00007.safetensors",
|
185 |
+
"model.layers.14.mlp.up_proj.weight": "model-00004-of-00007.safetensors",
|
186 |
+
"model.layers.14.post_attention_layernorm.weight": "model-00004-of-00007.safetensors",
|
187 |
+
"model.layers.14.self_attn.time_mixer.a0": "model-00004-of-00007.safetensors",
|
188 |
+
"model.layers.14.self_attn.time_mixer.a1": "model-00004-of-00007.safetensors",
|
189 |
+
"model.layers.14.self_attn.time_mixer.a2": "model-00004-of-00007.safetensors",
|
190 |
+
"model.layers.14.self_attn.time_mixer.g1": "model-00004-of-00007.safetensors",
|
191 |
+
"model.layers.14.self_attn.time_mixer.g2": "model-00004-of-00007.safetensors",
|
192 |
+
"model.layers.14.self_attn.time_mixer.k_a": "model-00004-of-00007.safetensors",
|
193 |
+
"model.layers.14.self_attn.time_mixer.k_k": "model-00004-of-00007.safetensors",
|
194 |
+
"model.layers.14.self_attn.time_mixer.key.weight": "model-00004-of-00007.safetensors",
|
195 |
+
"model.layers.14.self_attn.time_mixer.output.weight": "model-00004-of-00007.safetensors",
|
196 |
+
"model.layers.14.self_attn.time_mixer.r_k": "model-00004-of-00007.safetensors",
|
197 |
+
"model.layers.14.self_attn.time_mixer.receptance.weight": "model-00004-of-00007.safetensors",
|
198 |
+
"model.layers.14.self_attn.time_mixer.v0": "model-00004-of-00007.safetensors",
|
199 |
+
"model.layers.14.self_attn.time_mixer.v1": "model-00004-of-00007.safetensors",
|
200 |
+
"model.layers.14.self_attn.time_mixer.v2": "model-00004-of-00007.safetensors",
|
201 |
+
"model.layers.14.self_attn.time_mixer.value.weight": "model-00004-of-00007.safetensors",
|
202 |
+
"model.layers.14.self_attn.time_mixer.w0": "model-00004-of-00007.safetensors",
|
203 |
+
"model.layers.14.self_attn.time_mixer.w1": "model-00004-of-00007.safetensors",
|
204 |
+
"model.layers.14.self_attn.time_mixer.w2": "model-00004-of-00007.safetensors",
|
205 |
+
"model.layers.14.self_attn.time_mixer.x_a": "model-00004-of-00007.safetensors",
|
206 |
+
"model.layers.14.self_attn.time_mixer.x_g": "model-00004-of-00007.safetensors",
|
207 |
+
"model.layers.14.self_attn.time_mixer.x_k": "model-00004-of-00007.safetensors",
|
208 |
+
"model.layers.14.self_attn.time_mixer.x_r": "model-00004-of-00007.safetensors",
|
209 |
+
"model.layers.14.self_attn.time_mixer.x_v": "model-00004-of-00007.safetensors",
|
210 |
+
"model.layers.14.self_attn.time_mixer.x_w": "model-00004-of-00007.safetensors",
|
211 |
+
"model.layers.15.input_layernorm.weight": "model-00004-of-00007.safetensors",
|
212 |
+
"model.layers.15.mlp.down_proj.weight": "model-00004-of-00007.safetensors",
|
213 |
+
"model.layers.15.mlp.gate_proj.weight": "model-00004-of-00007.safetensors",
|
214 |
+
"model.layers.15.mlp.up_proj.weight": "model-00004-of-00007.safetensors",
|
215 |
+
"model.layers.15.post_attention_layernorm.weight": "model-00004-of-00007.safetensors",
|
216 |
+
"model.layers.15.self_attn.time_mixer.a0": "model-00004-of-00007.safetensors",
|
217 |
+
"model.layers.15.self_attn.time_mixer.a1": "model-00004-of-00007.safetensors",
|
218 |
+
"model.layers.15.self_attn.time_mixer.a2": "model-00004-of-00007.safetensors",
|
219 |
+
"model.layers.15.self_attn.time_mixer.g1": "model-00004-of-00007.safetensors",
|
220 |
+
"model.layers.15.self_attn.time_mixer.g2": "model-00004-of-00007.safetensors",
|
221 |
+
"model.layers.15.self_attn.time_mixer.k_a": "model-00004-of-00007.safetensors",
|
222 |
+
"model.layers.15.self_attn.time_mixer.k_k": "model-00004-of-00007.safetensors",
|
223 |
+
"model.layers.15.self_attn.time_mixer.key.weight": "model-00004-of-00007.safetensors",
|
224 |
+
"model.layers.15.self_attn.time_mixer.output.weight": "model-00004-of-00007.safetensors",
|
225 |
+
"model.layers.15.self_attn.time_mixer.r_k": "model-00004-of-00007.safetensors",
|
226 |
+
"model.layers.15.self_attn.time_mixer.receptance.weight": "model-00004-of-00007.safetensors",
|
227 |
+
"model.layers.15.self_attn.time_mixer.v0": "model-00004-of-00007.safetensors",
|
228 |
+
"model.layers.15.self_attn.time_mixer.v1": "model-00004-of-00007.safetensors",
|
229 |
+
"model.layers.15.self_attn.time_mixer.v2": "model-00004-of-00007.safetensors",
|
230 |
+
"model.layers.15.self_attn.time_mixer.value.weight": "model-00004-of-00007.safetensors",
|
231 |
+
"model.layers.15.self_attn.time_mixer.w0": "model-00004-of-00007.safetensors",
|
232 |
+
"model.layers.15.self_attn.time_mixer.w1": "model-00004-of-00007.safetensors",
|
233 |
+
"model.layers.15.self_attn.time_mixer.w2": "model-00004-of-00007.safetensors",
|
234 |
+
"model.layers.15.self_attn.time_mixer.x_a": "model-00004-of-00007.safetensors",
|
235 |
+
"model.layers.15.self_attn.time_mixer.x_g": "model-00004-of-00007.safetensors",
|
236 |
+
"model.layers.15.self_attn.time_mixer.x_k": "model-00004-of-00007.safetensors",
|
237 |
+
"model.layers.15.self_attn.time_mixer.x_r": "model-00004-of-00007.safetensors",
|
238 |
+
"model.layers.15.self_attn.time_mixer.x_v": "model-00004-of-00007.safetensors",
|
239 |
+
"model.layers.15.self_attn.time_mixer.x_w": "model-00004-of-00007.safetensors",
|
240 |
+
"model.layers.16.input_layernorm.weight": "model-00004-of-00007.safetensors",
|
241 |
+
"model.layers.16.mlp.down_proj.weight": "model-00004-of-00007.safetensors",
|
242 |
+
"model.layers.16.mlp.gate_proj.weight": "model-00004-of-00007.safetensors",
|
243 |
+
"model.layers.16.mlp.up_proj.weight": "model-00004-of-00007.safetensors",
|
244 |
+
"model.layers.16.post_attention_layernorm.weight": "model-00004-of-00007.safetensors",
|
245 |
+
"model.layers.16.self_attn.time_mixer.a0": "model-00004-of-00007.safetensors",
|
246 |
+
"model.layers.16.self_attn.time_mixer.a1": "model-00004-of-00007.safetensors",
|
247 |
+
"model.layers.16.self_attn.time_mixer.a2": "model-00004-of-00007.safetensors",
|
248 |
+
"model.layers.16.self_attn.time_mixer.g1": "model-00004-of-00007.safetensors",
|
249 |
+
"model.layers.16.self_attn.time_mixer.g2": "model-00004-of-00007.safetensors",
|
250 |
+
"model.layers.16.self_attn.time_mixer.k_a": "model-00004-of-00007.safetensors",
|
251 |
+
"model.layers.16.self_attn.time_mixer.k_k": "model-00004-of-00007.safetensors",
|
252 |
+
"model.layers.16.self_attn.time_mixer.key.weight": "model-00004-of-00007.safetensors",
|
253 |
+
"model.layers.16.self_attn.time_mixer.output.weight": "model-00004-of-00007.safetensors",
|
254 |
+
"model.layers.16.self_attn.time_mixer.r_k": "model-00004-of-00007.safetensors",
|
255 |
+
"model.layers.16.self_attn.time_mixer.receptance.weight": "model-00004-of-00007.safetensors",
|
256 |
+
"model.layers.16.self_attn.time_mixer.v0": "model-00004-of-00007.safetensors",
|
257 |
+
"model.layers.16.self_attn.time_mixer.v1": "model-00004-of-00007.safetensors",
|
258 |
+
"model.layers.16.self_attn.time_mixer.v2": "model-00004-of-00007.safetensors",
|
259 |
+
"model.layers.16.self_attn.time_mixer.value.weight": "model-00004-of-00007.safetensors",
|
260 |
+
"model.layers.16.self_attn.time_mixer.w0": "model-00004-of-00007.safetensors",
|
261 |
+
"model.layers.16.self_attn.time_mixer.w1": "model-00004-of-00007.safetensors",
|
262 |
+
"model.layers.16.self_attn.time_mixer.w2": "model-00004-of-00007.safetensors",
|
263 |
+
"model.layers.16.self_attn.time_mixer.x_a": "model-00004-of-00007.safetensors",
|
264 |
+
"model.layers.16.self_attn.time_mixer.x_g": "model-00004-of-00007.safetensors",
|
265 |
+
"model.layers.16.self_attn.time_mixer.x_k": "model-00004-of-00007.safetensors",
|
266 |
+
"model.layers.16.self_attn.time_mixer.x_r": "model-00004-of-00007.safetensors",
|
267 |
+
"model.layers.16.self_attn.time_mixer.x_v": "model-00004-of-00007.safetensors",
|
268 |
+
"model.layers.16.self_attn.time_mixer.x_w": "model-00004-of-00007.safetensors",
|
269 |
+
"model.layers.17.input_layernorm.weight": "model-00005-of-00007.safetensors",
|
270 |
+
"model.layers.17.mlp.down_proj.weight": "model-00005-of-00007.safetensors",
|
271 |
+
"model.layers.17.mlp.gate_proj.weight": "model-00005-of-00007.safetensors",
|
272 |
+
"model.layers.17.mlp.up_proj.weight": "model-00005-of-00007.safetensors",
|
273 |
+
"model.layers.17.post_attention_layernorm.weight": "model-00005-of-00007.safetensors",
|
274 |
+
"model.layers.17.self_attn.time_mixer.a0": "model-00004-of-00007.safetensors",
|
275 |
+
"model.layers.17.self_attn.time_mixer.a1": "model-00004-of-00007.safetensors",
|
276 |
+
"model.layers.17.self_attn.time_mixer.a2": "model-00004-of-00007.safetensors",
|
277 |
+
"model.layers.17.self_attn.time_mixer.g1": "model-00004-of-00007.safetensors",
|
278 |
+
"model.layers.17.self_attn.time_mixer.g2": "model-00004-of-00007.safetensors",
|
279 |
+
"model.layers.17.self_attn.time_mixer.k_a": "model-00004-of-00007.safetensors",
|
280 |
+
"model.layers.17.self_attn.time_mixer.k_k": "model-00004-of-00007.safetensors",
|
281 |
+
"model.layers.17.self_attn.time_mixer.key.weight": "model-00005-of-00007.safetensors",
|
282 |
+
"model.layers.17.self_attn.time_mixer.output.weight": "model-00005-of-00007.safetensors",
|
283 |
+
"model.layers.17.self_attn.time_mixer.r_k": "model-00004-of-00007.safetensors",
|
284 |
+
"model.layers.17.self_attn.time_mixer.receptance.weight": "model-00004-of-00007.safetensors",
|
285 |
+
"model.layers.17.self_attn.time_mixer.v0": "model-00004-of-00007.safetensors",
|
286 |
+
"model.layers.17.self_attn.time_mixer.v1": "model-00004-of-00007.safetensors",
|
287 |
+
"model.layers.17.self_attn.time_mixer.v2": "model-00004-of-00007.safetensors",
|
288 |
+
"model.layers.17.self_attn.time_mixer.value.weight": "model-00005-of-00007.safetensors",
|
289 |
+
"model.layers.17.self_attn.time_mixer.w0": "model-00004-of-00007.safetensors",
|
290 |
+
"model.layers.17.self_attn.time_mixer.w1": "model-00004-of-00007.safetensors",
|
291 |
+
"model.layers.17.self_attn.time_mixer.w2": "model-00004-of-00007.safetensors",
|
292 |
+
"model.layers.17.self_attn.time_mixer.x_a": "model-00004-of-00007.safetensors",
|
293 |
+
"model.layers.17.self_attn.time_mixer.x_g": "model-00004-of-00007.safetensors",
|
294 |
+
"model.layers.17.self_attn.time_mixer.x_k": "model-00004-of-00007.safetensors",
|
295 |
+
"model.layers.17.self_attn.time_mixer.x_r": "model-00004-of-00007.safetensors",
|
296 |
+
"model.layers.17.self_attn.time_mixer.x_v": "model-00004-of-00007.safetensors",
|
297 |
+
"model.layers.17.self_attn.time_mixer.x_w": "model-00004-of-00007.safetensors",
|
298 |
+
"model.layers.18.input_layernorm.weight": "model-00005-of-00007.safetensors",
|
299 |
+
"model.layers.18.mlp.down_proj.weight": "model-00005-of-00007.safetensors",
|
300 |
+
"model.layers.18.mlp.gate_proj.weight": "model-00005-of-00007.safetensors",
|
301 |
+
"model.layers.18.mlp.up_proj.weight": "model-00005-of-00007.safetensors",
|
302 |
+
"model.layers.18.post_attention_layernorm.weight": "model-00005-of-00007.safetensors",
|
303 |
+
"model.layers.18.self_attn.time_mixer.a0": "model-00005-of-00007.safetensors",
|
304 |
+
"model.layers.18.self_attn.time_mixer.a1": "model-00005-of-00007.safetensors",
|
305 |
+
"model.layers.18.self_attn.time_mixer.a2": "model-00005-of-00007.safetensors",
|
306 |
+
"model.layers.18.self_attn.time_mixer.g1": "model-00005-of-00007.safetensors",
|
307 |
+
"model.layers.18.self_attn.time_mixer.g2": "model-00005-of-00007.safetensors",
|
308 |
+
"model.layers.18.self_attn.time_mixer.k_a": "model-00005-of-00007.safetensors",
|
309 |
+
"model.layers.18.self_attn.time_mixer.k_k": "model-00005-of-00007.safetensors",
|
310 |
+
"model.layers.18.self_attn.time_mixer.key.weight": "model-00005-of-00007.safetensors",
|
311 |
+
"model.layers.18.self_attn.time_mixer.output.weight": "model-00005-of-00007.safetensors",
|
312 |
+
"model.layers.18.self_attn.time_mixer.r_k": "model-00005-of-00007.safetensors",
|
313 |
+
"model.layers.18.self_attn.time_mixer.receptance.weight": "model-00005-of-00007.safetensors",
|
314 |
+
"model.layers.18.self_attn.time_mixer.v0": "model-00005-of-00007.safetensors",
|
315 |
+
"model.layers.18.self_attn.time_mixer.v1": "model-00005-of-00007.safetensors",
|
316 |
+
"model.layers.18.self_attn.time_mixer.v2": "model-00005-of-00007.safetensors",
|
317 |
+
"model.layers.18.self_attn.time_mixer.value.weight": "model-00005-of-00007.safetensors",
|
318 |
+
"model.layers.18.self_attn.time_mixer.w0": "model-00005-of-00007.safetensors",
|
319 |
+
"model.layers.18.self_attn.time_mixer.w1": "model-00005-of-00007.safetensors",
|
320 |
+
"model.layers.18.self_attn.time_mixer.w2": "model-00005-of-00007.safetensors",
|
321 |
+
"model.layers.18.self_attn.time_mixer.x_a": "model-00005-of-00007.safetensors",
|
322 |
+
"model.layers.18.self_attn.time_mixer.x_g": "model-00005-of-00007.safetensors",
|
323 |
+
"model.layers.18.self_attn.time_mixer.x_k": "model-00005-of-00007.safetensors",
|
324 |
+
"model.layers.18.self_attn.time_mixer.x_r": "model-00005-of-00007.safetensors",
|
325 |
+
"model.layers.18.self_attn.time_mixer.x_v": "model-00005-of-00007.safetensors",
|
326 |
+
"model.layers.18.self_attn.time_mixer.x_w": "model-00005-of-00007.safetensors",
|
327 |
+
"model.layers.19.input_layernorm.weight": "model-00005-of-00007.safetensors",
|
328 |
+
"model.layers.19.mlp.down_proj.weight": "model-00005-of-00007.safetensors",
|
329 |
+
"model.layers.19.mlp.gate_proj.weight": "model-00005-of-00007.safetensors",
|
330 |
+
"model.layers.19.mlp.up_proj.weight": "model-00005-of-00007.safetensors",
|
331 |
+
"model.layers.19.post_attention_layernorm.weight": "model-00005-of-00007.safetensors",
|
332 |
+
"model.layers.19.self_attn.time_mixer.a0": "model-00005-of-00007.safetensors",
|
333 |
+
"model.layers.19.self_attn.time_mixer.a1": "model-00005-of-00007.safetensors",
|
334 |
+
"model.layers.19.self_attn.time_mixer.a2": "model-00005-of-00007.safetensors",
|
335 |
+
"model.layers.19.self_attn.time_mixer.g1": "model-00005-of-00007.safetensors",
|
336 |
+
"model.layers.19.self_attn.time_mixer.g2": "model-00005-of-00007.safetensors",
|
337 |
+
"model.layers.19.self_attn.time_mixer.k_a": "model-00005-of-00007.safetensors",
|
338 |
+
"model.layers.19.self_attn.time_mixer.k_k": "model-00005-of-00007.safetensors",
|
339 |
+
"model.layers.19.self_attn.time_mixer.key.weight": "model-00005-of-00007.safetensors",
|
340 |
+
"model.layers.19.self_attn.time_mixer.output.weight": "model-00005-of-00007.safetensors",
|
341 |
+
"model.layers.19.self_attn.time_mixer.r_k": "model-00005-of-00007.safetensors",
|
342 |
+
"model.layers.19.self_attn.time_mixer.receptance.weight": "model-00005-of-00007.safetensors",
|
343 |
+
"model.layers.19.self_attn.time_mixer.v0": "model-00005-of-00007.safetensors",
|
344 |
+
"model.layers.19.self_attn.time_mixer.v1": "model-00005-of-00007.safetensors",
|
345 |
+
"model.layers.19.self_attn.time_mixer.v2": "model-00005-of-00007.safetensors",
|
346 |
+
"model.layers.19.self_attn.time_mixer.value.weight": "model-00005-of-00007.safetensors",
|
347 |
+
"model.layers.19.self_attn.time_mixer.w0": "model-00005-of-00007.safetensors",
|
348 |
+
"model.layers.19.self_attn.time_mixer.w1": "model-00005-of-00007.safetensors",
|
349 |
+
"model.layers.19.self_attn.time_mixer.w2": "model-00005-of-00007.safetensors",
|
350 |
+
"model.layers.19.self_attn.time_mixer.x_a": "model-00005-of-00007.safetensors",
|
351 |
+
"model.layers.19.self_attn.time_mixer.x_g": "model-00005-of-00007.safetensors",
|
352 |
+
"model.layers.19.self_attn.time_mixer.x_k": "model-00005-of-00007.safetensors",
|
353 |
+
"model.layers.19.self_attn.time_mixer.x_r": "model-00005-of-00007.safetensors",
|
354 |
+
"model.layers.19.self_attn.time_mixer.x_v": "model-00005-of-00007.safetensors",
|
355 |
+
"model.layers.19.self_attn.time_mixer.x_w": "model-00005-of-00007.safetensors",
|
356 |
+
"model.layers.2.input_layernorm.weight": "model-00002-of-00007.safetensors",
|
357 |
+
"model.layers.2.mlp.down_proj.weight": "model-00002-of-00007.safetensors",
|
358 |
+
"model.layers.2.mlp.gate_proj.weight": "model-00001-of-00007.safetensors",
|
359 |
+
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00007.safetensors",
|
360 |
+
"model.layers.2.post_attention_layernorm.weight": "model-00002-of-00007.safetensors",
|
361 |
+
"model.layers.2.self_attn.time_mixer.a0": "model-00001-of-00007.safetensors",
|
362 |
+
"model.layers.2.self_attn.time_mixer.a1": "model-00001-of-00007.safetensors",
|
363 |
+
"model.layers.2.self_attn.time_mixer.a2": "model-00001-of-00007.safetensors",
|
364 |
+
"model.layers.2.self_attn.time_mixer.g1": "model-00001-of-00007.safetensors",
|
365 |
+
"model.layers.2.self_attn.time_mixer.g2": "model-00001-of-00007.safetensors",
|
366 |
+
"model.layers.2.self_attn.time_mixer.k_a": "model-00001-of-00007.safetensors",
|
367 |
+
"model.layers.2.self_attn.time_mixer.k_k": "model-00001-of-00007.safetensors",
|
368 |
+
"model.layers.2.self_attn.time_mixer.key.weight": "model-00001-of-00007.safetensors",
|
369 |
+
"model.layers.2.self_attn.time_mixer.output.weight": "model-00001-of-00007.safetensors",
|
370 |
+
"model.layers.2.self_attn.time_mixer.r_k": "model-00001-of-00007.safetensors",
|
371 |
+
"model.layers.2.self_attn.time_mixer.receptance.weight": "model-00001-of-00007.safetensors",
|
372 |
+
"model.layers.2.self_attn.time_mixer.v0": "model-00001-of-00007.safetensors",
|
373 |
+
"model.layers.2.self_attn.time_mixer.v1": "model-00001-of-00007.safetensors",
|
374 |
+
"model.layers.2.self_attn.time_mixer.v2": "model-00001-of-00007.safetensors",
|
375 |
+
"model.layers.2.self_attn.time_mixer.value.weight": "model-00001-of-00007.safetensors",
|
376 |
+
"model.layers.2.self_attn.time_mixer.w0": "model-00001-of-00007.safetensors",
|
377 |
+
"model.layers.2.self_attn.time_mixer.w1": "model-00001-of-00007.safetensors",
|
378 |
+
"model.layers.2.self_attn.time_mixer.w2": "model-00001-of-00007.safetensors",
|
379 |
+
"model.layers.2.self_attn.time_mixer.x_a": "model-00001-of-00007.safetensors",
|
380 |
+
"model.layers.2.self_attn.time_mixer.x_g": "model-00001-of-00007.safetensors",
|
381 |
+
"model.layers.2.self_attn.time_mixer.x_k": "model-00001-of-00007.safetensors",
|
382 |
+
"model.layers.2.self_attn.time_mixer.x_r": "model-00001-of-00007.safetensors",
|
383 |
+
"model.layers.2.self_attn.time_mixer.x_v": "model-00001-of-00007.safetensors",
|
384 |
+
"model.layers.2.self_attn.time_mixer.x_w": "model-00001-of-00007.safetensors",
|
385 |
+
"model.layers.20.input_layernorm.weight": "model-00005-of-00007.safetensors",
|
386 |
+
"model.layers.20.mlp.down_proj.weight": "model-00005-of-00007.safetensors",
|
387 |
+
"model.layers.20.mlp.gate_proj.weight": "model-00005-of-00007.safetensors",
|
388 |
+
"model.layers.20.mlp.up_proj.weight": "model-00005-of-00007.safetensors",
|
389 |
+
"model.layers.20.post_attention_layernorm.weight": "model-00005-of-00007.safetensors",
|
390 |
+
"model.layers.20.self_attn.time_mixer.a0": "model-00005-of-00007.safetensors",
|
391 |
+
"model.layers.20.self_attn.time_mixer.a1": "model-00005-of-00007.safetensors",
|
392 |
+
"model.layers.20.self_attn.time_mixer.a2": "model-00005-of-00007.safetensors",
|
393 |
+
"model.layers.20.self_attn.time_mixer.g1": "model-00005-of-00007.safetensors",
|
394 |
+
"model.layers.20.self_attn.time_mixer.g2": "model-00005-of-00007.safetensors",
|
395 |
+
"model.layers.20.self_attn.time_mixer.k_a": "model-00005-of-00007.safetensors",
|
396 |
+
"model.layers.20.self_attn.time_mixer.k_k": "model-00005-of-00007.safetensors",
|
397 |
+
"model.layers.20.self_attn.time_mixer.key.weight": "model-00005-of-00007.safetensors",
|
398 |
+
"model.layers.20.self_attn.time_mixer.output.weight": "model-00005-of-00007.safetensors",
|
399 |
+
"model.layers.20.self_attn.time_mixer.r_k": "model-00005-of-00007.safetensors",
|
400 |
+
"model.layers.20.self_attn.time_mixer.receptance.weight": "model-00005-of-00007.safetensors",
|
401 |
+
"model.layers.20.self_attn.time_mixer.v0": "model-00005-of-00007.safetensors",
|
402 |
+
"model.layers.20.self_attn.time_mixer.v1": "model-00005-of-00007.safetensors",
|
403 |
+
"model.layers.20.self_attn.time_mixer.v2": "model-00005-of-00007.safetensors",
|
404 |
+
"model.layers.20.self_attn.time_mixer.value.weight": "model-00005-of-00007.safetensors",
|
405 |
+
"model.layers.20.self_attn.time_mixer.w0": "model-00005-of-00007.safetensors",
|
406 |
+
"model.layers.20.self_attn.time_mixer.w1": "model-00005-of-00007.safetensors",
|
407 |
+
"model.layers.20.self_attn.time_mixer.w2": "model-00005-of-00007.safetensors",
|
408 |
+
"model.layers.20.self_attn.time_mixer.x_a": "model-00005-of-00007.safetensors",
|
409 |
+
"model.layers.20.self_attn.time_mixer.x_g": "model-00005-of-00007.safetensors",
|
410 |
+
"model.layers.20.self_attn.time_mixer.x_k": "model-00005-of-00007.safetensors",
|
411 |
+
"model.layers.20.self_attn.time_mixer.x_r": "model-00005-of-00007.safetensors",
|
412 |
+
"model.layers.20.self_attn.time_mixer.x_v": "model-00005-of-00007.safetensors",
|
413 |
+
"model.layers.20.self_attn.time_mixer.x_w": "model-00005-of-00007.safetensors",
|
414 |
+
"model.layers.21.input_layernorm.weight": "model-00006-of-00007.safetensors",
|
415 |
+
"model.layers.21.mlp.down_proj.weight": "model-00006-of-00007.safetensors",
|
416 |
+
"model.layers.21.mlp.gate_proj.weight": "model-00005-of-00007.safetensors",
|
417 |
+
"model.layers.21.mlp.up_proj.weight": "model-00005-of-00007.safetensors",
|
418 |
+
"model.layers.21.post_attention_layernorm.weight": "model-00006-of-00007.safetensors",
|
419 |
+
"model.layers.21.self_attn.time_mixer.a0": "model-00005-of-00007.safetensors",
|
420 |
+
"model.layers.21.self_attn.time_mixer.a1": "model-00005-of-00007.safetensors",
|
421 |
+
"model.layers.21.self_attn.time_mixer.a2": "model-00005-of-00007.safetensors",
|
422 |
+
"model.layers.21.self_attn.time_mixer.g1": "model-00005-of-00007.safetensors",
|
423 |
+
"model.layers.21.self_attn.time_mixer.g2": "model-00005-of-00007.safetensors",
|
424 |
+
"model.layers.21.self_attn.time_mixer.k_a": "model-00005-of-00007.safetensors",
|
425 |
+
"model.layers.21.self_attn.time_mixer.k_k": "model-00005-of-00007.safetensors",
|
426 |
+
"model.layers.21.self_attn.time_mixer.key.weight": "model-00005-of-00007.safetensors",
|
427 |
+
"model.layers.21.self_attn.time_mixer.output.weight": "model-00005-of-00007.safetensors",
|
428 |
+
"model.layers.21.self_attn.time_mixer.r_k": "model-00005-of-00007.safetensors",
|
429 |
+
"model.layers.21.self_attn.time_mixer.receptance.weight": "model-00005-of-00007.safetensors",
|
430 |
+
"model.layers.21.self_attn.time_mixer.v0": "model-00005-of-00007.safetensors",
|
431 |
+
"model.layers.21.self_attn.time_mixer.v1": "model-00005-of-00007.safetensors",
|
432 |
+
"model.layers.21.self_attn.time_mixer.v2": "model-00005-of-00007.safetensors",
|
433 |
+
"model.layers.21.self_attn.time_mixer.value.weight": "model-00005-of-00007.safetensors",
|
434 |
+
"model.layers.21.self_attn.time_mixer.w0": "model-00005-of-00007.safetensors",
|
435 |
+
"model.layers.21.self_attn.time_mixer.w1": "model-00005-of-00007.safetensors",
|
436 |
+
"model.layers.21.self_attn.time_mixer.w2": "model-00005-of-00007.safetensors",
|
437 |
+
"model.layers.21.self_attn.time_mixer.x_a": "model-00005-of-00007.safetensors",
|
438 |
+
"model.layers.21.self_attn.time_mixer.x_g": "model-00005-of-00007.safetensors",
|
439 |
+
"model.layers.21.self_attn.time_mixer.x_k": "model-00005-of-00007.safetensors",
|
440 |
+
"model.layers.21.self_attn.time_mixer.x_r": "model-00005-of-00007.safetensors",
|
441 |
+
"model.layers.21.self_attn.time_mixer.x_v": "model-00005-of-00007.safetensors",
|
442 |
+
"model.layers.21.self_attn.time_mixer.x_w": "model-00005-of-00007.safetensors",
|
443 |
+
"model.layers.22.input_layernorm.weight": "model-00006-of-00007.safetensors",
|
444 |
+
"model.layers.22.mlp.down_proj.weight": "model-00006-of-00007.safetensors",
|
445 |
+
"model.layers.22.mlp.gate_proj.weight": "model-00006-of-00007.safetensors",
|
446 |
+
"model.layers.22.mlp.up_proj.weight": "model-00006-of-00007.safetensors",
|
447 |
+
"model.layers.22.post_attention_layernorm.weight": "model-00006-of-00007.safetensors",
|
448 |
+
"model.layers.22.self_attn.time_mixer.a0": "model-00006-of-00007.safetensors",
|
449 |
+
"model.layers.22.self_attn.time_mixer.a1": "model-00006-of-00007.safetensors",
|
450 |
+
"model.layers.22.self_attn.time_mixer.a2": "model-00006-of-00007.safetensors",
|
451 |
+
"model.layers.22.self_attn.time_mixer.g1": "model-00006-of-00007.safetensors",
|
452 |
+
"model.layers.22.self_attn.time_mixer.g2": "model-00006-of-00007.safetensors",
|
453 |
+
"model.layers.22.self_attn.time_mixer.k_a": "model-00006-of-00007.safetensors",
|
454 |
+
"model.layers.22.self_attn.time_mixer.k_k": "model-00006-of-00007.safetensors",
|
455 |
+
"model.layers.22.self_attn.time_mixer.key.weight": "model-00006-of-00007.safetensors",
|
456 |
+
"model.layers.22.self_attn.time_mixer.output.weight": "model-00006-of-00007.safetensors",
|
457 |
+
"model.layers.22.self_attn.time_mixer.r_k": "model-00006-of-00007.safetensors",
|
458 |
+
"model.layers.22.self_attn.time_mixer.receptance.weight": "model-00006-of-00007.safetensors",
|
459 |
+
"model.layers.22.self_attn.time_mixer.v0": "model-00006-of-00007.safetensors",
|
460 |
+
"model.layers.22.self_attn.time_mixer.v1": "model-00006-of-00007.safetensors",
|
461 |
+
"model.layers.22.self_attn.time_mixer.v2": "model-00006-of-00007.safetensors",
|
462 |
+
"model.layers.22.self_attn.time_mixer.value.weight": "model-00006-of-00007.safetensors",
|
463 |
+
"model.layers.22.self_attn.time_mixer.w0": "model-00006-of-00007.safetensors",
|
464 |
+
"model.layers.22.self_attn.time_mixer.w1": "model-00006-of-00007.safetensors",
|
465 |
+
"model.layers.22.self_attn.time_mixer.w2": "model-00006-of-00007.safetensors",
|
466 |
+
"model.layers.22.self_attn.time_mixer.x_a": "model-00006-of-00007.safetensors",
|
467 |
+
"model.layers.22.self_attn.time_mixer.x_g": "model-00006-of-00007.safetensors",
|
468 |
+
"model.layers.22.self_attn.time_mixer.x_k": "model-00006-of-00007.safetensors",
|
469 |
+
"model.layers.22.self_attn.time_mixer.x_r": "model-00006-of-00007.safetensors",
|
470 |
+
"model.layers.22.self_attn.time_mixer.x_v": "model-00006-of-00007.safetensors",
|
471 |
+
"model.layers.22.self_attn.time_mixer.x_w": "model-00006-of-00007.safetensors",
|
472 |
+
"model.layers.23.input_layernorm.weight": "model-00006-of-00007.safetensors",
|
473 |
+
"model.layers.23.mlp.down_proj.weight": "model-00006-of-00007.safetensors",
|
474 |
+
"model.layers.23.mlp.gate_proj.weight": "model-00006-of-00007.safetensors",
|
475 |
+
"model.layers.23.mlp.up_proj.weight": "model-00006-of-00007.safetensors",
|
476 |
+
"model.layers.23.post_attention_layernorm.weight": "model-00006-of-00007.safetensors",
|
477 |
+
"model.layers.23.self_attn.time_mixer.a0": "model-00006-of-00007.safetensors",
|
478 |
+
"model.layers.23.self_attn.time_mixer.a1": "model-00006-of-00007.safetensors",
|
479 |
+
"model.layers.23.self_attn.time_mixer.a2": "model-00006-of-00007.safetensors",
|
480 |
+
"model.layers.23.self_attn.time_mixer.g1": "model-00006-of-00007.safetensors",
|
481 |
+
"model.layers.23.self_attn.time_mixer.g2": "model-00006-of-00007.safetensors",
|
482 |
+
"model.layers.23.self_attn.time_mixer.k_a": "model-00006-of-00007.safetensors",
|
483 |
+
"model.layers.23.self_attn.time_mixer.k_k": "model-00006-of-00007.safetensors",
|
484 |
+
"model.layers.23.self_attn.time_mixer.key.weight": "model-00006-of-00007.safetensors",
|
485 |
+
"model.layers.23.self_attn.time_mixer.output.weight": "model-00006-of-00007.safetensors",
|
486 |
+
"model.layers.23.self_attn.time_mixer.r_k": "model-00006-of-00007.safetensors",
|
487 |
+
"model.layers.23.self_attn.time_mixer.receptance.weight": "model-00006-of-00007.safetensors",
|
488 |
+
"model.layers.23.self_attn.time_mixer.v0": "model-00006-of-00007.safetensors",
|
489 |
+
"model.layers.23.self_attn.time_mixer.v1": "model-00006-of-00007.safetensors",
|
490 |
+
"model.layers.23.self_attn.time_mixer.v2": "model-00006-of-00007.safetensors",
|
491 |
+
"model.layers.23.self_attn.time_mixer.value.weight": "model-00006-of-00007.safetensors",
|
492 |
+
"model.layers.23.self_attn.time_mixer.w0": "model-00006-of-00007.safetensors",
|
493 |
+
"model.layers.23.self_attn.time_mixer.w1": "model-00006-of-00007.safetensors",
|
494 |
+
"model.layers.23.self_attn.time_mixer.w2": "model-00006-of-00007.safetensors",
|
495 |
+
"model.layers.23.self_attn.time_mixer.x_a": "model-00006-of-00007.safetensors",
|
496 |
+
"model.layers.23.self_attn.time_mixer.x_g": "model-00006-of-00007.safetensors",
|
497 |
+
"model.layers.23.self_attn.time_mixer.x_k": "model-00006-of-00007.safetensors",
|
498 |
+
"model.layers.23.self_attn.time_mixer.x_r": "model-00006-of-00007.safetensors",
|
499 |
+
"model.layers.23.self_attn.time_mixer.x_v": "model-00006-of-00007.safetensors",
|
500 |
+
"model.layers.23.self_attn.time_mixer.x_w": "model-00006-of-00007.safetensors",
|
501 |
+
"model.layers.24.input_layernorm.weight": "model-00006-of-00007.safetensors",
|
502 |
+
"model.layers.24.mlp.down_proj.weight": "model-00006-of-00007.safetensors",
|
503 |
+
"model.layers.24.mlp.gate_proj.weight": "model-00006-of-00007.safetensors",
|
504 |
+
"model.layers.24.mlp.up_proj.weight": "model-00006-of-00007.safetensors",
|
505 |
+
"model.layers.24.post_attention_layernorm.weight": "model-00006-of-00007.safetensors",
|
506 |
+
"model.layers.24.self_attn.time_mixer.a0": "model-00006-of-00007.safetensors",
|
507 |
+
"model.layers.24.self_attn.time_mixer.a1": "model-00006-of-00007.safetensors",
|
508 |
+
"model.layers.24.self_attn.time_mixer.a2": "model-00006-of-00007.safetensors",
|
509 |
+
"model.layers.24.self_attn.time_mixer.g1": "model-00006-of-00007.safetensors",
|
510 |
+
"model.layers.24.self_attn.time_mixer.g2": "model-00006-of-00007.safetensors",
|
511 |
+
"model.layers.24.self_attn.time_mixer.k_a": "model-00006-of-00007.safetensors",
|
512 |
+
"model.layers.24.self_attn.time_mixer.k_k": "model-00006-of-00007.safetensors",
|
513 |
+
"model.layers.24.self_attn.time_mixer.key.weight": "model-00006-of-00007.safetensors",
|
514 |
+
"model.layers.24.self_attn.time_mixer.output.weight": "model-00006-of-00007.safetensors",
|
515 |
+
"model.layers.24.self_attn.time_mixer.r_k": "model-00006-of-00007.safetensors",
|
516 |
+
"model.layers.24.self_attn.time_mixer.receptance.weight": "model-00006-of-00007.safetensors",
|
517 |
+
"model.layers.24.self_attn.time_mixer.v0": "model-00006-of-00007.safetensors",
|
518 |
+
"model.layers.24.self_attn.time_mixer.v1": "model-00006-of-00007.safetensors",
|
519 |
+
"model.layers.24.self_attn.time_mixer.v2": "model-00006-of-00007.safetensors",
|
520 |
+
"model.layers.24.self_attn.time_mixer.value.weight": "model-00006-of-00007.safetensors",
|
521 |
+
"model.layers.24.self_attn.time_mixer.w0": "model-00006-of-00007.safetensors",
|
522 |
+
"model.layers.24.self_attn.time_mixer.w1": "model-00006-of-00007.safetensors",
|
523 |
+
"model.layers.24.self_attn.time_mixer.w2": "model-00006-of-00007.safetensors",
|
524 |
+
"model.layers.24.self_attn.time_mixer.x_a": "model-00006-of-00007.safetensors",
|
525 |
+
"model.layers.24.self_attn.time_mixer.x_g": "model-00006-of-00007.safetensors",
|
526 |
+
"model.layers.24.self_attn.time_mixer.x_k": "model-00006-of-00007.safetensors",
|
527 |
+
"model.layers.24.self_attn.time_mixer.x_r": "model-00006-of-00007.safetensors",
|
528 |
+
"model.layers.24.self_attn.time_mixer.x_v": "model-00006-of-00007.safetensors",
|
529 |
+
"model.layers.24.self_attn.time_mixer.x_w": "model-00006-of-00007.safetensors",
|
530 |
+
"model.layers.25.input_layernorm.weight": "model-00006-of-00007.safetensors",
|
531 |
+
"model.layers.25.mlp.down_proj.weight": "model-00006-of-00007.safetensors",
|
532 |
+
"model.layers.25.mlp.gate_proj.weight": "model-00006-of-00007.safetensors",
|
533 |
+
"model.layers.25.mlp.up_proj.weight": "model-00006-of-00007.safetensors",
|
534 |
+
"model.layers.25.post_attention_layernorm.weight": "model-00006-of-00007.safetensors",
|
535 |
+
"model.layers.25.self_attn.time_mixer.a0": "model-00006-of-00007.safetensors",
|
536 |
+
"model.layers.25.self_attn.time_mixer.a1": "model-00006-of-00007.safetensors",
|
537 |
+
"model.layers.25.self_attn.time_mixer.a2": "model-00006-of-00007.safetensors",
|
538 |
+
"model.layers.25.self_attn.time_mixer.g1": "model-00006-of-00007.safetensors",
|
539 |
+
"model.layers.25.self_attn.time_mixer.g2": "model-00006-of-00007.safetensors",
|
540 |
+
"model.layers.25.self_attn.time_mixer.k_a": "model-00006-of-00007.safetensors",
|
541 |
+
"model.layers.25.self_attn.time_mixer.k_k": "model-00006-of-00007.safetensors",
|
542 |
+
"model.layers.25.self_attn.time_mixer.key.weight": "model-00006-of-00007.safetensors",
|
543 |
+
"model.layers.25.self_attn.time_mixer.output.weight": "model-00006-of-00007.safetensors",
|
544 |
+
"model.layers.25.self_attn.time_mixer.r_k": "model-00006-of-00007.safetensors",
|
545 |
+
"model.layers.25.self_attn.time_mixer.receptance.weight": "model-00006-of-00007.safetensors",
|
546 |
+
"model.layers.25.self_attn.time_mixer.v0": "model-00006-of-00007.safetensors",
|
547 |
+
"model.layers.25.self_attn.time_mixer.v1": "model-00006-of-00007.safetensors",
|
548 |
+
"model.layers.25.self_attn.time_mixer.v2": "model-00006-of-00007.safetensors",
|
549 |
+
"model.layers.25.self_attn.time_mixer.value.weight": "model-00006-of-00007.safetensors",
|
550 |
+
"model.layers.25.self_attn.time_mixer.w0": "model-00006-of-00007.safetensors",
|
551 |
+
"model.layers.25.self_attn.time_mixer.w1": "model-00006-of-00007.safetensors",
|
552 |
+
"model.layers.25.self_attn.time_mixer.w2": "model-00006-of-00007.safetensors",
|
553 |
+
"model.layers.25.self_attn.time_mixer.x_a": "model-00006-of-00007.safetensors",
|
554 |
+
"model.layers.25.self_attn.time_mixer.x_g": "model-00006-of-00007.safetensors",
|
555 |
+
"model.layers.25.self_attn.time_mixer.x_k": "model-00006-of-00007.safetensors",
|
556 |
+
"model.layers.25.self_attn.time_mixer.x_r": "model-00006-of-00007.safetensors",
|
557 |
+
"model.layers.25.self_attn.time_mixer.x_v": "model-00006-of-00007.safetensors",
|
558 |
+
"model.layers.25.self_attn.time_mixer.x_w": "model-00006-of-00007.safetensors",
|
559 |
+
"model.layers.26.input_layernorm.weight": "model-00007-of-00007.safetensors",
|
560 |
+
"model.layers.26.mlp.down_proj.weight": "model-00007-of-00007.safetensors",
|
561 |
+
"model.layers.26.mlp.gate_proj.weight": "model-00006-of-00007.safetensors",
|
562 |
+
"model.layers.26.mlp.up_proj.weight": "model-00007-of-00007.safetensors",
|
563 |
+
"model.layers.26.post_attention_layernorm.weight": "model-00007-of-00007.safetensors",
|
564 |
+
"model.layers.26.self_attn.time_mixer.a0": "model-00006-of-00007.safetensors",
|
565 |
+
"model.layers.26.self_attn.time_mixer.a1": "model-00006-of-00007.safetensors",
|
566 |
+
"model.layers.26.self_attn.time_mixer.a2": "model-00006-of-00007.safetensors",
|
567 |
+
"model.layers.26.self_attn.time_mixer.g1": "model-00006-of-00007.safetensors",
|
568 |
+
"model.layers.26.self_attn.time_mixer.g2": "model-00006-of-00007.safetensors",
|
569 |
+
"model.layers.26.self_attn.time_mixer.k_a": "model-00006-of-00007.safetensors",
|
570 |
+
"model.layers.26.self_attn.time_mixer.k_k": "model-00006-of-00007.safetensors",
|
571 |
+
"model.layers.26.self_attn.time_mixer.key.weight": "model-00006-of-00007.safetensors",
|
572 |
+
"model.layers.26.self_attn.time_mixer.output.weight": "model-00006-of-00007.safetensors",
|
573 |
+
"model.layers.26.self_attn.time_mixer.r_k": "model-00006-of-00007.safetensors",
|
574 |
+
"model.layers.26.self_attn.time_mixer.receptance.weight": "model-00006-of-00007.safetensors",
|
575 |
+
"model.layers.26.self_attn.time_mixer.v0": "model-00006-of-00007.safetensors",
|
576 |
+
"model.layers.26.self_attn.time_mixer.v1": "model-00006-of-00007.safetensors",
|
577 |
+
"model.layers.26.self_attn.time_mixer.v2": "model-00006-of-00007.safetensors",
|
578 |
+
"model.layers.26.self_attn.time_mixer.value.weight": "model-00006-of-00007.safetensors",
|
579 |
+
"model.layers.26.self_attn.time_mixer.w0": "model-00006-of-00007.safetensors",
|
580 |
+
"model.layers.26.self_attn.time_mixer.w1": "model-00006-of-00007.safetensors",
|
581 |
+
"model.layers.26.self_attn.time_mixer.w2": "model-00006-of-00007.safetensors",
|
582 |
+
"model.layers.26.self_attn.time_mixer.x_a": "model-00006-of-00007.safetensors",
|
583 |
+
"model.layers.26.self_attn.time_mixer.x_g": "model-00006-of-00007.safetensors",
|
584 |
+
"model.layers.26.self_attn.time_mixer.x_k": "model-00006-of-00007.safetensors",
|
585 |
+
"model.layers.26.self_attn.time_mixer.x_r": "model-00006-of-00007.safetensors",
|
586 |
+
"model.layers.26.self_attn.time_mixer.x_v": "model-00006-of-00007.safetensors",
|
587 |
+
"model.layers.26.self_attn.time_mixer.x_w": "model-00006-of-00007.safetensors",
|
588 |
+
"model.layers.27.input_layernorm.weight": "model-00007-of-00007.safetensors",
|
589 |
+
"model.layers.27.mlp.down_proj.weight": "model-00007-of-00007.safetensors",
|
590 |
+
"model.layers.27.mlp.gate_proj.weight": "model-00007-of-00007.safetensors",
|
591 |
+
"model.layers.27.mlp.up_proj.weight": "model-00007-of-00007.safetensors",
|
592 |
+
"model.layers.27.post_attention_layernorm.weight": "model-00007-of-00007.safetensors",
|
593 |
+
"model.layers.27.self_attn.time_mixer.a0": "model-00007-of-00007.safetensors",
|
594 |
+
"model.layers.27.self_attn.time_mixer.a1": "model-00007-of-00007.safetensors",
|
595 |
+
"model.layers.27.self_attn.time_mixer.a2": "model-00007-of-00007.safetensors",
|
596 |
+
"model.layers.27.self_attn.time_mixer.g1": "model-00007-of-00007.safetensors",
|
597 |
+
"model.layers.27.self_attn.time_mixer.g2": "model-00007-of-00007.safetensors",
|
598 |
+
"model.layers.27.self_attn.time_mixer.k_a": "model-00007-of-00007.safetensors",
|
599 |
+
"model.layers.27.self_attn.time_mixer.k_k": "model-00007-of-00007.safetensors",
|
600 |
+
"model.layers.27.self_attn.time_mixer.key.weight": "model-00007-of-00007.safetensors",
|
601 |
+
"model.layers.27.self_attn.time_mixer.output.weight": "model-00007-of-00007.safetensors",
|
602 |
+
"model.layers.27.self_attn.time_mixer.r_k": "model-00007-of-00007.safetensors",
|
603 |
+
"model.layers.27.self_attn.time_mixer.receptance.weight": "model-00007-of-00007.safetensors",
|
604 |
+
"model.layers.27.self_attn.time_mixer.v0": "model-00007-of-00007.safetensors",
|
605 |
+
"model.layers.27.self_attn.time_mixer.v1": "model-00007-of-00007.safetensors",
|
606 |
+
"model.layers.27.self_attn.time_mixer.v2": "model-00007-of-00007.safetensors",
|
607 |
+
"model.layers.27.self_attn.time_mixer.value.weight": "model-00007-of-00007.safetensors",
|
608 |
+
"model.layers.27.self_attn.time_mixer.w0": "model-00007-of-00007.safetensors",
|
609 |
+
"model.layers.27.self_attn.time_mixer.w1": "model-00007-of-00007.safetensors",
|
610 |
+
"model.layers.27.self_attn.time_mixer.w2": "model-00007-of-00007.safetensors",
|
611 |
+
"model.layers.27.self_attn.time_mixer.x_a": "model-00007-of-00007.safetensors",
|
612 |
+
"model.layers.27.self_attn.time_mixer.x_g": "model-00007-of-00007.safetensors",
|
613 |
+
"model.layers.27.self_attn.time_mixer.x_k": "model-00007-of-00007.safetensors",
|
614 |
+
"model.layers.27.self_attn.time_mixer.x_r": "model-00007-of-00007.safetensors",
|
615 |
+
"model.layers.27.self_attn.time_mixer.x_v": "model-00007-of-00007.safetensors",
|
616 |
+
"model.layers.27.self_attn.time_mixer.x_w": "model-00007-of-00007.safetensors",
|
617 |
+
"model.layers.3.input_layernorm.weight": "model-00002-of-00007.safetensors",
|
618 |
+
"model.layers.3.mlp.down_proj.weight": "model-00002-of-00007.safetensors",
|
619 |
+
"model.layers.3.mlp.gate_proj.weight": "model-00002-of-00007.safetensors",
|
620 |
+
"model.layers.3.mlp.up_proj.weight": "model-00002-of-00007.safetensors",
|
621 |
+
"model.layers.3.post_attention_layernorm.weight": "model-00002-of-00007.safetensors",
|
622 |
+
"model.layers.3.self_attn.time_mixer.a0": "model-00002-of-00007.safetensors",
|
623 |
+
"model.layers.3.self_attn.time_mixer.a1": "model-00002-of-00007.safetensors",
|
624 |
+
"model.layers.3.self_attn.time_mixer.a2": "model-00002-of-00007.safetensors",
|
625 |
+
"model.layers.3.self_attn.time_mixer.g1": "model-00002-of-00007.safetensors",
|
626 |
+
"model.layers.3.self_attn.time_mixer.g2": "model-00002-of-00007.safetensors",
|
627 |
+
"model.layers.3.self_attn.time_mixer.k_a": "model-00002-of-00007.safetensors",
|
628 |
+
"model.layers.3.self_attn.time_mixer.k_k": "model-00002-of-00007.safetensors",
|
629 |
+
"model.layers.3.self_attn.time_mixer.key.weight": "model-00002-of-00007.safetensors",
|
630 |
+
"model.layers.3.self_attn.time_mixer.output.weight": "model-00002-of-00007.safetensors",
|
631 |
+
"model.layers.3.self_attn.time_mixer.r_k": "model-00002-of-00007.safetensors",
|
632 |
+
"model.layers.3.self_attn.time_mixer.receptance.weight": "model-00002-of-00007.safetensors",
|
633 |
+
"model.layers.3.self_attn.time_mixer.v0": "model-00002-of-00007.safetensors",
|
634 |
+
"model.layers.3.self_attn.time_mixer.v1": "model-00002-of-00007.safetensors",
|
635 |
+
"model.layers.3.self_attn.time_mixer.v2": "model-00002-of-00007.safetensors",
|
636 |
+
"model.layers.3.self_attn.time_mixer.value.weight": "model-00002-of-00007.safetensors",
|
637 |
+
"model.layers.3.self_attn.time_mixer.w0": "model-00002-of-00007.safetensors",
|
638 |
+
"model.layers.3.self_attn.time_mixer.w1": "model-00002-of-00007.safetensors",
|
639 |
+
"model.layers.3.self_attn.time_mixer.w2": "model-00002-of-00007.safetensors",
|
640 |
+
"model.layers.3.self_attn.time_mixer.x_a": "model-00002-of-00007.safetensors",
|
641 |
+
"model.layers.3.self_attn.time_mixer.x_g": "model-00002-of-00007.safetensors",
|
642 |
+
"model.layers.3.self_attn.time_mixer.x_k": "model-00002-of-00007.safetensors",
|
643 |
+
"model.layers.3.self_attn.time_mixer.x_r": "model-00002-of-00007.safetensors",
|
644 |
+
"model.layers.3.self_attn.time_mixer.x_v": "model-00002-of-00007.safetensors",
|
645 |
+
"model.layers.3.self_attn.time_mixer.x_w": "model-00002-of-00007.safetensors",
|
646 |
+
"model.layers.4.input_layernorm.weight": "model-00002-of-00007.safetensors",
|
647 |
+
"model.layers.4.mlp.down_proj.weight": "model-00002-of-00007.safetensors",
|
648 |
+
"model.layers.4.mlp.gate_proj.weight": "model-00002-of-00007.safetensors",
|
649 |
+
"model.layers.4.mlp.up_proj.weight": "model-00002-of-00007.safetensors",
|
650 |
+
"model.layers.4.post_attention_layernorm.weight": "model-00002-of-00007.safetensors",
|
651 |
+
"model.layers.4.self_attn.time_mixer.a0": "model-00002-of-00007.safetensors",
|
652 |
+
"model.layers.4.self_attn.time_mixer.a1": "model-00002-of-00007.safetensors",
|
653 |
+
"model.layers.4.self_attn.time_mixer.a2": "model-00002-of-00007.safetensors",
|
654 |
+
"model.layers.4.self_attn.time_mixer.g1": "model-00002-of-00007.safetensors",
|
655 |
+
"model.layers.4.self_attn.time_mixer.g2": "model-00002-of-00007.safetensors",
|
656 |
+
"model.layers.4.self_attn.time_mixer.k_a": "model-00002-of-00007.safetensors",
|
657 |
+
"model.layers.4.self_attn.time_mixer.k_k": "model-00002-of-00007.safetensors",
|
658 |
+
"model.layers.4.self_attn.time_mixer.key.weight": "model-00002-of-00007.safetensors",
|
659 |
+
"model.layers.4.self_attn.time_mixer.output.weight": "model-00002-of-00007.safetensors",
|
660 |
+
"model.layers.4.self_attn.time_mixer.r_k": "model-00002-of-00007.safetensors",
|
661 |
+
"model.layers.4.self_attn.time_mixer.receptance.weight": "model-00002-of-00007.safetensors",
|
662 |
+
"model.layers.4.self_attn.time_mixer.v0": "model-00002-of-00007.safetensors",
|
663 |
+
"model.layers.4.self_attn.time_mixer.v1": "model-00002-of-00007.safetensors",
|
664 |
+
"model.layers.4.self_attn.time_mixer.v2": "model-00002-of-00007.safetensors",
|
665 |
+
"model.layers.4.self_attn.time_mixer.value.weight": "model-00002-of-00007.safetensors",
|
666 |
+
"model.layers.4.self_attn.time_mixer.w0": "model-00002-of-00007.safetensors",
|
667 |
+
"model.layers.4.self_attn.time_mixer.w1": "model-00002-of-00007.safetensors",
|
668 |
+
"model.layers.4.self_attn.time_mixer.w2": "model-00002-of-00007.safetensors",
|
669 |
+
"model.layers.4.self_attn.time_mixer.x_a": "model-00002-of-00007.safetensors",
|
670 |
+
"model.layers.4.self_attn.time_mixer.x_g": "model-00002-of-00007.safetensors",
|
671 |
+
"model.layers.4.self_attn.time_mixer.x_k": "model-00002-of-00007.safetensors",
|
672 |
+
"model.layers.4.self_attn.time_mixer.x_r": "model-00002-of-00007.safetensors",
|
673 |
+
"model.layers.4.self_attn.time_mixer.x_v": "model-00002-of-00007.safetensors",
|
674 |
+
"model.layers.4.self_attn.time_mixer.x_w": "model-00002-of-00007.safetensors",
|
675 |
+
"model.layers.5.input_layernorm.weight": "model-00002-of-00007.safetensors",
|
676 |
+
"model.layers.5.mlp.down_proj.weight": "model-00002-of-00007.safetensors",
|
677 |
+
"model.layers.5.mlp.gate_proj.weight": "model-00002-of-00007.safetensors",
|
678 |
+
"model.layers.5.mlp.up_proj.weight": "model-00002-of-00007.safetensors",
|
679 |
+
"model.layers.5.post_attention_layernorm.weight": "model-00002-of-00007.safetensors",
|
680 |
+
"model.layers.5.self_attn.time_mixer.a0": "model-00002-of-00007.safetensors",
|
681 |
+
"model.layers.5.self_attn.time_mixer.a1": "model-00002-of-00007.safetensors",
|
682 |
+
"model.layers.5.self_attn.time_mixer.a2": "model-00002-of-00007.safetensors",
|
683 |
+
"model.layers.5.self_attn.time_mixer.g1": "model-00002-of-00007.safetensors",
|
684 |
+
"model.layers.5.self_attn.time_mixer.g2": "model-00002-of-00007.safetensors",
|
685 |
+
"model.layers.5.self_attn.time_mixer.k_a": "model-00002-of-00007.safetensors",
|
686 |
+
"model.layers.5.self_attn.time_mixer.k_k": "model-00002-of-00007.safetensors",
|
687 |
+
"model.layers.5.self_attn.time_mixer.key.weight": "model-00002-of-00007.safetensors",
|
688 |
+
"model.layers.5.self_attn.time_mixer.output.weight": "model-00002-of-00007.safetensors",
|
689 |
+
"model.layers.5.self_attn.time_mixer.r_k": "model-00002-of-00007.safetensors",
|
690 |
+
"model.layers.5.self_attn.time_mixer.receptance.weight": "model-00002-of-00007.safetensors",
|
691 |
+
"model.layers.5.self_attn.time_mixer.v0": "model-00002-of-00007.safetensors",
|
692 |
+
"model.layers.5.self_attn.time_mixer.v1": "model-00002-of-00007.safetensors",
|
693 |
+
"model.layers.5.self_attn.time_mixer.v2": "model-00002-of-00007.safetensors",
|
694 |
+
"model.layers.5.self_attn.time_mixer.value.weight": "model-00002-of-00007.safetensors",
|
695 |
+
"model.layers.5.self_attn.time_mixer.w0": "model-00002-of-00007.safetensors",
|
696 |
+
"model.layers.5.self_attn.time_mixer.w1": "model-00002-of-00007.safetensors",
|
697 |
+
"model.layers.5.self_attn.time_mixer.w2": "model-00002-of-00007.safetensors",
|
698 |
+
"model.layers.5.self_attn.time_mixer.x_a": "model-00002-of-00007.safetensors",
|
699 |
+
"model.layers.5.self_attn.time_mixer.x_g": "model-00002-of-00007.safetensors",
|
700 |
+
"model.layers.5.self_attn.time_mixer.x_k": "model-00002-of-00007.safetensors",
|
701 |
+
"model.layers.5.self_attn.time_mixer.x_r": "model-00002-of-00007.safetensors",
|
702 |
+
"model.layers.5.self_attn.time_mixer.x_v": "model-00002-of-00007.safetensors",
|
703 |
+
"model.layers.5.self_attn.time_mixer.x_w": "model-00002-of-00007.safetensors",
|
704 |
+
"model.layers.6.input_layernorm.weight": "model-00002-of-00007.safetensors",
|
705 |
+
"model.layers.6.mlp.down_proj.weight": "model-00002-of-00007.safetensors",
|
706 |
+
"model.layers.6.mlp.gate_proj.weight": "model-00002-of-00007.safetensors",
|
707 |
+
"model.layers.6.mlp.up_proj.weight": "model-00002-of-00007.safetensors",
|
708 |
+
"model.layers.6.post_attention_layernorm.weight": "model-00002-of-00007.safetensors",
|
709 |
+
"model.layers.6.self_attn.time_mixer.a0": "model-00002-of-00007.safetensors",
|
710 |
+
"model.layers.6.self_attn.time_mixer.a1": "model-00002-of-00007.safetensors",
|
711 |
+
"model.layers.6.self_attn.time_mixer.a2": "model-00002-of-00007.safetensors",
|
712 |
+
"model.layers.6.self_attn.time_mixer.g1": "model-00002-of-00007.safetensors",
|
713 |
+
"model.layers.6.self_attn.time_mixer.g2": "model-00002-of-00007.safetensors",
|
714 |
+
"model.layers.6.self_attn.time_mixer.k_a": "model-00002-of-00007.safetensors",
|
715 |
+
"model.layers.6.self_attn.time_mixer.k_k": "model-00002-of-00007.safetensors",
|
716 |
+
"model.layers.6.self_attn.time_mixer.key.weight": "model-00002-of-00007.safetensors",
|
717 |
+
"model.layers.6.self_attn.time_mixer.output.weight": "model-00002-of-00007.safetensors",
|
718 |
+
"model.layers.6.self_attn.time_mixer.r_k": "model-00002-of-00007.safetensors",
|
719 |
+
"model.layers.6.self_attn.time_mixer.receptance.weight": "model-00002-of-00007.safetensors",
|
720 |
+
"model.layers.6.self_attn.time_mixer.v0": "model-00002-of-00007.safetensors",
|
721 |
+
"model.layers.6.self_attn.time_mixer.v1": "model-00002-of-00007.safetensors",
|
722 |
+
"model.layers.6.self_attn.time_mixer.v2": "model-00002-of-00007.safetensors",
|
723 |
+
"model.layers.6.self_attn.time_mixer.value.weight": "model-00002-of-00007.safetensors",
|
724 |
+
"model.layers.6.self_attn.time_mixer.w0": "model-00002-of-00007.safetensors",
|
725 |
+
"model.layers.6.self_attn.time_mixer.w1": "model-00002-of-00007.safetensors",
|
726 |
+
"model.layers.6.self_attn.time_mixer.w2": "model-00002-of-00007.safetensors",
|
727 |
+
"model.layers.6.self_attn.time_mixer.x_a": "model-00002-of-00007.safetensors",
|
728 |
+
"model.layers.6.self_attn.time_mixer.x_g": "model-00002-of-00007.safetensors",
|
729 |
+
"model.layers.6.self_attn.time_mixer.x_k": "model-00002-of-00007.safetensors",
|
730 |
+
"model.layers.6.self_attn.time_mixer.x_r": "model-00002-of-00007.safetensors",
|
731 |
+
"model.layers.6.self_attn.time_mixer.x_v": "model-00002-of-00007.safetensors",
|
732 |
+
"model.layers.6.self_attn.time_mixer.x_w": "model-00002-of-00007.safetensors",
|
733 |
+
"model.layers.7.input_layernorm.weight": "model-00003-of-00007.safetensors",
|
734 |
+
"model.layers.7.mlp.down_proj.weight": "model-00003-of-00007.safetensors",
|
735 |
+
"model.layers.7.mlp.gate_proj.weight": "model-00002-of-00007.safetensors",
|
736 |
+
"model.layers.7.mlp.up_proj.weight": "model-00003-of-00007.safetensors",
|
737 |
+
"model.layers.7.post_attention_layernorm.weight": "model-00003-of-00007.safetensors",
|
738 |
+
"model.layers.7.self_attn.time_mixer.a0": "model-00002-of-00007.safetensors",
|
739 |
+
"model.layers.7.self_attn.time_mixer.a1": "model-00002-of-00007.safetensors",
|
740 |
+
"model.layers.7.self_attn.time_mixer.a2": "model-00002-of-00007.safetensors",
|
741 |
+
"model.layers.7.self_attn.time_mixer.g1": "model-00002-of-00007.safetensors",
|
742 |
+
"model.layers.7.self_attn.time_mixer.g2": "model-00002-of-00007.safetensors",
|
743 |
+
"model.layers.7.self_attn.time_mixer.k_a": "model-00002-of-00007.safetensors",
|
744 |
+
"model.layers.7.self_attn.time_mixer.k_k": "model-00002-of-00007.safetensors",
|
745 |
+
"model.layers.7.self_attn.time_mixer.key.weight": "model-00002-of-00007.safetensors",
|
746 |
+
"model.layers.7.self_attn.time_mixer.output.weight": "model-00002-of-00007.safetensors",
|
747 |
+
"model.layers.7.self_attn.time_mixer.r_k": "model-00002-of-00007.safetensors",
|
748 |
+
"model.layers.7.self_attn.time_mixer.receptance.weight": "model-00002-of-00007.safetensors",
|
749 |
+
"model.layers.7.self_attn.time_mixer.v0": "model-00002-of-00007.safetensors",
|
750 |
+
"model.layers.7.self_attn.time_mixer.v1": "model-00002-of-00007.safetensors",
|
751 |
+
"model.layers.7.self_attn.time_mixer.v2": "model-00002-of-00007.safetensors",
|
752 |
+
"model.layers.7.self_attn.time_mixer.value.weight": "model-00002-of-00007.safetensors",
|
753 |
+
"model.layers.7.self_attn.time_mixer.w0": "model-00002-of-00007.safetensors",
|
754 |
+
"model.layers.7.self_attn.time_mixer.w1": "model-00002-of-00007.safetensors",
|
755 |
+
"model.layers.7.self_attn.time_mixer.w2": "model-00002-of-00007.safetensors",
|
756 |
+
"model.layers.7.self_attn.time_mixer.x_a": "model-00002-of-00007.safetensors",
|
757 |
+
"model.layers.7.self_attn.time_mixer.x_g": "model-00002-of-00007.safetensors",
|
758 |
+
"model.layers.7.self_attn.time_mixer.x_k": "model-00002-of-00007.safetensors",
|
759 |
+
"model.layers.7.self_attn.time_mixer.x_r": "model-00002-of-00007.safetensors",
|
760 |
+
"model.layers.7.self_attn.time_mixer.x_v": "model-00002-of-00007.safetensors",
|
761 |
+
"model.layers.7.self_attn.time_mixer.x_w": "model-00002-of-00007.safetensors",
|
762 |
+
"model.layers.8.input_layernorm.weight": "model-00003-of-00007.safetensors",
|
763 |
+
"model.layers.8.mlp.down_proj.weight": "model-00003-of-00007.safetensors",
|
764 |
+
"model.layers.8.mlp.gate_proj.weight": "model-00003-of-00007.safetensors",
|
765 |
+
"model.layers.8.mlp.up_proj.weight": "model-00003-of-00007.safetensors",
|
766 |
+
"model.layers.8.post_attention_layernorm.weight": "model-00003-of-00007.safetensors",
|
767 |
+
"model.layers.8.self_attn.time_mixer.a0": "model-00003-of-00007.safetensors",
|
768 |
+
"model.layers.8.self_attn.time_mixer.a1": "model-00003-of-00007.safetensors",
|
769 |
+
"model.layers.8.self_attn.time_mixer.a2": "model-00003-of-00007.safetensors",
|
770 |
+
"model.layers.8.self_attn.time_mixer.g1": "model-00003-of-00007.safetensors",
|
771 |
+
"model.layers.8.self_attn.time_mixer.g2": "model-00003-of-00007.safetensors",
|
772 |
+
"model.layers.8.self_attn.time_mixer.k_a": "model-00003-of-00007.safetensors",
|
773 |
+
"model.layers.8.self_attn.time_mixer.k_k": "model-00003-of-00007.safetensors",
|
774 |
+
"model.layers.8.self_attn.time_mixer.key.weight": "model-00003-of-00007.safetensors",
|
775 |
+
"model.layers.8.self_attn.time_mixer.output.weight": "model-00003-of-00007.safetensors",
|
776 |
+
"model.layers.8.self_attn.time_mixer.r_k": "model-00003-of-00007.safetensors",
|
777 |
+
"model.layers.8.self_attn.time_mixer.receptance.weight": "model-00003-of-00007.safetensors",
|
778 |
+
"model.layers.8.self_attn.time_mixer.v0": "model-00003-of-00007.safetensors",
|
779 |
+
"model.layers.8.self_attn.time_mixer.v1": "model-00003-of-00007.safetensors",
|
780 |
+
"model.layers.8.self_attn.time_mixer.v2": "model-00003-of-00007.safetensors",
|
781 |
+
"model.layers.8.self_attn.time_mixer.value.weight": "model-00003-of-00007.safetensors",
|
782 |
+
"model.layers.8.self_attn.time_mixer.w0": "model-00003-of-00007.safetensors",
|
783 |
+
"model.layers.8.self_attn.time_mixer.w1": "model-00003-of-00007.safetensors",
|
784 |
+
"model.layers.8.self_attn.time_mixer.w2": "model-00003-of-00007.safetensors",
|
785 |
+
"model.layers.8.self_attn.time_mixer.x_a": "model-00003-of-00007.safetensors",
|
786 |
+
"model.layers.8.self_attn.time_mixer.x_g": "model-00003-of-00007.safetensors",
|
787 |
+
"model.layers.8.self_attn.time_mixer.x_k": "model-00003-of-00007.safetensors",
|
788 |
+
"model.layers.8.self_attn.time_mixer.x_r": "model-00003-of-00007.safetensors",
|
789 |
+
"model.layers.8.self_attn.time_mixer.x_v": "model-00003-of-00007.safetensors",
|
790 |
+
"model.layers.8.self_attn.time_mixer.x_w": "model-00003-of-00007.safetensors",
|
791 |
+
"model.layers.9.input_layernorm.weight": "model-00003-of-00007.safetensors",
|
792 |
+
"model.layers.9.mlp.down_proj.weight": "model-00003-of-00007.safetensors",
|
793 |
+
"model.layers.9.mlp.gate_proj.weight": "model-00003-of-00007.safetensors",
|
794 |
+
"model.layers.9.mlp.up_proj.weight": "model-00003-of-00007.safetensors",
|
795 |
+
"model.layers.9.post_attention_layernorm.weight": "model-00003-of-00007.safetensors",
|
796 |
+
"model.layers.9.self_attn.time_mixer.a0": "model-00003-of-00007.safetensors",
|
797 |
+
"model.layers.9.self_attn.time_mixer.a1": "model-00003-of-00007.safetensors",
|
798 |
+
"model.layers.9.self_attn.time_mixer.a2": "model-00003-of-00007.safetensors",
|
799 |
+
"model.layers.9.self_attn.time_mixer.g1": "model-00003-of-00007.safetensors",
|
800 |
+
"model.layers.9.self_attn.time_mixer.g2": "model-00003-of-00007.safetensors",
|
801 |
+
"model.layers.9.self_attn.time_mixer.k_a": "model-00003-of-00007.safetensors",
|
802 |
+
"model.layers.9.self_attn.time_mixer.k_k": "model-00003-of-00007.safetensors",
|
803 |
+
"model.layers.9.self_attn.time_mixer.key.weight": "model-00003-of-00007.safetensors",
|
804 |
+
"model.layers.9.self_attn.time_mixer.output.weight": "model-00003-of-00007.safetensors",
|
805 |
+
"model.layers.9.self_attn.time_mixer.r_k": "model-00003-of-00007.safetensors",
|
806 |
+
"model.layers.9.self_attn.time_mixer.receptance.weight": "model-00003-of-00007.safetensors",
|
807 |
+
"model.layers.9.self_attn.time_mixer.v0": "model-00003-of-00007.safetensors",
|
808 |
+
"model.layers.9.self_attn.time_mixer.v1": "model-00003-of-00007.safetensors",
|
809 |
+
"model.layers.9.self_attn.time_mixer.v2": "model-00003-of-00007.safetensors",
|
810 |
+
"model.layers.9.self_attn.time_mixer.value.weight": "model-00003-of-00007.safetensors",
|
811 |
+
"model.layers.9.self_attn.time_mixer.w0": "model-00003-of-00007.safetensors",
|
812 |
+
"model.layers.9.self_attn.time_mixer.w1": "model-00003-of-00007.safetensors",
|
813 |
+
"model.layers.9.self_attn.time_mixer.w2": "model-00003-of-00007.safetensors",
|
814 |
+
"model.layers.9.self_attn.time_mixer.x_a": "model-00003-of-00007.safetensors",
|
815 |
+
"model.layers.9.self_attn.time_mixer.x_g": "model-00003-of-00007.safetensors",
|
816 |
+
"model.layers.9.self_attn.time_mixer.x_k": "model-00003-of-00007.safetensors",
|
817 |
+
"model.layers.9.self_attn.time_mixer.x_r": "model-00003-of-00007.safetensors",
|
818 |
+
"model.layers.9.self_attn.time_mixer.x_v": "model-00003-of-00007.safetensors",
|
819 |
+
"model.layers.9.self_attn.time_mixer.x_w": "model-00003-of-00007.safetensors",
|
820 |
+
"model.norm.weight": "model-00007-of-00007.safetensors"
|
821 |
+
}
|
822 |
+
}
|
modeling_rwkv_hybrid.py
ADDED
@@ -0,0 +1,632 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Callable, List, Optional, Tuple, Union
|
2 |
+
|
3 |
+
import torch
|
4 |
+
import torch.nn as nn
|
5 |
+
from transformers.cache_utils import Cache
|
6 |
+
|
7 |
+
from transformers.activations import ACT2FN
|
8 |
+
from transformers.cache_utils import Cache, StaticCache
|
9 |
+
from .hybrid_cache import HybridCache
|
10 |
+
from transformers.generation import GenerationMixin
|
11 |
+
from transformers.modeling_attn_mask_utils import AttentionMaskConverter
|
12 |
+
from transformers.modeling_flash_attention_utils import FlashAttentionKwargs
|
13 |
+
from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
|
14 |
+
|
15 |
+
from transformers.modeling_outputs import (
|
16 |
+
BaseModelOutputWithPast,
|
17 |
+
CausalLMOutputWithPast,
|
18 |
+
)
|
19 |
+
from transformers.processing_utils import Unpack
|
20 |
+
from transformers.utils import (
|
21 |
+
LossKwargs,
|
22 |
+
add_start_docstrings,
|
23 |
+
add_start_docstrings_to_model_forward,
|
24 |
+
logging,
|
25 |
+
)
|
26 |
+
|
27 |
+
import threading
|
28 |
+
from .wkv import Rwkv7Attention, Rwkv6Attention
|
29 |
+
from .configuration_rwkv_hybrid import RwkvHybridConfig
|
30 |
+
|
31 |
+
from transformers.models.qwen2.modeling_qwen2 import (Qwen2MLP,
|
32 |
+
Qwen2RMSNorm,
|
33 |
+
Qwen2RotaryEmbedding,
|
34 |
+
Qwen2Attention)
|
35 |
+
|
36 |
+
logger = logging.get_logger(__name__)
|
37 |
+
|
38 |
+
_CONFIG_FOR_DOC = "RwkvHybridConfig"
|
39 |
+
|
40 |
+
class RwkvHybridDecoderLayer(nn.Module):
|
41 |
+
def __init__(self, config: RwkvHybridConfig, layer_idx: int, update_v_first, get_v_first):
|
42 |
+
super().__init__()
|
43 |
+
self.hidden_size = config.hidden_size
|
44 |
+
|
45 |
+
self.is_rwkv = True if layer_idx in config.wkv_layers else False
|
46 |
+
if self.is_rwkv:
|
47 |
+
if config.wkv_version == 7:
|
48 |
+
self.self_attn = Rwkv7Attention(args=config, layer_id=layer_idx,
|
49 |
+
update_v_first=update_v_first,
|
50 |
+
get_v_first=get_v_first)
|
51 |
+
elif config.wkv_version == 6:
|
52 |
+
self.self_attn = Rwkv6Attention(args=config, layer_id=layer_idx,
|
53 |
+
update_v_first=update_v_first,
|
54 |
+
get_v_first=get_v_first)
|
55 |
+
else:
|
56 |
+
raise NotImplementedError
|
57 |
+
elif not self.is_rwkv:
|
58 |
+
self.self_attn = Qwen2Attention(config=config, layer_idx=layer_idx)
|
59 |
+
else:
|
60 |
+
self.self_attn = None
|
61 |
+
raise NotImplementedError
|
62 |
+
|
63 |
+
self.mlp = Qwen2MLP(config)
|
64 |
+
self.input_layernorm = Qwen2RMSNorm(
|
65 |
+
config.hidden_size, eps=config.rms_norm_eps)
|
66 |
+
self.post_attention_layernorm = Qwen2RMSNorm(
|
67 |
+
config.hidden_size, eps=config.rms_norm_eps)
|
68 |
+
|
69 |
+
|
70 |
+
def forward(
|
71 |
+
self,
|
72 |
+
hidden_states: torch.Tensor,
|
73 |
+
attention_mask: Optional[torch.Tensor] = None,
|
74 |
+
position_ids: Optional[torch.LongTensor] = None,
|
75 |
+
past_key_value: Optional[Cache] = None,
|
76 |
+
output_attentions: Optional[bool] = False,
|
77 |
+
use_cache: Optional[bool] = False,
|
78 |
+
cache_position: Optional[torch.LongTensor] = None,
|
79 |
+
position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC
|
80 |
+
**kwargs,
|
81 |
+
) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
|
82 |
+
residual = hidden_states
|
83 |
+
|
84 |
+
hidden_states = self.input_layernorm(hidden_states)
|
85 |
+
|
86 |
+
# RWKV attention
|
87 |
+
hidden_states, self_attn_weights = self.self_attn(
|
88 |
+
hidden_states=hidden_states,
|
89 |
+
attention_mask=attention_mask,
|
90 |
+
position_ids=position_ids,
|
91 |
+
past_key_value=past_key_value,
|
92 |
+
output_attentions=output_attentions,
|
93 |
+
use_cache=use_cache,
|
94 |
+
cache_position=cache_position,
|
95 |
+
position_embeddings=position_embeddings,
|
96 |
+
)
|
97 |
+
hidden_states = residual + hidden_states
|
98 |
+
|
99 |
+
# Fully Connected
|
100 |
+
residual = hidden_states
|
101 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
102 |
+
hidden_states = self.mlp(hidden_states)
|
103 |
+
hidden_states = residual + hidden_states
|
104 |
+
|
105 |
+
outputs = (hidden_states,)
|
106 |
+
if output_attentions:
|
107 |
+
outputs += (self_attn_weights,)
|
108 |
+
|
109 |
+
return outputs
|
110 |
+
|
111 |
+
RWKV_HYBRID_START_DOCSTRING = r"""
|
112 |
+
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
|
113 |
+
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
|
114 |
+
etc.)
|
115 |
+
|
116 |
+
This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
|
117 |
+
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
|
118 |
+
and behavior.
|
119 |
+
|
120 |
+
Parameters:
|
121 |
+
config ([`RwkvHybridConfig`]):
|
122 |
+
Model configuration class with all the parameters of the model. Initializing with a config file does not
|
123 |
+
load the weights associated with the model, only the configuration. Check out the
|
124 |
+
[`~PreTrainedModel.from_pretrained`] method to load the model weights.
|
125 |
+
"""
|
126 |
+
|
127 |
+
@add_start_docstrings(
|
128 |
+
"The bare RWKV Hybrid Model outputting raw hidden-states without any specific head on top.",
|
129 |
+
RWKV_HYBRID_START_DOCSTRING,
|
130 |
+
)
|
131 |
+
class RwkvHybridPreTrainedModel(PreTrainedModel):
|
132 |
+
config_class = RwkvHybridConfig
|
133 |
+
base_model_prefix = "rwkv_hybrid"
|
134 |
+
supports_gradient_checkpointing = True
|
135 |
+
_no_split_modules = ["RwkvHybridDecoderLayer"]
|
136 |
+
_skip_keys_device_placement = ["past_key_values"]
|
137 |
+
|
138 |
+
def _init_weights(self, module):
|
139 |
+
std = self.config.initializer_range
|
140 |
+
if isinstance(module, nn.Linear):
|
141 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
142 |
+
if module.bias is not None:
|
143 |
+
module.bias.data.zero_()
|
144 |
+
elif isinstance(module, nn.Embedding):
|
145 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
146 |
+
if module.padding_idx is not None:
|
147 |
+
module.weight.data[module.padding_idx].zero_()
|
148 |
+
|
149 |
+
RWKV_HYBRID_INPUTS_DOCSTRING = r"""
|
150 |
+
Args:
|
151 |
+
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
|
152 |
+
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
|
153 |
+
it.
|
154 |
+
|
155 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
156 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
157 |
+
|
158 |
+
[What are input IDs?](../glossary#input-ids)
|
159 |
+
attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
|
160 |
+
Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
|
161 |
+
|
162 |
+
- 1 for tokens that are **not masked**,
|
163 |
+
- 0 for tokens that are **masked**.
|
164 |
+
|
165 |
+
[What are attention masks?](../glossary#attention-mask)
|
166 |
+
|
167 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
168 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
169 |
+
|
170 |
+
If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
|
171 |
+
`past_key_values`).
|
172 |
+
|
173 |
+
If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
|
174 |
+
and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
|
175 |
+
information on the default strategy.
|
176 |
+
|
177 |
+
- 1 indicates the head is **not masked**,
|
178 |
+
- 0 indicates the head is **masked**.
|
179 |
+
position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
180 |
+
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
|
181 |
+
config.n_positions - 1]`.
|
182 |
+
|
183 |
+
[What are position IDs?](../glossary#position-ids)
|
184 |
+
past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
|
185 |
+
Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
|
186 |
+
blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
|
187 |
+
returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.
|
188 |
+
|
189 |
+
Two formats are allowed:
|
190 |
+
- a [`~cache_utils.Cache`] instance, see our
|
191 |
+
[kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache);
|
192 |
+
- Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
|
193 |
+
shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
|
194 |
+
cache format.
|
195 |
+
|
196 |
+
The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
|
197 |
+
legacy cache format will be returned.
|
198 |
+
|
199 |
+
If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
|
200 |
+
have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
|
201 |
+
of shape `(batch_size, sequence_length)`.
|
202 |
+
inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
|
203 |
+
Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
|
204 |
+
is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
|
205 |
+
model's internal embedding lookup matrix.
|
206 |
+
use_cache (`bool`, *optional*):
|
207 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
|
208 |
+
`past_key_values`).
|
209 |
+
output_attentions (`bool`, *optional*):
|
210 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
|
211 |
+
tensors for more detail.
|
212 |
+
output_hidden_states (`bool`, *optional*):
|
213 |
+
Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
|
214 |
+
more detail.
|
215 |
+
return_dict (`bool`, *optional*):
|
216 |
+
Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
|
217 |
+
cache_position (`torch.LongTensor` of shape `(sequence_length)`, *optional*):
|
218 |
+
Indices depicting the position of the input sequence tokens in the sequence. Contrarily to `position_ids`,
|
219 |
+
this tensor is not affected by padding. It is used to update the cache in the correct position and to infer
|
220 |
+
the complete sequence length.
|
221 |
+
"""
|
222 |
+
|
223 |
+
|
224 |
+
@add_start_docstrings(
|
225 |
+
"The bare RWKV Hybrid Model outputting raw hidden-states without any specific head on top.",
|
226 |
+
RWKV_HYBRID_START_DOCSTRING,
|
227 |
+
)
|
228 |
+
class RwkvHybridModel(RwkvHybridPreTrainedModel):
|
229 |
+
"""
|
230 |
+
RWKV and Transformer hybrid decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`RwkvHybridDecoderLayer`]
|
231 |
+
|
232 |
+
Args:
|
233 |
+
config: RwkvHybridConfig
|
234 |
+
"""
|
235 |
+
|
236 |
+
def __init__(self, config: RwkvHybridConfig):
|
237 |
+
super().__init__(config)
|
238 |
+
self.padding_idx = config.pad_token_id
|
239 |
+
self.vocab_size = config.vocab_size
|
240 |
+
|
241 |
+
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
|
242 |
+
self.thread_local = threading.local()
|
243 |
+
self.thread_local.v_first = None
|
244 |
+
self.layers = nn.ModuleList(
|
245 |
+
[RwkvHybridDecoderLayer(config, layer_idx, self.update_v_first, self.get_v_first) for layer_idx in range(config.num_hidden_layers)]
|
246 |
+
)
|
247 |
+
self.norm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
248 |
+
self.rotary_emb = Qwen2RotaryEmbedding(config=config)
|
249 |
+
self.gradient_checkpointing = False
|
250 |
+
|
251 |
+
# Initialize weights and apply final processing
|
252 |
+
self.post_init()
|
253 |
+
|
254 |
+
def post_init(self):
|
255 |
+
"""
|
256 |
+
A method executed at the end of each Transformer model initialization, to execute code that needs the model's
|
257 |
+
modules properly initialized (such as weight initialization).
|
258 |
+
"""
|
259 |
+
self.init_weights()
|
260 |
+
self._backward_compatibility_gradient_checkpointing()
|
261 |
+
# If current model is a base model, attach `base_model_tp_plan` from config
|
262 |
+
if self.base_model is self:
|
263 |
+
self._tp_plan = self.config.base_model_tp_plan
|
264 |
+
from transformers.modeling_utils import _init_weights
|
265 |
+
if _init_weights:
|
266 |
+
for layer in self.layers:
|
267 |
+
layer.self_attn.time_mixer.post_init()
|
268 |
+
|
269 |
+
def update_v_first(self, new_v_first):
|
270 |
+
"""Callback function to update v_first in HybridModel."""
|
271 |
+
self.thread_local.v_first = new_v_first
|
272 |
+
|
273 |
+
def get_v_first(self):
|
274 |
+
return self.thread_local.v_first
|
275 |
+
|
276 |
+
def get_input_embeddings(self):
|
277 |
+
return self.embed_tokens
|
278 |
+
|
279 |
+
def set_input_embeddings(self, value):
|
280 |
+
self.embed_tokens = value
|
281 |
+
|
282 |
+
@add_start_docstrings_to_model_forward(RWKV_HYBRID_INPUTS_DOCSTRING)
|
283 |
+
def forward(
|
284 |
+
self,
|
285 |
+
input_ids: torch.LongTensor = None,
|
286 |
+
attention_mask: Optional[torch.Tensor] = None,
|
287 |
+
position_ids: Optional[torch.LongTensor] = None,
|
288 |
+
past_key_values: Optional[Cache] = None,
|
289 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
290 |
+
use_cache: Optional[bool] = None,
|
291 |
+
output_attentions: Optional[bool] = None,
|
292 |
+
output_hidden_states: Optional[bool] = None,
|
293 |
+
return_dict: Optional[bool] = None,
|
294 |
+
cache_position: Optional[torch.LongTensor] = None,
|
295 |
+
**flash_attn_kwargs: Unpack[FlashAttentionKwargs],
|
296 |
+
) -> Union[Tuple, BaseModelOutputWithPast]:
|
297 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
298 |
+
output_hidden_states = (
|
299 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
300 |
+
)
|
301 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
302 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
303 |
+
|
304 |
+
if (input_ids is None) ^ (inputs_embeds is not None):
|
305 |
+
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
306 |
+
|
307 |
+
if self.gradient_checkpointing and self.training and use_cache:
|
308 |
+
logger.warning_once(
|
309 |
+
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`."
|
310 |
+
)
|
311 |
+
use_cache = False
|
312 |
+
|
313 |
+
if inputs_embeds is None:
|
314 |
+
inputs_embeds = self.embed_tokens(input_ids)
|
315 |
+
|
316 |
+
if use_cache and past_key_values is None:
|
317 |
+
past_key_values = HybridCache()
|
318 |
+
|
319 |
+
if cache_position is None:
|
320 |
+
past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
|
321 |
+
cache_position = torch.arange(
|
322 |
+
past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device
|
323 |
+
)
|
324 |
+
|
325 |
+
if position_ids is None:
|
326 |
+
position_ids = cache_position.unsqueeze(0)
|
327 |
+
|
328 |
+
causal_mask = self._update_causal_mask(
|
329 |
+
attention_mask, inputs_embeds, cache_position, past_key_values, output_attentions
|
330 |
+
)
|
331 |
+
|
332 |
+
hidden_states = inputs_embeds
|
333 |
+
|
334 |
+
# create position embeddings to be shared across the decoder layers
|
335 |
+
position_embeddings = self.rotary_emb(hidden_states, position_ids)
|
336 |
+
|
337 |
+
# decoder layers
|
338 |
+
all_hidden_states = () if output_hidden_states else None
|
339 |
+
all_self_attns = () if output_attentions else None
|
340 |
+
|
341 |
+
for decoder_layer in self.layers[: self.config.num_hidden_layers]:
|
342 |
+
if output_hidden_states:
|
343 |
+
all_hidden_states += (hidden_states,)
|
344 |
+
|
345 |
+
if self.gradient_checkpointing and self.training:
|
346 |
+
layer_outputs = self._gradient_checkpointing_func(
|
347 |
+
decoder_layer.__call__,
|
348 |
+
hidden_states,
|
349 |
+
causal_mask,
|
350 |
+
position_ids,
|
351 |
+
past_key_values,
|
352 |
+
output_attentions,
|
353 |
+
use_cache,
|
354 |
+
cache_position,
|
355 |
+
position_embeddings,
|
356 |
+
)
|
357 |
+
else:
|
358 |
+
layer_outputs = decoder_layer(
|
359 |
+
hidden_states,
|
360 |
+
attention_mask=causal_mask,
|
361 |
+
position_ids=position_ids,
|
362 |
+
past_key_value=past_key_values,
|
363 |
+
output_attentions=output_attentions,
|
364 |
+
use_cache=use_cache,
|
365 |
+
cache_position=cache_position,
|
366 |
+
position_embeddings=position_embeddings,
|
367 |
+
**flash_attn_kwargs,
|
368 |
+
)
|
369 |
+
|
370 |
+
hidden_states = layer_outputs[0]
|
371 |
+
|
372 |
+
if output_attentions:
|
373 |
+
all_self_attns += (layer_outputs[1],)
|
374 |
+
|
375 |
+
hidden_states = self.norm(hidden_states)
|
376 |
+
|
377 |
+
# add hidden states from the last decoder layer
|
378 |
+
if output_hidden_states:
|
379 |
+
all_hidden_states += (hidden_states,)
|
380 |
+
|
381 |
+
output = BaseModelOutputWithPast(
|
382 |
+
last_hidden_state=hidden_states,
|
383 |
+
past_key_values=past_key_values if use_cache else None,
|
384 |
+
hidden_states=all_hidden_states,
|
385 |
+
attentions=all_self_attns,
|
386 |
+
)
|
387 |
+
return output if return_dict else output.to_tuple()
|
388 |
+
|
389 |
+
def _update_causal_mask(
|
390 |
+
self,
|
391 |
+
attention_mask: torch.Tensor,
|
392 |
+
input_tensor: torch.Tensor,
|
393 |
+
cache_position: torch.Tensor,
|
394 |
+
past_key_values: Cache,
|
395 |
+
output_attentions: bool,
|
396 |
+
):
|
397 |
+
if self.config._attn_implementation == "flash_attention_2":
|
398 |
+
if attention_mask is not None and (attention_mask == 0.0).any():
|
399 |
+
return attention_mask
|
400 |
+
return None
|
401 |
+
|
402 |
+
# For SDPA, when possible, we will rely on its `is_causal` argument instead of its `attn_mask` argument, in
|
403 |
+
# order to dispatch on Flash Attention 2. This feature is not compatible with static cache, as SDPA will fail
|
404 |
+
# to infer the attention mask.
|
405 |
+
past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
|
406 |
+
using_static_cache = isinstance(past_key_values, StaticCache)
|
407 |
+
|
408 |
+
# When output attentions is True, sdpa implementation's forward method calls the eager implementation's forward
|
409 |
+
if self.config._attn_implementation == "sdpa" and not using_static_cache and not output_attentions:
|
410 |
+
if AttentionMaskConverter._ignore_causal_mask_sdpa(
|
411 |
+
attention_mask,
|
412 |
+
inputs_embeds=input_tensor,
|
413 |
+
past_key_values_length=past_seen_tokens,
|
414 |
+
is_training=self.training,
|
415 |
+
):
|
416 |
+
return None
|
417 |
+
|
418 |
+
dtype, device = input_tensor.dtype, input_tensor.device
|
419 |
+
sequence_length = input_tensor.shape[1]
|
420 |
+
if using_static_cache:
|
421 |
+
target_length = past_key_values.get_max_cache_shape()
|
422 |
+
else:
|
423 |
+
target_length = (
|
424 |
+
attention_mask.shape[-1]
|
425 |
+
if isinstance(attention_mask, torch.Tensor)
|
426 |
+
else past_seen_tokens + sequence_length + 1
|
427 |
+
)
|
428 |
+
|
429 |
+
# In case the provided `attention` mask is 2D, we generate a causal mask here (4D).
|
430 |
+
causal_mask = self._prepare_4d_causal_attention_mask_with_cache_position(
|
431 |
+
attention_mask,
|
432 |
+
sequence_length=sequence_length,
|
433 |
+
target_length=target_length,
|
434 |
+
dtype=dtype,
|
435 |
+
device=device,
|
436 |
+
cache_position=cache_position,
|
437 |
+
batch_size=input_tensor.shape[0],
|
438 |
+
)
|
439 |
+
|
440 |
+
if (
|
441 |
+
self.config._attn_implementation == "sdpa"
|
442 |
+
and attention_mask is not None
|
443 |
+
and attention_mask.device.type == "cuda"
|
444 |
+
and not output_attentions
|
445 |
+
):
|
446 |
+
# Attend to all tokens in fully masked rows in the causal_mask, for example the relevant first rows when
|
447 |
+
# using left padding. This is required by F.scaled_dot_product_attention memory-efficient attention path.
|
448 |
+
# Details: https://github.com/pytorch/pytorch/issues/110213
|
449 |
+
min_dtype = torch.finfo(dtype).min
|
450 |
+
causal_mask = AttentionMaskConverter._unmask_unattended(causal_mask, min_dtype)
|
451 |
+
|
452 |
+
return causal_mask
|
453 |
+
|
454 |
+
@staticmethod
|
455 |
+
def _prepare_4d_causal_attention_mask_with_cache_position(
|
456 |
+
attention_mask: torch.Tensor,
|
457 |
+
sequence_length: int,
|
458 |
+
target_length: int,
|
459 |
+
dtype: torch.dtype,
|
460 |
+
device: torch.device,
|
461 |
+
cache_position: torch.Tensor,
|
462 |
+
batch_size: int,
|
463 |
+
**kwargs,
|
464 |
+
):
|
465 |
+
"""
|
466 |
+
Creates a causal 4D mask of shape `(batch_size, 1, query_length, key_value_length)` from a 2D mask of shape
|
467 |
+
`(batch_size, key_value_length)`, or if the input `attention_mask` is already 4D, do nothing.
|
468 |
+
|
469 |
+
Args:
|
470 |
+
attention_mask (`torch.Tensor`):
|
471 |
+
A 2D attention mask of shape `(batch_size, key_value_length)` or a 4D attention mask of shape
|
472 |
+
`(batch_size, 1, query_length, key_value_length)`.
|
473 |
+
sequence_length (`int`):
|
474 |
+
The sequence length being processed.
|
475 |
+
target_length (`int`):
|
476 |
+
The target length: when generating with static cache, the mask should be as long as the static cache,
|
477 |
+
to account for the 0 padding, the part of the cache that is not filled yet.
|
478 |
+
dtype (`torch.dtype`):
|
479 |
+
The dtype to use for the 4D attention mask.
|
480 |
+
device (`torch.device`):
|
481 |
+
The device to plcae the 4D attention mask on.
|
482 |
+
cache_position (`torch.Tensor`):
|
483 |
+
Indices depicting the position of the input sequence tokens in the sequence.
|
484 |
+
batch_size (`torch.Tensor`):
|
485 |
+
Batch size.
|
486 |
+
"""
|
487 |
+
if attention_mask is not None and attention_mask.dim() == 4:
|
488 |
+
# In this case we assume that the mask comes already in inverted form and requires no inversion or slicing.
|
489 |
+
causal_mask = attention_mask
|
490 |
+
else:
|
491 |
+
min_dtype = torch.finfo(dtype).min
|
492 |
+
causal_mask = torch.full(
|
493 |
+
(sequence_length, target_length), fill_value=min_dtype, dtype=dtype, device=device
|
494 |
+
)
|
495 |
+
if sequence_length != 1:
|
496 |
+
causal_mask = torch.triu(causal_mask, diagonal=1)
|
497 |
+
causal_mask *= torch.arange(target_length, device=device) > cache_position.reshape(-1, 1)
|
498 |
+
causal_mask = causal_mask[None, None, :, :].expand(batch_size, 1, -1, -1)
|
499 |
+
if attention_mask is not None:
|
500 |
+
causal_mask = causal_mask.clone() # copy to contiguous memory for in-place edit
|
501 |
+
mask_length = attention_mask.shape[-1]
|
502 |
+
padding_mask = causal_mask[:, :, :, :mask_length] + attention_mask[:, None, None, :]
|
503 |
+
padding_mask = padding_mask == 0
|
504 |
+
causal_mask[:, :, :, :mask_length] = causal_mask[:, :, :, :mask_length].masked_fill(
|
505 |
+
padding_mask, min_dtype
|
506 |
+
)
|
507 |
+
|
508 |
+
return causal_mask
|
509 |
+
|
510 |
+
|
511 |
+
class KwargsForCausalLM(FlashAttentionKwargs, LossKwargs): ...
|
512 |
+
|
513 |
+
class RwkvHybridForCausalLM(RwkvHybridPreTrainedModel, GenerationMixin):
|
514 |
+
_tied_weights_keys = ["lm_head.weight"]
|
515 |
+
_tp_plan = {"lm_head": "colwise_rep"}
|
516 |
+
|
517 |
+
def __init__(self, config):
|
518 |
+
super().__init__(config)
|
519 |
+
self.model = RwkvHybridModel(config)
|
520 |
+
self.vocab_size = config.vocab_size
|
521 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
522 |
+
|
523 |
+
# Initialize weights and apply final processing
|
524 |
+
self.post_init()
|
525 |
+
|
526 |
+
def get_input_embeddings(self):
|
527 |
+
return self.model.embed_tokens
|
528 |
+
|
529 |
+
def set_input_embeddings(self, value):
|
530 |
+
self.model.embed_tokens = value
|
531 |
+
|
532 |
+
def get_output_embeddings(self):
|
533 |
+
return self.lm_head
|
534 |
+
|
535 |
+
def set_output_embeddings(self, new_embeddings):
|
536 |
+
self.lm_head = new_embeddings
|
537 |
+
|
538 |
+
def set_decoder(self, decoder):
|
539 |
+
self.model = decoder
|
540 |
+
|
541 |
+
def get_decoder(self):
|
542 |
+
return self.model
|
543 |
+
|
544 |
+
# @add_start_docstrings_to_model_forward(QWEN2_INPUTS_DOCSTRING)
|
545 |
+
# @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
|
546 |
+
def forward(
|
547 |
+
self,
|
548 |
+
input_ids: torch.LongTensor = None,
|
549 |
+
attention_mask: Optional[torch.Tensor] = None,
|
550 |
+
position_ids: Optional[torch.LongTensor] = None,
|
551 |
+
past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
|
552 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
553 |
+
labels: Optional[torch.LongTensor] = None,
|
554 |
+
use_cache: Optional[bool] = None,
|
555 |
+
output_attentions: Optional[bool] = None,
|
556 |
+
output_hidden_states: Optional[bool] = None,
|
557 |
+
return_dict: Optional[bool] = None,
|
558 |
+
cache_position: Optional[torch.LongTensor] = None,
|
559 |
+
num_logits_to_keep: int = 0,
|
560 |
+
**kwargs: Unpack[KwargsForCausalLM],
|
561 |
+
) -> Union[Tuple, CausalLMOutputWithPast]:
|
562 |
+
r"""
|
563 |
+
Args:
|
564 |
+
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
565 |
+
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
|
566 |
+
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
|
567 |
+
(masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
|
568 |
+
|
569 |
+
num_logits_to_keep (`int`, *optional*):
|
570 |
+
Calculate logits for the last `num_logits_to_keep` tokens. If `0`, calculate logits for all
|
571 |
+
`input_ids` (special case). Only last token logits are needed for generation, and calculating them only for that
|
572 |
+
token can save memory, which becomes pretty significant for long sequences or large vocabulary size.
|
573 |
+
|
574 |
+
Returns:
|
575 |
+
|
576 |
+
Example:
|
577 |
+
|
578 |
+
```python
|
579 |
+
>>> from transformers import AutoTokenizer, RwkvHybridForCausalLM
|
580 |
+
|
581 |
+
>>> model = Qwen2ForCausalLM.from_pretrained("RWKV-Red-Team/ARWKV-7B-Preview-0.1")
|
582 |
+
>>> tokenizer = AutoTokenizer.from_pretrained("RWKV-Red-Team/ARWKV-7B-Preview-0.1")
|
583 |
+
|
584 |
+
>>> prompt = "Hey, are you conscious? Can you talk to me?"
|
585 |
+
>>> inputs = tokenizer(prompt, return_tensors="pt")
|
586 |
+
|
587 |
+
>>> # Generate
|
588 |
+
>>> generate_ids = model.generate(inputs.input_ids, max_length=30)
|
589 |
+
>>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
590 |
+
"Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
|
591 |
+
```"""
|
592 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
593 |
+
output_hidden_states = (
|
594 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
595 |
+
)
|
596 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
597 |
+
|
598 |
+
# decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
|
599 |
+
outputs = self.model(
|
600 |
+
input_ids=input_ids,
|
601 |
+
attention_mask=attention_mask,
|
602 |
+
position_ids=position_ids,
|
603 |
+
past_key_values=past_key_values,
|
604 |
+
inputs_embeds=inputs_embeds,
|
605 |
+
use_cache=use_cache,
|
606 |
+
output_attentions=output_attentions,
|
607 |
+
output_hidden_states=output_hidden_states,
|
608 |
+
return_dict=return_dict,
|
609 |
+
cache_position=cache_position,
|
610 |
+
**kwargs,
|
611 |
+
)
|
612 |
+
|
613 |
+
hidden_states = outputs[0]
|
614 |
+
# Only compute necessary logits, and do not upcast them to float if we are not computing the loss
|
615 |
+
logits = self.lm_head(hidden_states[:, -num_logits_to_keep:, :])
|
616 |
+
|
617 |
+
loss = None
|
618 |
+
if labels is not None:
|
619 |
+
loss = self.loss_function(logits=logits, labels=labels, vocab_size=self.config.vocab_size, **kwargs)
|
620 |
+
|
621 |
+
if not return_dict:
|
622 |
+
output = (logits,) + outputs[1:]
|
623 |
+
return (loss,) + output if loss is not None else output
|
624 |
+
|
625 |
+
return CausalLMOutputWithPast(
|
626 |
+
loss=loss,
|
627 |
+
logits=logits,
|
628 |
+
past_key_values=outputs.past_key_values,
|
629 |
+
hidden_states=outputs.hidden_states,
|
630 |
+
attentions=outputs.attentions,
|
631 |
+
)
|
632 |
+
|
test_gradio.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
4 |
+
from transformers import TextIteratorStreamer
|
5 |
+
import threading
|
6 |
+
|
7 |
+
|
8 |
+
model = AutoModelForCausalLM.from_pretrained(
|
9 |
+
"RWKV-Red-Team/ARWKV-7B-Preview-0.1",
|
10 |
+
device_map="auto",
|
11 |
+
torch_dtype=torch.float16,
|
12 |
+
trust_remote_code=True,
|
13 |
+
)
|
14 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
15 |
+
"RWKV-Red-Team/ARWKV-7B-Preview-0.1"
|
16 |
+
)
|
17 |
+
device = "cuda"
|
18 |
+
|
19 |
+
|
20 |
+
def convert_history_to_messages(history):
|
21 |
+
messages = []
|
22 |
+
for user_msg, bot_msg in history:
|
23 |
+
messages.append({"role": "user", "content": user_msg})
|
24 |
+
if bot_msg is not None:
|
25 |
+
messages.append({"role": "assistant", "content": bot_msg})
|
26 |
+
return messages
|
27 |
+
|
28 |
+
|
29 |
+
def stream_chat(prompt, history):
|
30 |
+
|
31 |
+
messages = convert_history_to_messages(history)
|
32 |
+
messages.append({"role": "user", "content": prompt})
|
33 |
+
|
34 |
+
text = tokenizer.apply_chat_template(
|
35 |
+
messages, tokenize=False, add_generation_prompt=True
|
36 |
+
)
|
37 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
|
38 |
+
|
39 |
+
streamer = TextIteratorStreamer(
|
40 |
+
tokenizer, skip_prompt=True, skip_special_tokens=True
|
41 |
+
)
|
42 |
+
|
43 |
+
generation_kwargs = dict(
|
44 |
+
model_inputs,
|
45 |
+
streamer=streamer,
|
46 |
+
max_new_tokens=4096,
|
47 |
+
do_sample=True,
|
48 |
+
temperature=1.5,
|
49 |
+
top_p=0.2,
|
50 |
+
top_k=0,
|
51 |
+
)
|
52 |
+
thread = threading.Thread(target=model.generate, kwargs=generation_kwargs)
|
53 |
+
thread.start()
|
54 |
+
|
55 |
+
response = ""
|
56 |
+
for new_text in streamer:
|
57 |
+
response += new_text
|
58 |
+
yield history + [(prompt, response)]
|
59 |
+
|
60 |
+
|
61 |
+
with gr.Blocks() as demo:
|
62 |
+
chatbot = gr.Chatbot(label="Chat with LLM", height=750)
|
63 |
+
msg = gr.Textbox(label="Your Message")
|
64 |
+
clear = gr.Button("Clear Chat")
|
65 |
+
|
66 |
+
def user(user_message, history):
|
67 |
+
return "", history + [[user_message, None]]
|
68 |
+
|
69 |
+
def bot(history):
|
70 |
+
prompt = history[-1][0]
|
71 |
+
history[-1][1] = ""
|
72 |
+
for updated_history in stream_chat(prompt, history[:-1]):
|
73 |
+
yield updated_history
|
74 |
+
|
75 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
76 |
+
bot, chatbot, chatbot
|
77 |
+
)
|
78 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
79 |
+
|
80 |
+
demo.queue().launch(server_name="0.0.0.0")
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": false,
|
3 |
+
"add_prefix_space": false,
|
4 |
+
"added_tokens_decoder": {
|
5 |
+
"151643": {
|
6 |
+
"content": "<|endoftext|>",
|
7 |
+
"lstrip": false,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false,
|
11 |
+
"special": true
|
12 |
+
},
|
13 |
+
"151644": {
|
14 |
+
"content": "<|im_start|>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": false,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false,
|
19 |
+
"special": true
|
20 |
+
},
|
21 |
+
"151645": {
|
22 |
+
"content": "<|im_end|>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": false,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false,
|
27 |
+
"special": true
|
28 |
+
},
|
29 |
+
"151646": {
|
30 |
+
"content": "<|object_ref_start|>",
|
31 |
+
"lstrip": false,
|
32 |
+
"normalized": false,
|
33 |
+
"rstrip": false,
|
34 |
+
"single_word": false,
|
35 |
+
"special": true
|
36 |
+
},
|
37 |
+
"151647": {
|
38 |
+
"content": "<|object_ref_end|>",
|
39 |
+
"lstrip": false,
|
40 |
+
"normalized": false,
|
41 |
+
"rstrip": false,
|
42 |
+
"single_word": false,
|
43 |
+
"special": true
|
44 |
+
},
|
45 |
+
"151648": {
|
46 |
+
"content": "<|box_start|>",
|
47 |
+
"lstrip": false,
|
48 |
+
"normalized": false,
|
49 |
+
"rstrip": false,
|
50 |
+
"single_word": false,
|
51 |
+
"special": true
|
52 |
+
},
|
53 |
+
"151649": {
|
54 |
+
"content": "<|box_end|>",
|
55 |
+
"lstrip": false,
|
56 |
+
"normalized": false,
|
57 |
+
"rstrip": false,
|
58 |
+
"single_word": false,
|
59 |
+
"special": true
|
60 |
+
},
|
61 |
+
"151650": {
|
62 |
+
"content": "<|quad_start|>",
|
63 |
+
"lstrip": false,
|
64 |
+
"normalized": false,
|
65 |
+
"rstrip": false,
|
66 |
+
"single_word": false,
|
67 |
+
"special": true
|
68 |
+
},
|
69 |
+
"151651": {
|
70 |
+
"content": "<|quad_end|>",
|
71 |
+
"lstrip": false,
|
72 |
+
"normalized": false,
|
73 |
+
"rstrip": false,
|
74 |
+
"single_word": false,
|
75 |
+
"special": true
|
76 |
+
},
|
77 |
+
"151652": {
|
78 |
+
"content": "<|vision_start|>",
|
79 |
+
"lstrip": false,
|
80 |
+
"normalized": false,
|
81 |
+
"rstrip": false,
|
82 |
+
"single_word": false,
|
83 |
+
"special": true
|
84 |
+
},
|
85 |
+
"151653": {
|
86 |
+
"content": "<|vision_end|>",
|
87 |
+
"lstrip": false,
|
88 |
+
"normalized": false,
|
89 |
+
"rstrip": false,
|
90 |
+
"single_word": false,
|
91 |
+
"special": true
|
92 |
+
},
|
93 |
+
"151654": {
|
94 |
+
"content": "<|vision_pad|>",
|
95 |
+
"lstrip": false,
|
96 |
+
"normalized": false,
|
97 |
+
"rstrip": false,
|
98 |
+
"single_word": false,
|
99 |
+
"special": true
|
100 |
+
},
|
101 |
+
"151655": {
|
102 |
+
"content": "<|image_pad|>",
|
103 |
+
"lstrip": false,
|
104 |
+
"normalized": false,
|
105 |
+
"rstrip": false,
|
106 |
+
"single_word": false,
|
107 |
+
"special": true
|
108 |
+
},
|
109 |
+
"151656": {
|
110 |
+
"content": "<|video_pad|>",
|
111 |
+
"lstrip": false,
|
112 |
+
"normalized": false,
|
113 |
+
"rstrip": false,
|
114 |
+
"single_word": false,
|
115 |
+
"special": true
|
116 |
+
},
|
117 |
+
"151657": {
|
118 |
+
"content": "<tool_call>",
|
119 |
+
"lstrip": false,
|
120 |
+
"normalized": false,
|
121 |
+
"rstrip": false,
|
122 |
+
"single_word": false,
|
123 |
+
"special": false
|
124 |
+
},
|
125 |
+
"151658": {
|
126 |
+
"content": "</tool_call>",
|
127 |
+
"lstrip": false,
|
128 |
+
"normalized": false,
|
129 |
+
"rstrip": false,
|
130 |
+
"single_word": false,
|
131 |
+
"special": false
|
132 |
+
},
|
133 |
+
"151659": {
|
134 |
+
"content": "<|fim_prefix|>",
|
135 |
+
"lstrip": false,
|
136 |
+
"normalized": false,
|
137 |
+
"rstrip": false,
|
138 |
+
"single_word": false,
|
139 |
+
"special": false
|
140 |
+
},
|
141 |
+
"151660": {
|
142 |
+
"content": "<|fim_middle|>",
|
143 |
+
"lstrip": false,
|
144 |
+
"normalized": false,
|
145 |
+
"rstrip": false,
|
146 |
+
"single_word": false,
|
147 |
+
"special": false
|
148 |
+
},
|
149 |
+
"151661": {
|
150 |
+
"content": "<|fim_suffix|>",
|
151 |
+
"lstrip": false,
|
152 |
+
"normalized": false,
|
153 |
+
"rstrip": false,
|
154 |
+
"single_word": false,
|
155 |
+
"special": false
|
156 |
+
},
|
157 |
+
"151662": {
|
158 |
+
"content": "<|fim_pad|>",
|
159 |
+
"lstrip": false,
|
160 |
+
"normalized": false,
|
161 |
+
"rstrip": false,
|
162 |
+
"single_word": false,
|
163 |
+
"special": false
|
164 |
+
},
|
165 |
+
"151663": {
|
166 |
+
"content": "<|repo_name|>",
|
167 |
+
"lstrip": false,
|
168 |
+
"normalized": false,
|
169 |
+
"rstrip": false,
|
170 |
+
"single_word": false,
|
171 |
+
"special": false
|
172 |
+
},
|
173 |
+
"151664": {
|
174 |
+
"content": "<|file_sep|>",
|
175 |
+
"lstrip": false,
|
176 |
+
"normalized": false,
|
177 |
+
"rstrip": false,
|
178 |
+
"single_word": false,
|
179 |
+
"special": false
|
180 |
+
}
|
181 |
+
},
|
182 |
+
"additional_special_tokens": [
|
183 |
+
"<|im_start|>",
|
184 |
+
"<|im_end|>",
|
185 |
+
"<|object_ref_start|>",
|
186 |
+
"<|object_ref_end|>",
|
187 |
+
"<|box_start|>",
|
188 |
+
"<|box_end|>",
|
189 |
+
"<|quad_start|>",
|
190 |
+
"<|quad_end|>",
|
191 |
+
"<|vision_start|>",
|
192 |
+
"<|vision_end|>",
|
193 |
+
"<|vision_pad|>",
|
194 |
+
"<|image_pad|>",
|
195 |
+
"<|video_pad|>"
|
196 |
+
],
|
197 |
+
"bos_token": null,
|
198 |
+
"chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0]['role'] == 'system' %}\n {{- messages[0]['content'] }}\n {%- else %}\n {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}\n {%- endif %}\n {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0]['role'] == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + message.content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n",
|
199 |
+
"clean_up_tokenization_spaces": false,
|
200 |
+
"eos_token": "<|im_end|>",
|
201 |
+
"errors": "replace",
|
202 |
+
"model_max_length": 131072,
|
203 |
+
"pad_token": "<|endoftext|>",
|
204 |
+
"split_special_tokens": false,
|
205 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
206 |
+
"unk_token": null
|
207 |
+
}
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
wkv.py
ADDED
@@ -0,0 +1,522 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from einops import rearrange
|
3 |
+
|
4 |
+
from .hybrid_cache import TimeMixState, BlockState
|
5 |
+
import math
|
6 |
+
import torch.nn as nn
|
7 |
+
from torch.nn import functional as F
|
8 |
+
from .configuration_rwkv_hybrid import RwkvHybridConfig
|
9 |
+
|
10 |
+
try:
|
11 |
+
import triton
|
12 |
+
from rwkvfla.ops.rwkv7 import (
|
13 |
+
fused_recurrent_rwkv7,
|
14 |
+
chunk_rwkv7,
|
15 |
+
native_recurrent_rwkv7,
|
16 |
+
) # pylint: disable=C0411
|
17 |
+
from rwkvfla.ops.rwkv6 import (
|
18 |
+
fused_recurrent_rwkv6,
|
19 |
+
chunk_rwkv6,
|
20 |
+
native_recurrent_rwkv6,
|
21 |
+
)
|
22 |
+
except ImportError:
|
23 |
+
from rwkvfla.ops.rwkv7 import native_recurrent_rwkv7 # pylint: disable=C0411
|
24 |
+
from rwkvfla.ops.rwkv6 import native_recurrent_rwkv6
|
25 |
+
|
26 |
+
fused_recurrent_rwkv7 = native_recurrent_rwkv7
|
27 |
+
chunk_rwkv7 = native_recurrent_rwkv7
|
28 |
+
chunk_rwkv6 = native_recurrent_rwkv6
|
29 |
+
fused_recurrent_rwkv6 = native_recurrent_rwkv6
|
30 |
+
|
31 |
+
|
32 |
+
class Rwkv_Tmix_x070(nn.Module):
|
33 |
+
def __init__(self, args: RwkvHybridConfig, layer_id, update_v_first, get_v_first):
|
34 |
+
super().__init__()
|
35 |
+
self.args = args
|
36 |
+
self.layer_id = layer_id
|
37 |
+
self.hidden_size = args.hidden_size
|
38 |
+
|
39 |
+
self.update_v_first = update_v_first
|
40 |
+
self.get_v_first = get_v_first
|
41 |
+
|
42 |
+
self.head_size = args.head_size
|
43 |
+
self.n_head = args.num_wkv_heads
|
44 |
+
assert args.hidden_size % self.n_head == 0
|
45 |
+
H = self.n_head
|
46 |
+
N = self.head_size
|
47 |
+
|
48 |
+
self.x_r = nn.Parameter(torch.Tensor(1, 1, args.hidden_size))
|
49 |
+
self.x_w = nn.Parameter(torch.Tensor(1, 1, args.hidden_size))
|
50 |
+
self.x_k = nn.Parameter(torch.Tensor(1, 1, args.hidden_size))
|
51 |
+
self.x_v = nn.Parameter(torch.Tensor(1, 1, args.hidden_size))
|
52 |
+
self.x_a = nn.Parameter(torch.Tensor(1, 1, args.hidden_size))
|
53 |
+
self.x_g = nn.Parameter(torch.Tensor(1, 1, args.hidden_size))
|
54 |
+
|
55 |
+
D_DECAY_LORA = 64
|
56 |
+
D_AAA_LORA = 64
|
57 |
+
D_MV_LORA = 32
|
58 |
+
D_GATE_LORA = 128
|
59 |
+
|
60 |
+
self.w1 = nn.Parameter(torch.Tensor(args.hidden_size, D_DECAY_LORA))
|
61 |
+
self.w2 = nn.Parameter(torch.Tensor(D_DECAY_LORA, args.hidden_size))
|
62 |
+
self.w0 = nn.Parameter(torch.Tensor(1, 1, args.hidden_size))
|
63 |
+
|
64 |
+
self.a1 = nn.Parameter(torch.Tensor(args.hidden_size, D_AAA_LORA))
|
65 |
+
self.a2 = nn.Parameter(torch.Tensor(D_AAA_LORA, args.hidden_size))
|
66 |
+
self.a0 = nn.Parameter(torch.Tensor(1, 1, args.hidden_size))
|
67 |
+
|
68 |
+
self.v1 = nn.Parameter(torch.Tensor(args.hidden_size, D_MV_LORA))
|
69 |
+
self.v2 = nn.Parameter(torch.Tensor(D_MV_LORA, args.hidden_size))
|
70 |
+
self.v0 = nn.Parameter(torch.Tensor(1, 1, args.hidden_size))
|
71 |
+
|
72 |
+
if self.args.wkv_has_gate:
|
73 |
+
self.g1 = nn.Parameter(torch.Tensor(args.hidden_size, D_GATE_LORA))
|
74 |
+
self.g2 = nn.Parameter(torch.Tensor(D_GATE_LORA, args.hidden_size))
|
75 |
+
|
76 |
+
self.k_k = nn.Parameter(torch.Tensor(1, 1, args.hidden_size))
|
77 |
+
self.k_a = nn.Parameter(torch.Tensor(1, 1, args.hidden_size))
|
78 |
+
self.r_k = nn.Parameter(torch.Tensor(H, N))
|
79 |
+
|
80 |
+
self.time_shift = nn.ZeroPad2d((0, 0, 1, -1))
|
81 |
+
self.receptance = nn.Linear(args.hidden_size, args.hidden_size, bias=False)
|
82 |
+
self.key = nn.Linear(args.hidden_size, args.hidden_size, bias=False)
|
83 |
+
self.value = nn.Linear(args.hidden_size, args.hidden_size, bias=False)
|
84 |
+
self.output = nn.Linear(args.hidden_size, args.hidden_size, bias=False)
|
85 |
+
|
86 |
+
if self.args.wkv_has_group_norm:
|
87 |
+
self.ln_x = nn.GroupNorm(
|
88 |
+
H, args.hidden_size, eps=(1e-5) * (args.head_size_divisor**2)
|
89 |
+
)
|
90 |
+
|
91 |
+
def post_init(self):
|
92 |
+
with torch.no_grad():
|
93 |
+
ratio_0_to_1 = self.layer_id / (self.args.num_hidden_layers - 1) # 0 to 1
|
94 |
+
ratio_1_to_almost0 = 1.0 - (
|
95 |
+
self.layer_id / self.args.num_hidden_layers
|
96 |
+
) # 1 to ~0
|
97 |
+
|
98 |
+
ddd = torch.ones(1, 1, self.args.hidden_size)
|
99 |
+
for i in range(self.args.hidden_size):
|
100 |
+
ddd[0, 0, i] = i / self.args.hidden_size
|
101 |
+
|
102 |
+
nn.init.constant_(self.x_r, 1.0 - torch.pow(ddd, 0.2 * ratio_1_to_almost0))
|
103 |
+
nn.init.constant_(self.x_w, 1.0 - torch.pow(ddd, 0.9 * ratio_1_to_almost0))
|
104 |
+
nn.init.constant_(
|
105 |
+
self.x_k,
|
106 |
+
1.0 - (torch.pow(ddd, 0.9 * ratio_1_to_almost0) + 0.4 * ratio_0_to_1),
|
107 |
+
)
|
108 |
+
nn.init.constant_(
|
109 |
+
self.x_v,
|
110 |
+
1.0 - (torch.pow(ddd, 0.4 * ratio_1_to_almost0) + 0.6 * ratio_0_to_1),
|
111 |
+
)
|
112 |
+
nn.init.constant_(self.x_a, 1.0 - torch.pow(ddd, 0.9 * ratio_1_to_almost0))
|
113 |
+
nn.init.constant_(self.x_g, 1.0 - torch.pow(ddd, 0.2 * ratio_1_to_almost0))
|
114 |
+
|
115 |
+
def ortho_init(x, scale):
|
116 |
+
shape = x.shape
|
117 |
+
original_dtype = x.dtype
|
118 |
+
x_fp32 = x.float()
|
119 |
+
if len(shape) == 2:
|
120 |
+
gain = math.sqrt(shape[0] / shape[1]) if shape[0] > shape[1] else 1
|
121 |
+
nn.init.orthogonal_(x_fp32, gain=gain * scale)
|
122 |
+
elif len(shape) == 3:
|
123 |
+
gain = math.sqrt(shape[1] / shape[2]) if shape[1] > shape[2] else 1
|
124 |
+
for i in range(shape[0]):
|
125 |
+
nn.init.orthogonal_(x_fp32[i], gain=gain * scale)
|
126 |
+
else:
|
127 |
+
raise ValueError("ortho_init only supports 2D or 3D tensors")
|
128 |
+
x.data.copy_(x_fp32.to(original_dtype))
|
129 |
+
return x
|
130 |
+
|
131 |
+
D_DECAY_LORA = 64
|
132 |
+
nn.init.zeros_(self.w1)
|
133 |
+
self.w2 = nn.Parameter(
|
134 |
+
ortho_init(torch.zeros(D_DECAY_LORA, self.args.hidden_size), 0.1)
|
135 |
+
)
|
136 |
+
|
137 |
+
decay_speed = torch.ones(self.args.hidden_size)
|
138 |
+
for n in range(self.args.hidden_size):
|
139 |
+
decay_speed[n] = -7 + 5 * (n / (self.args.hidden_size - 1)) ** (
|
140 |
+
0.85 + 1.0 * ratio_0_to_1**0.5
|
141 |
+
)
|
142 |
+
nn.init.constant_(
|
143 |
+
self.w0, decay_speed.reshape(1, 1, self.args.hidden_size) + 0.5
|
144 |
+
)
|
145 |
+
|
146 |
+
D_AAA_LORA = 64
|
147 |
+
nn.init.zeros_(self.a1)
|
148 |
+
self.a2 = nn.Parameter(
|
149 |
+
ortho_init(torch.zeros(D_AAA_LORA, self.args.hidden_size), 0.1)
|
150 |
+
)
|
151 |
+
nn.init.zeros_(self.a0)
|
152 |
+
|
153 |
+
D_MV_LORA = 32
|
154 |
+
nn.init.zeros_(self.v1)
|
155 |
+
self.v2 = nn.Parameter(
|
156 |
+
ortho_init(torch.zeros(D_MV_LORA, self.args.hidden_size), 0.1)
|
157 |
+
)
|
158 |
+
nn.init.constant_(self.v0, 1.0)
|
159 |
+
|
160 |
+
D_GATE_LORA = 128
|
161 |
+
if self.args.wkv_has_gate:
|
162 |
+
nn.init.zeros_(self.g1)
|
163 |
+
self.g2 = nn.Parameter(
|
164 |
+
ortho_init(torch.zeros(D_GATE_LORA, self.args.hidden_size), 0.1)
|
165 |
+
)
|
166 |
+
|
167 |
+
nn.init.constant_(self.k_k, 0.85)
|
168 |
+
nn.init.constant_(self.k_a, 1.0)
|
169 |
+
nn.init.zeros_(self.r_k)
|
170 |
+
|
171 |
+
nn.init.zeros_(self.receptance.weight)
|
172 |
+
nn.init.zeros_(self.key.weight)
|
173 |
+
nn.init.zeros_(self.value.weight)
|
174 |
+
nn.init.zeros_(self.output.weight)
|
175 |
+
|
176 |
+
if self.args.wkv_has_group_norm:
|
177 |
+
nn.init.ones_(self.ln_x.weight)
|
178 |
+
nn.init.zeros_(self.ln_x.bias)
|
179 |
+
|
180 |
+
def apply_wkv7_state(self, r, k, v, w, a, b, s):
|
181 |
+
r = rearrange(r, "b l (h d) -> b h l d", h=self.n_head)
|
182 |
+
k = rearrange(k, "b l (h d) -> b h l d", h=self.n_head)
|
183 |
+
v = rearrange(v, "b l (h d) -> b h l d", h=self.n_head)
|
184 |
+
w = rearrange(w, "b l (h d) -> b h l d", h=self.n_head)
|
185 |
+
a = rearrange(a, "b l (h d) -> b h l d", h=self.n_head)
|
186 |
+
b = rearrange(b, "b l (h d) -> b h l d", h=self.n_head)
|
187 |
+
|
188 |
+
if r.device.type == "cpu":
|
189 |
+
o, state = native_recurrent_rwkv7(
|
190 |
+
r,
|
191 |
+
k,
|
192 |
+
v,
|
193 |
+
w,
|
194 |
+
a,
|
195 |
+
b,
|
196 |
+
scale=1.0,
|
197 |
+
initial_state=s.transpose(-1, -2),
|
198 |
+
output_final_state=True,
|
199 |
+
use_log_w=False,
|
200 |
+
head_first=True,
|
201 |
+
)
|
202 |
+
state = state.transpose(-1, -2)
|
203 |
+
elif self.training:
|
204 |
+
o, state = chunk_rwkv7(
|
205 |
+
r,
|
206 |
+
k,
|
207 |
+
v,
|
208 |
+
w,
|
209 |
+
a,
|
210 |
+
b,
|
211 |
+
scale=1.0,
|
212 |
+
initial_state=s,
|
213 |
+
output_final_state=True,
|
214 |
+
use_log_w=False,
|
215 |
+
head_first=True,
|
216 |
+
)
|
217 |
+
else:
|
218 |
+
o, state = fused_recurrent_rwkv7(
|
219 |
+
r,
|
220 |
+
k,
|
221 |
+
v,
|
222 |
+
w,
|
223 |
+
a,
|
224 |
+
b,
|
225 |
+
scale=1.0,
|
226 |
+
initial_state=s,
|
227 |
+
output_final_state=True,
|
228 |
+
use_log_w=False,
|
229 |
+
head_first=True,
|
230 |
+
)
|
231 |
+
|
232 |
+
x = rearrange(o, "b h l d -> b l (h d)")
|
233 |
+
return x, state
|
234 |
+
|
235 |
+
def forward(self, x, last_state: TimeMixState):
|
236 |
+
shift_state = last_state.shift_state
|
237 |
+
B, T, C = x.size()
|
238 |
+
H = self.n_head
|
239 |
+
if shift_state is not None:
|
240 |
+
xx = torch.concat((shift_state.unsqueeze(1), x[:, :-1]), dim=1) - x
|
241 |
+
else:
|
242 |
+
xx = self.time_shift(x) - x
|
243 |
+
lx = x[:, -1]
|
244 |
+
|
245 |
+
xr = x + xx * self.x_r
|
246 |
+
xw = x + xx * self.x_w
|
247 |
+
xk = x + xx * self.x_k
|
248 |
+
xv = x + xx * self.x_v
|
249 |
+
xa = x + xx * self.x_a
|
250 |
+
xg = x + xx * self.x_g
|
251 |
+
|
252 |
+
r = self.receptance(xr)
|
253 |
+
w = (
|
254 |
+
-F.softplus(-(self.w0 + torch.tanh(xw @ self.w1) @ self.w2)) - 0.5
|
255 |
+
) # soft-clamp to (-inf, -0.5)
|
256 |
+
k = self.key(xk)
|
257 |
+
v = self.value(xv)
|
258 |
+
if self.layer_id == 0:
|
259 |
+
self.update_v_first(v)
|
260 |
+
else:
|
261 |
+
# Original implementation
|
262 |
+
v = v + (self.get_v_first().to(v.device) - v) * torch.sigmoid(
|
263 |
+
self.v0 + (xv @ self.v1) @ self.v2
|
264 |
+
) # add value residual
|
265 |
+
|
266 |
+
a = torch.sigmoid(
|
267 |
+
self.a0 + (xa @ self.a1) @ self.a2
|
268 |
+
) # a is "in-context learning rate"
|
269 |
+
if self.args.wkv_has_gate:
|
270 |
+
g = torch.sigmoid(xg @ self.g1) @ self.g2
|
271 |
+
kk = k * self.k_k
|
272 |
+
kk = F.normalize(kk.view(B, T, H, -1), dim=-1, p=2.0).view(B, T, C)
|
273 |
+
k = k * (1 + (a - 1) * self.k_a)
|
274 |
+
|
275 |
+
wkv_state = last_state.wkv_state
|
276 |
+
x, wkv_state = self.apply_wkv7_state(
|
277 |
+
r,
|
278 |
+
k,
|
279 |
+
v,
|
280 |
+
w,
|
281 |
+
-kk,
|
282 |
+
(kk * a),
|
283 |
+
s=wkv_state,
|
284 |
+
)
|
285 |
+
if self.args.wkv_has_group_norm:
|
286 |
+
x = self.ln_x(x.view(B * T, C)).view(B, T, C)
|
287 |
+
x = x + (
|
288 |
+
(r.view(B, T, H, -1) * k.view(B, T, H, -1) * self.r_k).sum(
|
289 |
+
dim=-1, keepdim=True
|
290 |
+
)
|
291 |
+
* v.view(B, T, H, -1)
|
292 |
+
).view(B, T, C)
|
293 |
+
x = self.output(x * g) if self.args.wkv_has_gate else self.output(x)
|
294 |
+
return x, TimeMixState(lx, wkv_state)
|
295 |
+
|
296 |
+
|
297 |
+
class Rwkv7Attention(nn.Module):
|
298 |
+
def __init__(self, args: RwkvHybridConfig, layer_id, update_v_first, get_v_first):
|
299 |
+
super().__init__()
|
300 |
+
self.args = args
|
301 |
+
self.layer_idx = layer_id
|
302 |
+
self.time_mixer = Rwkv_Tmix_x070(args, layer_id, update_v_first, get_v_first)
|
303 |
+
|
304 |
+
def forward(self, hidden_states, past_key_value, **kwargs):
|
305 |
+
attn_output = hidden_states
|
306 |
+
batch_size, token_length, _ = attn_output.size()
|
307 |
+
|
308 |
+
if past_key_value is not None and len(past_key_value) > self.layer_idx:
|
309 |
+
last_state = past_key_value[self.layer_idx][0]
|
310 |
+
else:
|
311 |
+
last_state = self.init_state(
|
312 |
+
batch_size, attn_output.device, attn_output.dtype
|
313 |
+
)
|
314 |
+
|
315 |
+
attn_output, states = self.time_mixer(attn_output, last_state.time_mix_state)
|
316 |
+
last_state.time_mix_state = states
|
317 |
+
|
318 |
+
if past_key_value is not None:
|
319 |
+
past_key_value.update(token_length, last_state, self.layer_idx)
|
320 |
+
return attn_output, None
|
321 |
+
|
322 |
+
def init_state(self, batch_size, device, dtype) -> BlockState:
|
323 |
+
wkv_states = torch.zeros(
|
324 |
+
(
|
325 |
+
batch_size,
|
326 |
+
self.args.num_wkv_heads,
|
327 |
+
self.args.head_size,
|
328 |
+
self.args.head_size,
|
329 |
+
),
|
330 |
+
device=device,
|
331 |
+
dtype=torch.float32,
|
332 |
+
)
|
333 |
+
token_shift = torch.zeros(
|
334 |
+
(batch_size, self.args.hidden_size), device=device, dtype=dtype
|
335 |
+
)
|
336 |
+
return BlockState(TimeMixState(token_shift, wkv_states), None)
|
337 |
+
|
338 |
+
|
339 |
+
class Rwkv_Tmix_x060(nn.Module):
|
340 |
+
def __init__(self, args: RwkvHybridConfig, layer_id, **kwargs):
|
341 |
+
super().__init__()
|
342 |
+
self.args = args
|
343 |
+
self.layer_id = layer_id
|
344 |
+
self.hidden_size = args.hidden_size
|
345 |
+
|
346 |
+
self.head_size = args.head_size
|
347 |
+
self.n_head = args.num_wkv_heads
|
348 |
+
assert args.hidden_size % self.n_head == 0
|
349 |
+
H = self.n_head
|
350 |
+
N = self.head_size
|
351 |
+
|
352 |
+
with torch.no_grad():
|
353 |
+
ratio_0_to_1 = layer_id / (args.n_layer - 1) # 0 to 1
|
354 |
+
ratio_1_to_almost0 = 1.0 - (layer_id / args.n_layer) # 1 to ~0
|
355 |
+
ddd = torch.ones(1, 1, args.hidden_size)
|
356 |
+
for i in range(args.hidden_size):
|
357 |
+
ddd[0, 0, i] = i / args.hidden_size
|
358 |
+
|
359 |
+
# fancy time_mix
|
360 |
+
self.time_maa_x = nn.Parameter(1.0 - torch.pow(ddd, ratio_1_to_almost0))
|
361 |
+
self.time_maa_w = nn.Parameter(1.0 - torch.pow(ddd, ratio_1_to_almost0))
|
362 |
+
self.time_maa_k = nn.Parameter(1.0 - torch.pow(ddd, ratio_1_to_almost0))
|
363 |
+
self.time_maa_v = nn.Parameter(
|
364 |
+
1.0 - (torch.pow(ddd, ratio_1_to_almost0) + 0.3 * ratio_0_to_1)
|
365 |
+
)
|
366 |
+
self.time_maa_r = nn.Parameter(
|
367 |
+
1.0 - torch.pow(ddd, 0.5 * ratio_1_to_almost0)
|
368 |
+
)
|
369 |
+
self.time_maa_g = nn.Parameter(
|
370 |
+
1.0 - torch.pow(ddd, 0.5 * ratio_1_to_almost0)
|
371 |
+
)
|
372 |
+
|
373 |
+
D_MIX_LORA = 32 # generate TIME_MIX for w,k,v,r,g
|
374 |
+
if args.hidden_size == 4096:
|
375 |
+
D_MIX_LORA = D_MIX_LORA * 2
|
376 |
+
self.time_maa_w1 = nn.Parameter(
|
377 |
+
torch.zeros(args.hidden_size, D_MIX_LORA * 5)
|
378 |
+
)
|
379 |
+
self.time_maa_w2 = nn.Parameter(
|
380 |
+
torch.zeros(5, D_MIX_LORA, args.hidden_size).uniform_(-0.01, 0.01)
|
381 |
+
)
|
382 |
+
|
383 |
+
# fancy time_decay
|
384 |
+
decay_speed = torch.ones(args.head_size)
|
385 |
+
for n in range(args.head_size):
|
386 |
+
decay_speed[n] = -6 + 5 * (n / (args.head_size - 1)) ** (
|
387 |
+
0.7 + 1.3 * ratio_0_to_1
|
388 |
+
)
|
389 |
+
self.time_decay = nn.Parameter(decay_speed.reshape(1, 1, args.head_size))
|
390 |
+
|
391 |
+
D_DECAY_LORA = 64
|
392 |
+
if args.hidden_size == 4096:
|
393 |
+
D_DECAY_LORA = D_DECAY_LORA * 2
|
394 |
+
self.time_decay_w1 = nn.Parameter(
|
395 |
+
torch.zeros(args.hidden_size, D_DECAY_LORA)
|
396 |
+
)
|
397 |
+
self.time_decay_w2 = nn.Parameter(
|
398 |
+
torch.zeros(D_DECAY_LORA, args.head_size).uniform_(-0.01, 0.01)
|
399 |
+
)
|
400 |
+
|
401 |
+
tmp = torch.zeros(args.head_size)
|
402 |
+
for n in range(args.head_size):
|
403 |
+
zigzag = ((n + 1) % 3 - 1) * 0.1
|
404 |
+
tmp[n] = ratio_0_to_1 * (1 - (n / (args.head_size - 1))) + zigzag
|
405 |
+
|
406 |
+
self.time_faaaa = nn.Parameter(tmp.reshape(self.n_head, self.head_size))
|
407 |
+
# self.time_state = nn.Parameter(torch.zeros(self.n_head, self.head_size, self.head_size))
|
408 |
+
|
409 |
+
self.time_shift = nn.ZeroPad2d((0, 0, 1, -1))
|
410 |
+
self.receptance = nn.Linear(args.hidden_size, args.head_size, bias=False)
|
411 |
+
self.key = nn.Linear(args.hidden_size, args.head_size, bias=False)
|
412 |
+
|
413 |
+
self.value = nn.Linear(args.hidden_size, args.head_size, bias=False)
|
414 |
+
self.output = nn.Linear(args.head_size, args.hidden_size, bias=False)
|
415 |
+
self.gate = nn.Linear(args.hidden_size, args.head_size, bias=False)
|
416 |
+
|
417 |
+
if self.args.wkv_has_group_norm:
|
418 |
+
self.ln_x = nn.GroupNorm(
|
419 |
+
self.n_head, args.head_size, eps=(1e-5) * (args.head_size_divisor**2)
|
420 |
+
)
|
421 |
+
|
422 |
+
def post_init(self):
|
423 |
+
pass
|
424 |
+
|
425 |
+
def forward(self, x, last_state: TimeMixState):
|
426 |
+
shift_state = last_state.shift_state
|
427 |
+
B, T, C = x.size()
|
428 |
+
H = self.n_head
|
429 |
+
if shift_state is not None:
|
430 |
+
xx = torch.concat((shift_state.unsqueeze(1), x[:, :-1]), dim=1) - x
|
431 |
+
else:
|
432 |
+
xx = self.time_shift(x) - x
|
433 |
+
lx = x[:, -1]
|
434 |
+
|
435 |
+
xxx = x + xx * self.time_maa_x
|
436 |
+
xxx = torch.tanh(xxx @ self.time_maa_w1).view(B * T, 5, -1).transpose(0, 1)
|
437 |
+
xxx = torch.bmm(xxx, self.time_maa_w2).view(5, B, T, -1)
|
438 |
+
mw, mk, mv, mr, mg = xxx.unbind(dim=0)
|
439 |
+
|
440 |
+
xw = x + xx * (self.time_maa_w + mw)
|
441 |
+
xk = x + xx * (self.time_maa_k + mk)
|
442 |
+
xv = x + xx * (self.time_maa_v + mv)
|
443 |
+
xr = x + xx * (self.time_maa_r + mr)
|
444 |
+
xg = x + xx * (self.time_maa_g + mg)
|
445 |
+
|
446 |
+
r = self.receptance(xr)
|
447 |
+
k = self.key(xk)
|
448 |
+
v = self.value(xv)
|
449 |
+
g = F.silu(self.gate(xg))
|
450 |
+
|
451 |
+
ww = torch.tanh(xw @ self.time_decay_w1) @ self.time_decay_w2
|
452 |
+
w = self.time_decay + ww
|
453 |
+
|
454 |
+
wkv_state = last_state.wkv_state
|
455 |
+
x, wkv_state = self.apply_wkv6_state(
|
456 |
+
B, T, C, H, r, k, v, w, u=self.time_faaaa, s=wkv_state
|
457 |
+
)
|
458 |
+
if self.args.wkv_has_group_norm:
|
459 |
+
x = self.ln_x(x.view(B * T, C)).view(B, T, C)
|
460 |
+
x = self.output(x * g)
|
461 |
+
return x, TimeMixState(lx, wkv_state)
|
462 |
+
|
463 |
+
def apply_wkv6_state(self, B, T, C, H, r, k, v, w, u, s):
|
464 |
+
r = rearrange(r, "b l (h d) -> b h l d", h=H)
|
465 |
+
k = rearrange(k, "b l (h d) -> b h l d", h=H)
|
466 |
+
v = rearrange(v, "b l (h d) -> b h l d", h=H)
|
467 |
+
w = rearrange(w, "b l (h d) -> b h l d", h=H)
|
468 |
+
|
469 |
+
if r.device.type == "cpu":
|
470 |
+
wkv6_func = native_recurrent_rwkv6
|
471 |
+
elif self.training:
|
472 |
+
wkv6_func = chunk_rwkv6
|
473 |
+
else:
|
474 |
+
wkv6_func = fused_recurrent_rwkv6
|
475 |
+
|
476 |
+
o, state = wkv6_func(
|
477 |
+
r,
|
478 |
+
k,
|
479 |
+
v,
|
480 |
+
-torch.exp(w),
|
481 |
+
u=u,
|
482 |
+
scale=1.0,
|
483 |
+
initial_state=s,
|
484 |
+
output_final_state=True,
|
485 |
+
)
|
486 |
+
x = rearrange(o, "b h l d -> b l (h d)")
|
487 |
+
return x, state
|
488 |
+
|
489 |
+
|
490 |
+
class Rwkv6Attention(nn.Module):
|
491 |
+
def __init__(self, args: RwkvHybridConfig, layer_id, **kwargs):
|
492 |
+
super().__init__()
|
493 |
+
self.args = args
|
494 |
+
self.layer_idx = layer_id
|
495 |
+
self.time_mixer = Rwkv_Tmix_x060(args, layer_id, **kwargs)
|
496 |
+
|
497 |
+
def forward(self, hidden_states, past_key_value, **kwargs):
|
498 |
+
attn_output = hidden_states
|
499 |
+
B, T, C = attn_output.size()
|
500 |
+
if past_key_value is not None:
|
501 |
+
if len(past_key_value) <= self.layer_idx:
|
502 |
+
last_state = None
|
503 |
+
else:
|
504 |
+
last_state = past_key_value[self.layer_idx][0]
|
505 |
+
if last_state is None:
|
506 |
+
wkv_states = torch.zeros(
|
507 |
+
(B, self.args.num_wkv_heads, self.args.head_size, self.args.head_size),
|
508 |
+
device=attn_output.device,
|
509 |
+
dtype=torch.float32,
|
510 |
+
)
|
511 |
+
token_shift = torch.zeros(
|
512 |
+
(B, C), device=attn_output.device, dtype=attn_output.dtype
|
513 |
+
)
|
514 |
+
time_state = TimeMixState(token_shift, wkv_states)
|
515 |
+
channel_state = None
|
516 |
+
last_state = BlockState(time_state, channel_state)
|
517 |
+
attn_output, states = self.time_mixer(attn_output, last_state.time_mix_state)
|
518 |
+
last_state.time_mix_state = states
|
519 |
+
|
520 |
+
if past_key_value is not None:
|
521 |
+
past_key_value.update(T, last_state, self.layer_idx)
|
522 |
+
return attn_output, None
|