picocreator commited on
Commit
20865d9
1 Parent(s): b774728

[GHA] trainer-v4-unit-test/model-init.ipynb result notebooks (#7)

Browse files

- ef137574298e1921e37502d759bb4447972c095e6fcc8ed8adf81a73b4e5875e (44fcb393a15554671e7af304b52f55582286d421)

Files changed (1) hide show
  1. trainer-v4-unit-test/model-init.ipynb +294 -0
trainer-v4-unit-test/model-init.ipynb ADDED
@@ -0,0 +1,294 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "attachments": {},
5
+ "cell_type": "markdown",
6
+ "id": "52b890f4",
7
+ "metadata": {
8
+ "papermill": {
9
+ "duration": 0.002262,
10
+ "end_time": "2023-08-23T10:53:59.090685",
11
+ "exception": false,
12
+ "start_time": "2023-08-23T10:53:59.088423",
13
+ "status": "completed"
14
+ },
15
+ "tags": []
16
+ },
17
+ "source": [
18
+ "# Model Init\n",
19
+ "\n",
20
+ "Test that the model init code, runs without issues\n",
21
+ "\n",
22
+ "**L6-D512 model with**\n",
23
+ "- Layer count: 6\n",
24
+ "- Embed size: 512"
25
+ ]
26
+ },
27
+ {
28
+ "attachments": {},
29
+ "cell_type": "markdown",
30
+ "id": "f89c248f",
31
+ "metadata": {
32
+ "notebookRunGroups": {
33
+ "groupValue": ""
34
+ },
35
+ "papermill": {
36
+ "duration": 0.001598,
37
+ "end_time": "2023-08-23T10:53:59.094424",
38
+ "exception": false,
39
+ "start_time": "2023-08-23T10:53:59.092826",
40
+ "status": "completed"
41
+ },
42
+ "tags": []
43
+ },
44
+ "source": [
45
+ "## Preparing the init model and test dataset"
46
+ ]
47
+ },
48
+ {
49
+ "cell_type": "code",
50
+ "execution_count": 1,
51
+ "id": "65ffd8d5",
52
+ "metadata": {
53
+ "execution": {
54
+ "iopub.execute_input": "2023-08-23T10:53:59.099519Z",
55
+ "iopub.status.busy": "2023-08-23T10:53:59.099000Z",
56
+ "iopub.status.idle": "2023-08-23T10:53:59.849771Z",
57
+ "shell.execute_reply": "2023-08-23T10:53:59.848760Z"
58
+ },
59
+ "papermill": {
60
+ "duration": 0.756019,
61
+ "end_time": "2023-08-23T10:53:59.852126",
62
+ "exception": false,
63
+ "start_time": "2023-08-23T10:53:59.096107",
64
+ "status": "completed"
65
+ },
66
+ "tags": []
67
+ },
68
+ "outputs": [],
69
+ "source": [
70
+ "# First lets setup the various directories\n",
71
+ "!mkdir -p ../../model/\n",
72
+ "!mkdir -p ../../datapath/\n",
73
+ "!mkdir -p ../../checkpoint/"
74
+ ]
75
+ },
76
+ {
77
+ "cell_type": "code",
78
+ "execution_count": 2,
79
+ "id": "c3b4c1b4",
80
+ "metadata": {
81
+ "execution": {
82
+ "iopub.execute_input": "2023-08-23T10:53:59.858552Z",
83
+ "iopub.status.busy": "2023-08-23T10:53:59.858038Z",
84
+ "iopub.status.idle": "2023-08-23T10:54:08.846245Z",
85
+ "shell.execute_reply": "2023-08-23T10:54:08.844779Z"
86
+ },
87
+ "papermill": {
88
+ "duration": 8.994708,
89
+ "end_time": "2023-08-23T10:54:08.848911",
90
+ "exception": false,
91
+ "start_time": "2023-08-23T10:53:59.854203",
92
+ "status": "completed"
93
+ },
94
+ "tags": []
95
+ },
96
+ "outputs": [
97
+ {
98
+ "name": "stdout",
99
+ "output_type": "stream",
100
+ "text": [
101
+ "[2023-08-23 10:54:04,147] [INFO] [real_accelerator.py:133:get_accelerator] Setting ds_accelerator to cuda (auto detect)\r\n"
102
+ ]
103
+ },
104
+ {
105
+ "name": "stdout",
106
+ "output_type": "stream",
107
+ "text": [
108
+ "[RWKV.model] Running RWKV model using 'torch-jit' with torch '2.0.1+cu118'\r\n",
109
+ "---- Initializing model ----\r\n",
110
+ "No of layers: 6\r\n",
111
+ "Embedding size: 512\r\n",
112
+ "Output model path: ../model/L6-D512-neox-init.pth\r\n",
113
+ "Vocab size: 50277\r\n",
114
+ "Note: this process takes a significant time (and ram) for large models\r\n",
115
+ "---- ----- ----\r\n"
116
+ ]
117
+ },
118
+ {
119
+ "name": "stdout",
120
+ "output_type": "stream",
121
+ "text": [
122
+ "Using /root/.cache/torch_extensions/py310_cu118 as PyTorch extensions root...\r\n",
123
+ "Detected CUDA files, patching ldflags\r\n",
124
+ "Emitting ninja build file /root/.cache/torch_extensions/py310_cu118/wkv_1_bf16/build.ninja...\r\n"
125
+ ]
126
+ },
127
+ {
128
+ "name": "stdout",
129
+ "output_type": "stream",
130
+ "text": [
131
+ "Building extension module wkv_1_bf16...\r\n",
132
+ "Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)\r\n",
133
+ "ninja: no work to do.\r\n",
134
+ "Loading extension module wkv_1_bf16...\r\n"
135
+ ]
136
+ },
137
+ {
138
+ "name": "stdout",
139
+ "output_type": "stream",
140
+ "text": [
141
+ "[RWKV.model]: Finished initial model load\r\n"
142
+ ]
143
+ },
144
+ {
145
+ "name": "stdout",
146
+ "output_type": "stream",
147
+ "text": [
148
+ "50277 512 -0.0001 emb.weight\r\n"
149
+ ]
150
+ },
151
+ {
152
+ "name": "stdout",
153
+ "output_type": "stream",
154
+ "text": [
155
+ "512 512 0 blocks.0.att.key.weight\r\n",
156
+ "512 512 1.0 blocks.0.att.value.weight\r\n",
157
+ "512 512 0 blocks.0.att.receptance.weight\r\n",
158
+ "512 512 0 blocks.0.att.output.weight\r\n",
159
+ "2048 512 1.0 blocks.0.ffn.key.weight\r\n"
160
+ ]
161
+ },
162
+ {
163
+ "name": "stdout",
164
+ "output_type": "stream",
165
+ "text": [
166
+ "512 512 0 blocks.0.ffn.receptance.weight\r\n",
167
+ "512 2048 0 blocks.0.ffn.value.weight\r\n",
168
+ "512 512 0 blocks.1.att.key.weight\r\n",
169
+ "512 512 1.0 blocks.1.att.value.weight\r\n"
170
+ ]
171
+ },
172
+ {
173
+ "name": "stdout",
174
+ "output_type": "stream",
175
+ "text": [
176
+ "512 512 0 blocks.1.att.receptance.weight\r\n",
177
+ "512 512 0 blocks.1.att.output.weight\r\n",
178
+ "2048 512 1.0 blocks.1.ffn.key.weight\r\n"
179
+ ]
180
+ },
181
+ {
182
+ "name": "stdout",
183
+ "output_type": "stream",
184
+ "text": [
185
+ "512 512 0 blocks.1.ffn.receptance.weight\r\n",
186
+ "512 2048 0 blocks.1.ffn.value.weight\r\n",
187
+ "512 512 0 blocks.2.att.key.weight\r\n",
188
+ "512 512 1.0 blocks.2.att.value.weight\r\n",
189
+ "512 512 0 blocks.2.att.receptance.weight\r\n",
190
+ "512 512 0 blocks.2.att.output.weight\r\n",
191
+ "2048 512 1.0 blocks.2.ffn.key.weight\r\n"
192
+ ]
193
+ },
194
+ {
195
+ "name": "stdout",
196
+ "output_type": "stream",
197
+ "text": [
198
+ "512 512 0 blocks.2.ffn.receptance.weight\r\n",
199
+ "512 2048 0 blocks.2.ffn.value.weight\r\n",
200
+ "512 512 0 blocks.3.att.key.weight\r\n",
201
+ "512 512 1.0 blocks.3.att.value.weight\r\n"
202
+ ]
203
+ },
204
+ {
205
+ "name": "stdout",
206
+ "output_type": "stream",
207
+ "text": [
208
+ "512 512 0 blocks.3.att.receptance.weight\r\n",
209
+ "512 512 0 blocks.3.att.output.weight\r\n",
210
+ "2048 512 1.0 blocks.3.ffn.key.weight\r\n"
211
+ ]
212
+ },
213
+ {
214
+ "name": "stdout",
215
+ "output_type": "stream",
216
+ "text": [
217
+ "512 512 0 blocks.3.ffn.receptance.weight\r\n",
218
+ "512 2048 0 blocks.3.ffn.value.weight\r\n",
219
+ "512 512 0 blocks.4.att.key.weight\r\n",
220
+ "512 512 1.0 blocks.4.att.value.weight\r\n",
221
+ "512 512 0 blocks.4.att.receptance.weight\r\n",
222
+ "512 512 0 blocks.4.att.output.weight\r\n",
223
+ "2048 512 1.0 blocks.4.ffn.key.weight\r\n"
224
+ ]
225
+ },
226
+ {
227
+ "name": "stdout",
228
+ "output_type": "stream",
229
+ "text": [
230
+ "512 512 0 blocks.4.ffn.receptance.weight\r\n",
231
+ "512 2048 0 blocks.4.ffn.value.weight\r\n",
232
+ "512 512 0 blocks.5.att.key.weight\r\n",
233
+ "512 512 1.0 blocks.5.att.value.weight\r\n"
234
+ ]
235
+ },
236
+ {
237
+ "name": "stdout",
238
+ "output_type": "stream",
239
+ "text": [
240
+ "512 512 0 blocks.5.att.receptance.weight\r\n",
241
+ "512 512 0 blocks.5.att.output.weight\r\n",
242
+ "2048 512 1.0 blocks.5.ffn.key.weight\r\n",
243
+ "512 512 0 blocks.5.ffn.receptance.weight\r\n"
244
+ ]
245
+ },
246
+ {
247
+ "name": "stdout",
248
+ "output_type": "stream",
249
+ "text": [
250
+ "512 2048 0 blocks.5.ffn.value.weight\r\n",
251
+ "50277 512 0.5 head.weight\r\n"
252
+ ]
253
+ }
254
+ ],
255
+ "source": [
256
+ "# Lets initialized the L6-D512 model with the init_model.py code\n",
257
+ "!cd ../../RWKV-v4neo/ && python3 init_model.py --n_layer 6 --n_embd 512 --vocab_size neox ../model/L6-D512-neox-init.pth"
258
+ ]
259
+ }
260
+ ],
261
+ "metadata": {
262
+ "kernelspec": {
263
+ "display_name": "rwkv-exp",
264
+ "language": "python",
265
+ "name": "python3"
266
+ },
267
+ "language_info": {
268
+ "codemirror_mode": {
269
+ "name": "ipython",
270
+ "version": 3
271
+ },
272
+ "file_extension": ".py",
273
+ "mimetype": "text/x-python",
274
+ "name": "python",
275
+ "nbconvert_exporter": "python",
276
+ "pygments_lexer": "ipython3",
277
+ "version": "3.10.12"
278
+ },
279
+ "papermill": {
280
+ "default_parameters": {},
281
+ "duration": 11.521627,
282
+ "end_time": "2023-08-23T10:54:09.274570",
283
+ "environment_variables": {},
284
+ "exception": null,
285
+ "input_path": "/actions-runner/_work/RWKV-infctx-trainer/RWKV-infctx-trainer/notebook/trainer-v4-unit-test/model-init.ipynb",
286
+ "output_path": "/actions-runner/_work/RWKV-infctx-trainer/RWKV-infctx-trainer/output/trainer-v4-unit-test/model-init.ipynb",
287
+ "parameters": {},
288
+ "start_time": "2023-08-23T10:53:57.752943",
289
+ "version": "2.4.0"
290
+ }
291
+ },
292
+ "nbformat": 4,
293
+ "nbformat_minor": 5
294
+ }