smjain commited on
Commit
32ef0b6
·
verified ·
1 Parent(s): ab23490

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +44 -219
README.md CHANGED
@@ -7,239 +7,64 @@ tags:
7
  - educational
8
  ---
9
 
10
- # CUDA2LLM trained checkpoint
11
 
12
- This repository contains the trained checkpoint produced by the pure CUDA C implementation in `cuda2llm`.
13
 
14
- Artifacts:
15
- - `model.bin`: trained model checkpoint with parameters and AdamW state.
16
- - `vocab.bin`: character vocabulary.
17
- - `full_run.log`: complete RunPod verification log, including chapter CUDA checks, gradient check, 5000-step training, and generation samples.
18
- - `train.bin` and `val.bin`: Tiny Shakespeare character token streams used for this run.
19
 
20
- The run used an NVIDIA RTX A4000 pod with CUDA 12.4. The implementation is intentionally explicit CUDA C, not PyTorch training.
 
 
 
21
 
22
- ## Verification Tail
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  ```text
25
- --- code/ch10 ---
26
- nvcc -O3 -arch=native -lm softmax.cu -o softmax
27
- nvcc -O3 -arch=native -lm reduce_row.cu -o reduce_row
28
- code/ch10/reduce_row
29
- OK rowmax
30
- OK rowsum
31
- code/ch10/softmax
32
- one row of large scores through both kernels (a demonstration):
33
- logits: 101.3 99.1 102.7 12.0 100.0 103.9 97.2 100.8
34
- naive: nan nan nan 0.000000 nan nan nan nan
35
- safe: 0.051216 0.005675 0.207688 0.000000 0.013958 0.689551 0.000849 0.031064
36
- OK softmax_v65
37
- softmax_v65: N=8192 V=65 0.046 ms ~229 GB/s effective
38
- OK softmax_v1000
39
- softmax_v1000: N=8192 V=1000 0.173 ms ~948 GB/s effective
40
- OK softmax_rowsum
41
- --- code/ch11 ---
42
- nvcc -O3 -arch=native -lm layernorm.cu -o layernorm
43
- nvcc -O3 -arch=native -lm gelu.cu -o gelu
44
- code/ch11/gelu
45
- x gelu(x)
46
- -2 -0.0454
47
- -1 -0.1588
48
- 0 0.0000
49
- 1 0.8412
50
- 2 1.9546
51
- OK gelu
52
- code/ch11/layernorm
53
- N=8192 rows, C=384 channels
54
- OK layernorm_out
55
- OK layernorm_mean
56
- OK layernorm_rstd
57
- N=1000 rows, C=100 channels
58
- OK layernorm_ragged
59
- --- code/ch12 ---
60
- nvcc -O3 -arch=native -lm encoder.cu -o encoder
61
- nvcc -O3 -arch=native -lm crossentropy.cu -o crossentropy
62
- code/ch12/crossentropy
63
- OK softmax
64
- OK crossentropy
65
- uniform logits: mean loss 4.174387, expected ln(65) = 4.174387
66
- OK uniform_loss_4.17
67
- code/ch12/encoder
68
- OK encoder
69
- --- code/ch13 ---
70
- nvcc -O3 -arch=native -lm attention.cu -o attention
71
- code/ch13/attention
72
- OK attention_out
73
- OK attention_att
74
- OK attention_causal
75
- --- code/ch16 ---
76
- cc -O2 -lm -o toy_backprop toy_backprop.c
77
- code/ch16/toy_backprop
78
- forward: z = 7.0, y = 49.0
79
- backward: dx = 42.0, dw = 28.0, db = 14.0
80
- finite difference dx ~= 42.002
81
- OK toy_backprop
82
- === GPT BUILD ===
83
- rm -f prepare_data train_gpt generate_gpt grad_check
84
- cc -O2 -lm -o prepare_data prepare_data.c
85
- nvcc -O3 -arch=native -lm -o train_gpt train_gpt.cu
86
- nvcc -O3 -arch=native -lm -o generate_gpt generate_gpt.cu
87
- nvcc -O3 -arch=native -lm -o grad_check grad_check.cu
88
- === DATA ===
89
- curl -L -o input.txt https://raw.githubusercontent.com/karpathy/char-rnn/master/data/tinyshakespeare/input.txt
90
- % Total % Received % Xferd Average Speed Time Time Time Current
91
- Dload Upload Total Spent Left Speed
92
-
93
- 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
94
- 100 1089k 100 1089k 0 0 4798k 0 --:--:-- --:--:-- --:--:-- 4819k
95
- tokens: 1115394 | vocab: 65 | train: 1003854 | val: 111540
96
- === GRAD CHECK ===
97
- analytic -0.074804
98
- numerical -0.074863
99
- diff 0.000060
100
- OK grad_check_wte0
101
- === TRAIN 5000 ===
102
- parameters: 10770816
103
- step 1 | loss 4.2383 | lr 0.000010 | 7300 tok/s
104
- step 100 | loss 2.4751 | lr 0.001000 | 7039 tok/s
105
- step 200 | loss 2.3741 | lr 0.000999 | 6967 tok/s
106
- val 250 | loss 2.2469
107
- step 300 | loss 2.1620 | lr 0.000996 | 7033 tok/s
108
- step 400 | loss 1.8983 | lr 0.000992 | 7017 tok/s
109
- step 500 | loss 1.7598 | lr 0.000985 | 7035 tok/s
110
- val 500 | loss 1.9397
111
- step 600 | loss 1.7097 | lr 0.000977 | 7024 tok/s
112
- step 700 | loss 1.7504 | lr 0.000967 | 7036 tok/s
113
- val 750 | loss 1.8425
114
- step 800 | loss 1.6235 | lr 0.000955 | 7022 tok/s
115
- step 900 | loss 1.5730 | lr 0.000942 | 7052 tok/s
116
- step 1000 | loss 1.6028 | lr 0.000927 | 7029 tok/s
117
- val 1000 | loss 1.7558
118
- saved model.bin at step 1000
119
- step 1100 | loss 1.6541 | lr 0.000911 | 7029 tok/s
120
- step 1200 | loss 1.6146 | lr 0.000893 | 7051 tok/s
121
- val 1250 | loss 1.6679
122
- step 1300 | loss 1.4642 | lr 0.000873 | 7035 tok/s
123
- step 1400 | loss 1.3288 | lr 0.000853 | 7034 tok/s
124
- step 1500 | loss 1.3054 | lr 0.000831 | 7043 tok/s
125
- val 1500 | loss 1.6317
126
- step 1600 | loss 1.3982 | lr 0.000807 | 7063 tok/s
127
- step 1700 | loss 1.3385 | lr 0.000783 | 7052 tok/s
128
- val 1750 | loss 1.6163
129
- step 1800 | loss 1.2542 | lr 0.000758 | 7047 tok/s
130
- step 1900 | loss 1.3436 | lr 0.000732 | 7050 tok/s
131
- step 2000 | loss 1.2770 | lr 0.000705 | 7062 tok/s
132
- val 2000 | loss 1.5911
133
- saved model.bin at step 2000
134
- step 2100 | loss 1.2688 | lr 0.000678 | 7052 tok/s
135
- step 2200 | loss 1.1882 | lr 0.000650 | 7042 tok/s
136
- val 2250 | loss 1.6044
137
- step 2300 | loss 1.3317 | lr 0.000622 | 7046 tok/s
138
- step 2400 | loss 1.1211 | lr 0.000593 | 7036 tok/s
139
- step 2500 | loss 1.2006 | lr 0.000564 | 7059 tok/s
140
- val 2500 | loss 1.6112
141
- step 2600 | loss 1.1568 | lr 0.000536 | 7065 tok/s
142
- step 2700 | loss 1.2186 | lr 0.000507 | 7067 tok/s
143
- val 2750 | loss 1.6321
144
- step 2800 | loss 1.1401 | lr 0.000478 | 7069 tok/s
145
- step 2900 | loss 1.0421 | lr 0.000450 | 7064 tok/s
146
- step 3000 | loss 1.1062 | lr 0.000422 | 7057 tok/s
147
- val 3000 | loss 1.6381
148
- saved model.bin at step 3000
149
- step 3100 | loss 0.9624 | lr 0.000395 | 7069 tok/s
150
- step 3200 | loss 1.0200 | lr 0.000368 | 7073 tok/s
151
- val 3250 | loss 1.6753
152
- step 3300 | loss 1.0242 | lr 0.000342 | 7089 tok/s
153
- step 3400 | loss 1.0527 | lr 0.000317 | 7055 tok/s
154
- step 3500 | loss 0.9729 | lr 0.000293 | 7063 tok/s
155
- val 3500 | loss 1.7316
156
- step 3600 | loss 0.9506 | lr 0.000269 | 7077 tok/s
157
- step 3700 | loss 0.9488 | lr 0.000247 | 7067 tok/s
158
- val 3750 | loss 1.7931
159
- step 3800 | loss 0.9607 | lr 0.000227 | 7055 tok/s
160
- step 3900 | loss 0.9824 | lr 0.000207 | 7056 tok/s
161
- step 4000 | loss 0.7658 | lr 0.000189 | 7031 tok/s
162
- val 4000 | loss 1.8825
163
- saved model.bin at step 4000
164
- step 4100 | loss 0.8902 | lr 0.000173 | 7044 tok/s
165
- step 4200 | loss 0.7832 | lr 0.000158 | 7047 tok/s
166
- val 4250 | loss 1.9381
167
- step 4300 | loss 0.8469 | lr 0.000145 | 7036 tok/s
168
- step 4400 | loss 0.8653 | lr 0.000133 | 7053 tok/s
169
- step 4500 | loss 0.8695 | lr 0.000123 | 7035 tok/s
170
- val 4500 | loss 1.9576
171
- step 4600 | loss 0.7353 | lr 0.000115 | 7048 tok/s
172
- step 4700 | loss 0.7704 | lr 0.000108 | 7046 tok/s
173
- val 4750 | loss 1.9924
174
- step 4800 | loss 0.7446 | lr 0.000104 | 7032 tok/s
175
- step 4900 | loss 0.8131 | lr 0.000101 | 7042 tok/s
176
- step 5000 | loss 0.7931 | lr 0.000100 | 7054 tok/s
177
- val 5000 | loss 2.0483
178
- saved model.bin at step 5000
179
- === GENERATE ROMEO ===
180
  ROMEO:
181
  Ay not sustom's master and by earor-woo's love;
182
  She damned life, lest have had some removed,
183
  Lest in neither slander man, and might have
184
  Because the moon his commission.
 
185
 
186
- MARCIUS:
187
- No, I'll consent the choler is prince:
188
- I am gone to great the last of my master;
189
- That's smules not put to my counsel.
190
-
191
- LARTIUS:
192
- He'll down away; alas, my liege, may stand
193
- And in the truth of one sons with that for night
194
- But upon'sy. Let thou go;
195
- How sometimes thee on the ground the vault?
196
- Though thy wife will then to thee to thine,
197
- And doth me, thy force should thee from thy brother
198
- As thou didst uncontent? I think thee, that would ens
199
- Of gracious that here were most under his pleasing
200
- pay a wordfather, a mother; a boote ardone
201
- And this one in so to be a child, and so meek
202
- To lie in; and so, as the which I do ha
203
- === GENERATE JULIET ===
204
- JULIET:
205
- And fearn gather nothing by thy lance.
206
- Is my daughter's most reason can strengthen's stand
207
- My separance up and hereport of their children,
208
- My mildness and constant seize in purge
209
- With informal enrage, that the habit ours.
210
- Say thou never have me once what I have:
211
- Not hear then beat his; 'twere thy toother such
212
- And see the gates that which he can say.
213
-
214
- KING EDWARD IV:
215
- The gods be thereof there! O thee, climbs:
216
- This is there: 'for thou re's more there's service:
217
- 'Tis thou there?
218
- Why, villain, if thou know'st this noble armed,
219
- It must are the alive. But what is this?
220
-
221
- GLOUCESTER:
222
- It should be, there's no consort or charge.
223
-
224
- YORK:
225
- At what command?
226
-
227
- CLARENCE:
228
- It is. For that docts but loss this thought of thee,
229
- As doubt the truth of the whole head.
230
-
231
- GLOUCESTER:
232
- Your brother is and Polixenes,
233
- Ho
234
- === ARTIFACTS ===
235
- -rw-r--r-- 1 root root 124M Jul 6 02:12 model.bin
236
- -rw-r--r-- 1 root root 3.9M Jul 6 00:34 train.bin
237
- -rw-r--r-- 1 root root 436K Jul 6 00:34 val.bin
238
- -rw-r--r-- 1 root root 73 Jul 6 00:34 vocab.bin
239
  75eb8311e2bdec22b0c0e40084fb39fb1ed190662d3cd51f26e9f4b37ee06691 model.bin
240
  464eb51d66b5b643889064b82c75607e2d756df11ec960e5e6aaaf03c71734be vocab.bin
241
  a3f591a5c0dfa7f54a2ec0ab39c4561d6475f1af28264f38076932ca425d5037 train.bin
242
  836220b36a012c19cd285816001700117edef4f8e1098130b234d4b8fa766d86 val.bin
243
- === DONE ===
244
- 2026-07-06T02:12:17+00:00
245
  ```
 
7
  - educational
8
  ---
9
 
10
+ # CUDA2LLM Trained Checkpoints
11
 
12
+ This repository contains checkpoints produced by the pure CUDA C implementation from `cuda2llm`. The code path uses hand-written CUDA kernels for the transformer forward pass, backward pass, AdamW update, checkpoint loading, and text generation.
13
 
14
+ ## What This Run Proves
 
 
 
 
15
 
16
+ - The chapter CUDA programs compile and pass their checks.
17
+ - The full GPT program compiles with CUDA 12.4.
18
+ - `prepare_data`, `grad_check`, `train_gpt`, and `generate_gpt` all run on an NVIDIA RTX A4000.
19
+ - A 5000-step training run completed and generated text from the final checkpoint.
20
 
21
+ ## Important Quality Note
22
+
23
+ The final sample is not coherent Shakespeare. It is a small character-level model trained on a small corpus with an intentionally explicit educational implementation. It learns character labels, line breaks, archaic cadence, and local word shapes, but it does not reliably learn plot, speaker intent, or sentence-level meaning.
24
+
25
+ The validation curve shows overfitting after about step 2000. The final checkpoint is useful as proof that the scheduled run completed; the step-2000 region is the better demo checkpoint by validation loss.
26
+
27
+ ## Loss Curve
28
+
29
+ ```text
30
+ step 1000 | train loss 1.6028 | val loss 1.7558
31
+ step 2000 | train loss 1.2770 | val loss 1.5911
32
+ step 3000 | train loss 1.1062 | val loss 1.6381
33
+ step 4000 | train loss 0.7658 | val loss 1.8825
34
+ step 5000 | train loss 0.7931 | val loss 2.0483
35
+ ```
36
+
37
+ ## Final Sample Excerpt
38
 
39
  ```text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  ROMEO:
41
  Ay not sustom's master and by earor-woo's love;
42
  She damned life, lest have had some removed,
43
  Lest in neither slander man, and might have
44
  Because the moon his commission.
45
+ ```
46
 
47
+ This is best described as Shakespeare-like texture with weak semantics.
48
+
49
+ ## Files
50
+
51
+ ```text
52
+ model.bin
53
+ vocab.bin
54
+ train.bin
55
+ val.bin
56
+ full_run.log
57
+ checkpoints/model-interim-20260706-011839.bin
58
+ checkpoints/model-interim-20260706-020538.bin
59
+ samples/interim_sample_20260706-011839.txt
60
+ samples/interim_sample_20260706-020538.txt
61
+ ```
62
+
63
+ ## Final Artifact Hashes
64
+
65
+ ```text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  75eb8311e2bdec22b0c0e40084fb39fb1ed190662d3cd51f26e9f4b37ee06691 model.bin
67
  464eb51d66b5b643889064b82c75607e2d756df11ec960e5e6aaaf03c71734be vocab.bin
68
  a3f591a5c0dfa7f54a2ec0ab39c4561d6475f1af28264f38076932ca425d5037 train.bin
69
  836220b36a012c19cd285816001700117edef4f8e1098130b234d4b8fa766d86 val.bin
 
 
70
  ```