forked from KellerJordan/modded-nanogpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd1cf11aa-7b8e-4d28-a94d-1aab632e0f38.txt
2400 lines (2329 loc) · 151 KB
/
d1cf11aa-7b8e-4d28-a94d-1aab632e0f38.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
====================================================================================================
import os
import sys
with open(sys.argv[0]) as f:
code = f.read() # read the code of this file ASAP, for logging
import uuid
import glob
import time
from dataclasses import dataclass
import numpy as np
import torch
from torch import nn
import torch.nn.functional as F
import torch.distributed as dist
import torch._inductor.config as config
from torch.nn.parallel import DistributedDataParallel as DDP
# Use of FlexAttention contributed by @KoszarskyB
from torch.nn.attention.flex_attention import flex_attention, create_block_mask
flex_attention = torch.compile(flex_attention, dynamic=False)
create_block_mask = torch.compile(create_block_mask, dynamic=False)
# -----------------------------------------------------------------------------
# Muon optimizer
def zeropower_via_svd(G, steps=None):
U, S, V = G.svd()
return U @ V.T
@torch.compile
def zeropower_via_newtonschulz5(G, steps=10, eps=1e-7):
"""
Newton-Schulz iteration to compute the zeroth power / orthogonalization of G. We opt to use a
quintic iteration whose coefficients are selected to maximize the slope at zero. For the purpose
of minimizing steps, it turns out to be empirically effective to keep increasing the slope at
zero even beyond the point where the iteration no longer converges all the way to one everywhere
on the interval. This iteration therefore does not produce UV^T but rather something like US'V^T
where S' is diagonal with S_{ii}' ~ Uniform(0.5, 1.5), which turns out not to hurt model
performance at all relative to UV^T, where USV^T = G is the SVD.
"""
assert len(G.shape) == 2
a, b, c = (3.4445, -4.7750, 2.0315)
X = G.bfloat16()
X /= (X.norm() + eps) # ensure top singular value <= 1
if G.size(0) > G.size(1):
X = X.T
for _ in range(steps):
A = X @ X.T
B = b * A + c * A @ A # adapted from suggestion by @jxbz, @leloykun, and @YouJiacheng
X = a * X + B @ X
if G.size(0) > G.size(1):
X = X.T
return X
zeropower_backends = dict(svd=zeropower_via_svd, newtonschulz5=zeropower_via_newtonschulz5)
class Muon(torch.optim.Optimizer):
"""
Muon - MomentUm Orthogonalized by Newton-schulz
Muon internally runs standard SGD-momentum, and then performs an orthogonalization post-
processing step, in which each 2D parameter's update is replaced with the nearest orthogonal
matrix. To efficiently orthogonalize each update, we use a Newton-Schulz iteration, which has
the advantage that it can be stably run in bfloat16 on the GPU.
Some warnings:
- This optimizer assumes that all parameters passed in are 2D.
- It should not be used for the embedding layer, the final fully connected layer, or any {0,1}-D
parameters; those should all be optimized by a standard method (e.g., AdamW).
- To use it with 4D convolutional filters, it works well to just flatten their last 3 dimensions.
- We believe it is unlikely to work well for training with small batch size.
- We believe it may not work well for finetuning pretrained models, but we haven't tested this.
- We have not yet tried this optimizer for training scenarios larger than NanoGPT (124M).
Arguments:
lr: The learning rate used by the internal SGD.
momentum: The momentum used by the internal SGD.
nesterov: Whether to use Nesterov-style momentum in the internal SGD. (recommended)
backend: The chosen backend for the orthogonalization step. (recommended: 'newtonschulz5')
backend_steps: The number of iteration steps to use in the backend, if it is iterative.
"""
def __init__(self, params, lr=0.02, momentum=0.95, nesterov=True,
backend='newtonschulz5', backend_steps=5):
defaults = dict(lr=lr, momentum=momentum, nesterov=nesterov, backend=backend, backend_steps=backend_steps)
super().__init__(params, defaults)
def step(self):
for group in self.param_groups:
lr = group['lr']
momentum = group['momentum']
zeropower_backend = zeropower_backends[group['backend']]
# generate weight updates in distributed fashion
total_params = sum(p.numel() for p in group['params'])
updates_flat = torch.zeros(total_params, device='cuda', dtype=torch.bfloat16)
curr_idx = 0
for i, p in enumerate(group['params']):
# luckily this will perfectly distribute a transformer with multiple of 4 layers to 8 GPUs
if i % int(os.environ['WORLD_SIZE']) == int(os.environ['RANK']):
g = p.grad
assert g is not None
state = self.state[p]
if 'momentum_buffer' not in state:
state['momentum_buffer'] = torch.zeros_like(g)
buf = state['momentum_buffer']
buf.mul_(momentum).add_(g)
if group['nesterov']:
g = g.add(buf, alpha=momentum)
g = zeropower_backend(g, steps=group['backend_steps'])
g *= max(1, g.size(0)/g.size(1))**0.5
updates_flat[curr_idx:curr_idx+p.numel()] = g.flatten()
curr_idx += p.numel()
# sync updates across devices. we are not memory-constrained so can do this simple deserialization
dist.all_reduce(updates_flat, op=dist.ReduceOp.SUM)
# deserialize and apply updates
curr_idx = 0
for p in group['params']:
g = updates_flat[curr_idx:curr_idx+p.numel()].view_as(p.data).type_as(p.data)
p.data.add_(g, alpha=-lr)
curr_idx += p.numel()
# -----------------------------------------------------------------------------
# PyTorch nn.Module definitions for the GPT-2 model
class Rotary(torch.nn.Module):
def __init__(self, dim, base=10000):
super().__init__()
self.dim = dim
self.base = base
self.inv_freq = None
self.seq_len_cached = None
self.cos_cached = None
self.sin_cached = None
def forward(self, x):
seq_len = x.shape[1]
if seq_len != self.seq_len_cached:
self.inv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2, device=x.device).float() / self.dim))
self.seq_len_cached = seq_len
t = torch.arange(seq_len, device=x.device).type_as(self.inv_freq)
freqs = torch.outer(t, self.inv_freq)
self.cos_cached = freqs.cos().bfloat16()
self.sin_cached = freqs.sin().bfloat16()
return self.cos_cached[None, :, None, :], self.sin_cached[None, :, None, :]
def apply_rotary_emb(x, cos, sin):
assert x.ndim == 4 # multihead attention
d = x.shape[3]//2
x1 = x[..., :d]
x2 = x[..., d:]
y1 = x1 * cos + x2 * sin
y2 = x1 * (-sin) + x2 * cos
return torch.cat([y1, y2], 3).type_as(x)
class CastedLinear(nn.Linear):
def forward(self, x):
return F.linear(x, self.weight.to(x.dtype))
class CausalSelfAttention(nn.Module):
def __init__(self, config):
super().__init__()
self.n_head = config.n_head
self.n_embd = config.n_embd
self.head_dim = self.n_embd // self.n_head
assert self.n_embd % self.n_head == 0
self.c_q = CastedLinear(self.n_embd, self.n_embd, bias=False)
self.c_k = CastedLinear(self.n_embd, self.n_embd, bias=False)
self.c_v = CastedLinear(self.n_embd, self.n_embd, bias=False)
# output projection
self.c_proj = CastedLinear(self.n_embd, self.n_embd, bias=False)
self.c_proj.weight.data.zero_() # zero init suggested by @Grad62304977
self.rotary = Rotary(self.head_dim)
self.lamb = nn.Parameter(torch.tensor(0.5)) # @Grad62304977
def forward(self, x, v1, block_mask):
B, T, C = x.size() # batch size, sequence length, embedding dimensionality (n_embd)
q = self.c_q(x).view(B, T, self.n_head, self.head_dim)
k = self.c_k(x).view(B, T, self.n_head, self.head_dim)
v = self.c_v(x).view(B, T, self.n_head, self.head_dim)
if v1 is None:
v1 = v # This happens if we are in the first block. v needs to be accessed by subsequent blocks
v = (1 - self.lamb) * v + self.lamb * v1.view_as(v) # @Grad62304977
cos, sin = self.rotary(q)
q, k = F.rms_norm(q, (q.size(-1),)), F.rms_norm(k, (k.size(-1),)) # QK norm suggested by @Grad62304977
q, k = apply_rotary_emb(q, cos, sin), apply_rotary_emb(k, cos, sin)
y = flex_attention(q.transpose(1, 2), k.transpose(1, 2), v.transpose(1, 2), block_mask=block_mask)
y = y.transpose(1, 2).contiguous().view_as(x) # re-assemble all head outputs side by side
y = self.c_proj(y)
return y, v1
class MLP(nn.Module):
def __init__(self, config):
super().__init__()
self.c_fc = CastedLinear(config.n_embd, 4 * config.n_embd, bias=False)
self.c_proj = CastedLinear(4 * config.n_embd, config.n_embd, bias=False)
self.c_proj.weight.data.zero_() # zero init suggested by @Grad62304977
def forward(self, x):
x = self.c_fc(x)
x = F.relu(x).square() # https://arxiv.org/abs/2109.08668v2; ~1-2% better than GELU; suggested by @SKYLINEZ007 and @Grad62304977
x = self.c_proj(x)
return x
class Block(nn.Module):
def __init__(self, config):
super().__init__()
self.attn = CausalSelfAttention(config)
self.mlp = MLP(config)
self.lambdas = nn.Parameter(torch.tensor([1., 0.]))
def forward(self, x, v1, x0, block_mask):
x = self.lambdas[0] * x + self.lambdas[1] * x0
x1, v1 = self.attn(F.rms_norm(x, (x.size(-1),)), v1, block_mask)
x = x + x1
x = x + self.mlp(F.rms_norm(x, (x.size(-1),)))
return x, v1
# -----------------------------------------------------------------------------
# The main GPT-2 model
@dataclass
class GPTConfig:
vocab_size : int = 50304
n_layer : int = 12
n_head : int = 6 # head dim 128 suggested by @Grad62304977
n_embd : int = 768
class GPT(nn.Module):
def __init__(self, config):
super().__init__()
# U-net design by @brendanh0gan
self.num_encoder_layers = config.n_layer // 2 # Half of the layers for encoder
self.num_decoder_layers = config.n_layer - self.num_encoder_layers # Remaining for decoder
# Add learnable skip connection weights for decoder layers
self.skip_weights = nn.Parameter(torch.ones(self.num_decoder_layers))
self.transformer = nn.ModuleDict(dict(
wte = nn.Embedding(config.vocab_size, config.n_embd),
h = nn.ModuleList([Block(config) for _ in range(config.n_layer)]),
))
self.lm_head = CastedLinear(config.n_embd, config.vocab_size, bias=False)
self.lm_head.weight.data.zero_() # @Grad62304977
def forward(self, idx, target, attn_blocksize):
docs = (idx == 50256).cumsum(0)
def document_causal_mask(b, h, q_idx, kv_idx):
causal_mask = q_idx >= kv_idx
document_mask = docs[q_idx] == docs[kv_idx]
window_mask = q_idx - kv_idx < attn_blocksize
return causal_mask & document_mask & window_mask
S = len(idx)
block_mask = create_block_mask(document_causal_mask, None, None, S, S, device="cuda", _compile=True)
# forward the GPT model itself
x = self.transformer.wte(idx[None]) # token embeddings of shape (b, t, n_embd)
x = F.rms_norm(x, (x.size(-1),)) # @Grad62304977
x0 = x
v1 = None
# Store outputs for U-Net skip connections
skip_connections = []
# Encoder pass - process only the first half of the blocks
for i in range(self.num_encoder_layers):
x, v1 = self.transformer.h[i](x, v1, x0, block_mask)
skip_connections.append(x)
# Decoder pass - process the remaining blocks with weighted skip connections
for i in range(self.num_decoder_layers):
x = x + self.skip_weights[i] * skip_connections.pop()
x, v1 = self.transformer.h[self.num_encoder_layers + i](x, v1, x0, block_mask)
x = F.rms_norm(x, (x.size(-1),))
logits = self.lm_head(x)
logits = 30 * torch.tanh(logits / 30) # @Grad62304977
logits = logits.float()
loss = F.cross_entropy(logits.view(-1, logits.size(-1)), target.view(-1))
return loss
# -----------------------------------------------------------------------------
# Our own simple Distributed Data Loader
def _peek_data_shard(filename):
# only reads the header, returns header data
with open(filename, "rb") as f:
# first read the header, which is 256 int32 integers (4 bytes each)
header = np.frombuffer(f.read(256*4), dtype=np.int32)
if header[0] != 20240520:
print("ERROR: magic number mismatch in the data .bin file!")
print("---> HINT: Are you passing in a correct file with --input_bin?")
print("---> HINT: Dataset encoding changed recently, re-run data prepro or refer again to README")
print("---> HINT: For example re-run: `python dev/data/tinyshakespeare.py`, then re-try")
exit(1)
assert header[1] == 1, "unsupported version"
ntok = header[2] # number of tokens (claimed)
return ntok # for now just return the number of tokens
def _load_data_shard(filename):
with open(filename, "rb") as f:
# first read the header, which is 256 int32 integers (4 bytes each)
header = np.frombuffer(f.read(256*4), dtype=np.int32)
assert header[0] == 20240520, "magic number mismatch in the data .bin file"
assert header[1] == 1, "unsupported version"
ntok = header[2] # number of tokens (claimed)
# the rest of it are tokens, stored as uint16
tokens = np.frombuffer(f.read(), dtype=np.uint16)
assert len(tokens) == ntok, "number of tokens read does not match header?"
return tokens
class DistributedDataLoader:
def __init__(self, filename_pattern, B, T, process_rank, num_processes):
self.process_rank = process_rank
self.num_processes = num_processes
self.B = B
self.T = T
# glob files that match the pattern
self.files = sorted(glob.glob(filename_pattern))
assert len(self.files) > 0, f"did not find any files that match the pattern {filename_pattern}"
# load and validate all data shards, count number of tokens in total
ntok_total = 0
for fname in self.files:
shard_ntok = _peek_data_shard(fname)
assert shard_ntok >= num_processes * B * T + 1
ntok_total += int(shard_ntok)
self.ntok_total = ntok_total
self.reset()
def reset(self):
self.current_shard = -1
self.advance()
def advance(self): # advance to next data shard
self.current_shard = (self.current_shard + 1) % len(self.files)
self.current_position = self.process_rank * self.B * self.T
self.tokens = _load_data_shard(self.files[self.current_shard])
def next_batch(self):
batch_size = self.B * self.T * self.num_processes
buf = self.tokens[self.current_position:self.current_position+self.B*self.T+1]
buf = torch.tensor(buf.astype(np.int32), dtype=torch.long)
x = buf[:-1] # inputs
y = buf[1:] # targets
# advance current position and load next shard if necessary
self.current_position += batch_size
if self.current_position + batch_size >= len(self.tokens):
self.advance()
return x.cuda(), y.cuda()
# -----------------------------------------------------------------------------
# int main
@dataclass
class Hyperparameters:
# data hyperparams
input_bin : str = 'data/fineweb10B/fineweb_train_*.bin' # input .bin to train on
input_val_bin : str = 'data/fineweb10B/fineweb_val_*.bin' # input .bin to eval validation loss on
# optimization hyperparams
batch_size : int = 8 # batch size, in sequences, across all devices
device_batch_size : int = 1 # batch size, in sequences, per device
sequence_length : int = 64*1024 # sequence length, in tokens
num_iterations : int = 1750 # number of iterations to run
warmup_iters : int = 0
cooldown_iters : int = 640 # number of iterations of linear warmup/cooldown for triangular or trapezoidal schedule
weight_decay : float = 0
# evaluation and logging hyperparams
val_loss_every : int = 125 # every how many steps to evaluate val loss? 0 for only at the end
val_tokens : int = 10485760 # how many tokens of validation data? it's important to keep this fixed for consistent comparisons
save_every : int = 0 # every how many steps to save the checkpoint? 0 for only at the end
args = Hyperparameters()
# set up DDP (distributed data parallel). torchrun sets this env variable
assert torch.cuda.is_available()
dist.init_process_group(backend='nccl')
ddp_rank = int(os.environ['RANK'])
ddp_local_rank = int(os.environ['LOCAL_RANK'])
ddp_world_size = int(os.environ['WORLD_SIZE'])
device = f'cuda:{ddp_local_rank}'
torch.cuda.set_device(device)
print(f"using device: {device}")
master_process = (ddp_rank == 0) # this process will do logging, checkpointing etc.
# begin logging
logfile = None
if master_process:
run_id = str(uuid.uuid4())
logdir = 'logs/%s/' % run_id
os.makedirs(logdir, exist_ok=True)
logfile = 'logs/%s.txt' % run_id
# create the log file
with open(logfile, "w") as f:
# begin the log by printing this file (the Python code)
f.write('='*100 + '\n')
f.write(code)
f.write('='*100 + '\n')
def print0(s, logonly=False):
if master_process:
with open(logfile, "a") as f:
if not logonly:
print(s)
f.write(s+'\n')
# log information about the hardware/software environment this is running on
# and print the full `nvidia-smi` to file
print0(f"Running pytorch {torch.version.__version__} compiled for CUDA {torch.version.cuda}\nnvidia-smi:")
import subprocess
result = subprocess.run(['nvidia-smi'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
print0(f'{result.stdout}', logonly=True)
print0('='*100, logonly=True)
# convenience variables
B, T = args.device_batch_size, args.sequence_length
# calculate the number of steps to take in the val loop.
assert args.val_tokens % (B * T * ddp_world_size) == 0
val_steps = args.val_tokens // (B * T * ddp_world_size)
# calculate the steps of gradient accumulation required to attain the desired global batch size.
assert args.batch_size % (B * ddp_world_size) == 0
train_accumulation_steps = args.batch_size // (B * ddp_world_size)
# load tokens
train_loader = DistributedDataLoader(args.input_bin, B, T, ddp_rank, ddp_world_size)
val_loader = DistributedDataLoader(args.input_val_bin, B, T, ddp_rank, ddp_world_size)
print0(f"Training DataLoader: total number of tokens: {train_loader.ntok_total} across {len(train_loader.files)} files")
print0(f"Validation DataLoader: total number of tokens: {val_loader.ntok_total} across {len(val_loader.files)} files")
print0('='*100, logonly=True)
x, y = train_loader.next_batch()
# there are only 50257 unique GPT-2 tokens; we extend to nearest multiple of 128 for efficiency. suggested to me by @Grad62304977.
# this originates from Karpathy's experiments.
num_vocab = 50304
model = GPT(GPTConfig(vocab_size=num_vocab, n_layer=12, n_head=6, n_embd=768))
model = model.cuda().bfloat16()
for m in model.modules():
if isinstance(m, CastedLinear):
m.float()
if hasattr(config, "coordinate_descent_tuning"):
config.coordinate_descent_tuning = True # suggested by @Chillee
model = torch.compile(model)
# here we wrap model into DDP container
model = DDP(model, device_ids=[ddp_local_rank])
raw_model = model.module # always contains the "raw" unwrapped model
# CUDNN attention is ~4ms faster than Flash, but doesn't get selected by default in PyTorch 2.5.1
from torch.backends.cuda import enable_cudnn_sdp, enable_flash_sdp, enable_math_sdp, enable_mem_efficient_sdp
enable_cudnn_sdp(True)
enable_flash_sdp(False)
enable_mem_efficient_sdp(False)
enable_math_sdp(False)
# init the optimizer(s)
optimizer1 = torch.optim.Adam([raw_model.transformer.wte.weight], lr=0.6, betas=(0.8, 0.95), fused=True)
optimizer2 = torch.optim.Adam([raw_model.lm_head.weight], lr=0.008, betas=(0.8, 0.95), fused=True)
params = list(raw_model.transformer.h.parameters())
matrix_params = [p for p in params if p.ndim == 2]
scalar_params = [p for p in params if p.ndim < 2] + [raw_model.skip_weights]
optimizer3 = Muon(matrix_params, lr=0.05, momentum=0.95)
optimizer4 = torch.optim.Adam(scalar_params, lr=0.04, betas=(0.8, 0.95), fused=True) # note that this learning rate is neither sensitive nor tuned
optimizers = [optimizer1, optimizer2, optimizer3, optimizer4]
# learning rate decay scheduler (linear warmup and cooldown)
def get_lr(it):
assert it <= args.num_iterations
# 1) linear warmup for warmup_iters steps
if it < args.warmup_iters:
return (it+1) / args.warmup_iters
# 2) constant lr for a while
elif it < args.num_iterations - args.cooldown_iters:
return 1.0
# 3) linear cooldown
else:
decay_ratio = (args.num_iterations - it) / args.cooldown_iters
return decay_ratio
schedulers = [torch.optim.lr_scheduler.LambdaLR(opt, get_lr) for opt in optimizers]
# Start training loop
training_time_ms = 0
# start the clock
torch.cuda.synchronize()
t0 = time.time()
# begin training
for step in range(args.num_iterations + 1):
last_step = (step == args.num_iterations)
# Set the attention blocksize for the current step, in chunks of 64
attn_blocksize = torch.tensor(64*((step/args.num_iterations * (1792 - 64) + 64)//64), dtype=torch.int, device='cuda')
# This effectively ignores timing first 10 steps, which are slower for weird reasons.
# Alternately, and slightly more correctly in terms of benchmarking, we could do 10
# steps with dummy data first, and then re-initialize the model and reset the loader.
if step == 10:
training_time_ms = 0
t0 = time.time()
timed_steps = float('nan') if step <= 11 else (step - 10) + 1 # <= 11 to avoid bug in val
# once in a while evaluate the validation dataset
if (last_step or (args.val_loss_every > 0 and step % args.val_loss_every == 0)):
# stop the clock
torch.cuda.synchronize()
training_time_ms += 1000 * (time.time() - t0)
# run validation batches
model.eval()
val_loader.reset()
val_loss = 0.0
for _ in range(val_steps):
with torch.no_grad():
x_val, y_val = val_loader.next_batch()
val_loss += model(x_val, y_val, attn_blocksize=attn_blocksize)
dist.all_reduce(val_loss, op=dist.ReduceOp.AVG)
val_loss /= val_steps
# log val loss to console and to logfile
print0(f'step:{step}/{args.num_iterations} val_loss:{val_loss:.4f} train_time:{training_time_ms:.0f}ms step_avg:{training_time_ms/(timed_steps-1):.2f}ms')
# start the clock again
torch.cuda.synchronize()
t0 = time.time()
if master_process and (last_step or (args.save_every > 0 and step % args.save_every == 0)):
# stop the clock
torch.cuda.synchronize()
training_time_ms += 1000 * (time.time() - t0)
# save the state of the training process
log = dict(step=step, code=code, model=raw_model.state_dict(), optimizers=[opt.state_dict() for opt in optimizers])
torch.save(log, 'logs/%s/state_step%06d.pt' % (run_id, step))
# start the clock again
torch.cuda.synchronize()
t0 = time.time()
# bit confusing: we want to make sure to eval on 0th iteration
# but also after the very last iteration. so we loop for step <= num_iterations
# instead of just < num_iterations (one extra due to <=), only to do
# the validation/sampling one last time, and then we break right here as we're done.
if last_step:
break
# --------------- TRAINING SECTION BEGIN -----------------
model.train()
for i in range(1, train_accumulation_steps+1):
# forward pass
loss = model(x, y, attn_blocksize=attn_blocksize)
train_loss = loss.detach()
# advance the dataset for the next batch
x, y = train_loader.next_batch()
# backward pass
if i < train_accumulation_steps:
with model.no_sync(): # there's no need to sync gradients every accumulation step
loss.backward()
else:
loss.backward() # just sync on the last step
for p in model.parameters():
p.grad /= train_accumulation_steps
# momentum warmup for Muon
frac = min(step/300, 1)
optimizer3.param_groups[0]['momentum'] = (1 - frac) * 0.85 + frac * 0.95
# step the optimizers and schedulers
for opt, sched in zip(optimizers, schedulers):
opt.step()
sched.step()
# null the gradients
model.zero_grad(set_to_none=True)
# --------------- TRAINING SECTION END -------------------
# everything that follows now is just diagnostics, prints, logging, etc.
#dist.all_reduce(train_loss, op=dist.ReduceOp.AVG) # all-reducing the training loss would be more correct in terms of logging, but slower
approx_time = training_time_ms + 1000 * (time.time() - t0)
print0(f"step:{step+1}/{args.num_iterations} train_loss:{train_loss.item():.4f} train_time:{approx_time:.0f}ms step_avg:{approx_time/timed_steps:.2f}ms")
if master_process:
print(f"peak memory consumption: {torch.cuda.max_memory_allocated() // 1024 // 1024} MiB")
# -------------------------------------------------------------------------
# clean up nice
dist.destroy_process_group()
====================================================================================================
Running pytorch 2.6.0.dev20241124+cu124 compiled for CUDA 12.4
nvidia-smi:
Sun Nov 24 23:51:19 2024
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 555.42.06 Driver Version: 555.42.06 CUDA Version: 12.5 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA H100 80GB HBM3 Off | 00000000:18:00.0 Off | 0 |
| N/A 32C P0 69W / 700W | 4MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 1 NVIDIA H100 80GB HBM3 Off | 00000000:2A:00.0 Off | 0 |
| N/A 37C P0 71W / 700W | 4MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 2 NVIDIA H100 80GB HBM3 Off | 00000000:3A:00.0 Off | 0 |
| N/A 38C P0 69W / 700W | 4MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 3 NVIDIA H100 80GB HBM3 Off | 00000000:5D:00.0 Off | 0 |
| N/A 32C P0 70W / 700W | 4MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 4 NVIDIA H100 80GB HBM3 Off | 00000000:84:00.0 Off | 0 |
| N/A 31C P0 71W / 700W | 4MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 5 NVIDIA H100 80GB HBM3 Off | 00000000:8B:00.0 Off | 0 |
| N/A 38C P0 78W / 700W | 4MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 6 NVIDIA H100 80GB HBM3 Off | 00000000:91:00.0 Off | 0 |
| N/A 35C P0 70W / 700W | 4MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 7 NVIDIA H100 80GB HBM3 Off | 00000000:E4:00.0 Off | 0 |
| N/A 31C P0 72W / 700W | 4MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| No running processes found |
+-----------------------------------------------------------------------------------------+
====================================================================================================
Training DataLoader: total number of tokens: 1800000000 across 18 files
Validation DataLoader: total number of tokens: 100000000 across 1 files
====================================================================================================
step:0/1750 val_loss:10.8258 train_time:0ms step_avg:nanms
step:1/1750 train_loss:10.8258 train_time:25934ms step_avg:nanms
step:2/1750 train_loss:10.0766 train_time:26043ms step_avg:nanms
step:3/1750 train_loss:8.3653 train_time:26190ms step_avg:nanms
step:4/1750 train_loss:7.5805 train_time:26336ms step_avg:nanms
step:5/1750 train_loss:7.4751 train_time:26482ms step_avg:nanms
step:6/1750 train_loss:6.9705 train_time:26632ms step_avg:nanms
step:7/1750 train_loss:7.1962 train_time:26780ms step_avg:nanms
step:8/1750 train_loss:6.7268 train_time:26928ms step_avg:nanms
step:9/1750 train_loss:6.6169 train_time:27077ms step_avg:nanms
step:10/1750 train_loss:6.5023 train_time:27224ms step_avg:nanms
step:11/1750 train_loss:6.4319 train_time:110ms step_avg:nanms
step:12/1750 train_loss:6.3437 train_time:257ms step_avg:nanms
step:13/1750 train_loss:6.2507 train_time:405ms step_avg:135.01ms
step:14/1750 train_loss:6.2731 train_time:552ms step_avg:138.04ms
step:15/1750 train_loss:6.2133 train_time:699ms step_avg:139.89ms
step:16/1750 train_loss:6.1609 train_time:847ms step_avg:141.20ms
step:17/1750 train_loss:6.2056 train_time:995ms step_avg:142.13ms
step:18/1750 train_loss:6.0426 train_time:1143ms step_avg:142.82ms
step:19/1750 train_loss:6.0317 train_time:1291ms step_avg:143.42ms
step:20/1750 train_loss:5.7627 train_time:1438ms step_avg:143.82ms
step:21/1750 train_loss:6.0271 train_time:1587ms step_avg:144.24ms
step:22/1750 train_loss:6.2338 train_time:1733ms step_avg:144.44ms
step:23/1750 train_loss:5.9295 train_time:1881ms step_avg:144.69ms
step:24/1750 train_loss:6.1256 train_time:2030ms step_avg:144.97ms
step:25/1750 train_loss:5.7872 train_time:2177ms step_avg:145.12ms
step:26/1750 train_loss:5.7024 train_time:2325ms step_avg:145.31ms
step:27/1750 train_loss:5.8846 train_time:2474ms step_avg:145.52ms
step:28/1750 train_loss:5.5120 train_time:2621ms step_avg:145.63ms
step:29/1750 train_loss:5.7698 train_time:2769ms step_avg:145.76ms
step:30/1750 train_loss:5.6027 train_time:2916ms step_avg:145.80ms
step:31/1750 train_loss:5.5439 train_time:3065ms step_avg:145.95ms
step:32/1750 train_loss:5.4227 train_time:3213ms step_avg:146.06ms
step:33/1750 train_loss:5.6913 train_time:3361ms step_avg:146.12ms
step:34/1750 train_loss:5.5964 train_time:3509ms step_avg:146.23ms
step:35/1750 train_loss:5.7332 train_time:3656ms step_avg:146.23ms
step:36/1750 train_loss:5.6460 train_time:3804ms step_avg:146.31ms
step:37/1750 train_loss:5.5613 train_time:3951ms step_avg:146.33ms
step:38/1750 train_loss:5.4404 train_time:4101ms step_avg:146.47ms
step:39/1750 train_loss:5.4399 train_time:4246ms step_avg:146.42ms
step:40/1750 train_loss:5.3656 train_time:4394ms step_avg:146.47ms
step:41/1750 train_loss:5.3383 train_time:4541ms step_avg:146.47ms
step:42/1750 train_loss:5.2784 train_time:4690ms step_avg:146.55ms
step:43/1750 train_loss:5.3517 train_time:4837ms step_avg:146.57ms
step:44/1750 train_loss:5.3291 train_time:4985ms step_avg:146.63ms
step:45/1750 train_loss:5.4913 train_time:5133ms step_avg:146.64ms
step:46/1750 train_loss:5.2769 train_time:5279ms step_avg:146.65ms
step:47/1750 train_loss:5.1685 train_time:5429ms step_avg:146.74ms
step:48/1750 train_loss:5.3229 train_time:5575ms step_avg:146.72ms
step:49/1750 train_loss:5.2500 train_time:5723ms step_avg:146.74ms
step:50/1750 train_loss:5.3464 train_time:5871ms step_avg:146.78ms
step:51/1750 train_loss:5.2566 train_time:6018ms step_avg:146.78ms
step:52/1750 train_loss:5.1185 train_time:6166ms step_avg:146.82ms
step:53/1750 train_loss:5.2594 train_time:6314ms step_avg:146.84ms
step:54/1750 train_loss:5.1030 train_time:6462ms step_avg:146.85ms
step:55/1750 train_loss:5.4978 train_time:6610ms step_avg:146.88ms
step:56/1750 train_loss:5.1336 train_time:6756ms step_avg:146.87ms
step:57/1750 train_loss:4.9779 train_time:6905ms step_avg:146.91ms
step:58/1750 train_loss:5.0956 train_time:7052ms step_avg:146.91ms
step:59/1750 train_loss:5.0889 train_time:7200ms step_avg:146.93ms
step:60/1750 train_loss:5.2175 train_time:7348ms step_avg:146.95ms
step:61/1750 train_loss:4.9370 train_time:7495ms step_avg:146.97ms
step:62/1750 train_loss:5.0775 train_time:7643ms step_avg:146.97ms
step:63/1750 train_loss:5.0940 train_time:7791ms step_avg:146.99ms
step:64/1750 train_loss:4.9779 train_time:7937ms step_avg:146.98ms
step:65/1750 train_loss:4.9208 train_time:8085ms step_avg:147.01ms
step:66/1750 train_loss:5.0614 train_time:8233ms step_avg:147.01ms
step:67/1750 train_loss:4.9101 train_time:8380ms step_avg:147.01ms
step:68/1750 train_loss:5.1747 train_time:8527ms step_avg:147.02ms
step:69/1750 train_loss:4.8040 train_time:8674ms step_avg:147.02ms
step:70/1750 train_loss:4.9205 train_time:8821ms step_avg:147.02ms
step:71/1750 train_loss:5.0490 train_time:8971ms step_avg:147.06ms
step:72/1750 train_loss:4.9796 train_time:9118ms step_avg:147.06ms
step:73/1750 train_loss:4.8689 train_time:9266ms step_avg:147.08ms
step:74/1750 train_loss:5.0052 train_time:9414ms step_avg:147.10ms
step:75/1750 train_loss:4.9594 train_time:9560ms step_avg:147.08ms
step:76/1750 train_loss:4.8723 train_time:9710ms step_avg:147.12ms
step:77/1750 train_loss:4.9814 train_time:9857ms step_avg:147.11ms
step:78/1750 train_loss:5.1696 train_time:10004ms step_avg:147.12ms
step:79/1750 train_loss:4.9163 train_time:10151ms step_avg:147.11ms
step:80/1750 train_loss:4.9234 train_time:10297ms step_avg:147.11ms
step:81/1750 train_loss:4.7054 train_time:10444ms step_avg:147.10ms
step:82/1750 train_loss:4.8835 train_time:10592ms step_avg:147.10ms
step:83/1750 train_loss:4.8528 train_time:10738ms step_avg:147.10ms
step:84/1750 train_loss:4.8401 train_time:10887ms step_avg:147.12ms
step:85/1750 train_loss:4.6775 train_time:11034ms step_avg:147.13ms
step:86/1750 train_loss:4.8860 train_time:11182ms step_avg:147.14ms
step:87/1750 train_loss:4.8130 train_time:11331ms step_avg:147.15ms
step:88/1750 train_loss:4.8258 train_time:11476ms step_avg:147.13ms
step:89/1750 train_loss:4.7689 train_time:11625ms step_avg:147.15ms
step:90/1750 train_loss:4.7086 train_time:11773ms step_avg:147.16ms
step:91/1750 train_loss:4.6883 train_time:11920ms step_avg:147.16ms
step:92/1750 train_loss:4.8291 train_time:12068ms step_avg:147.18ms
step:93/1750 train_loss:4.6434 train_time:12216ms step_avg:147.18ms
step:94/1750 train_loss:4.6840 train_time:12364ms step_avg:147.19ms
step:95/1750 train_loss:4.7126 train_time:12511ms step_avg:147.19ms
step:96/1750 train_loss:4.6342 train_time:12657ms step_avg:147.18ms
step:97/1750 train_loss:4.6770 train_time:12806ms step_avg:147.20ms
step:98/1750 train_loss:4.6058 train_time:12952ms step_avg:147.19ms
step:99/1750 train_loss:4.6991 train_time:13101ms step_avg:147.20ms
step:100/1750 train_loss:4.7111 train_time:13248ms step_avg:147.20ms
step:101/1750 train_loss:4.5723 train_time:13395ms step_avg:147.20ms
step:102/1750 train_loss:4.7485 train_time:13543ms step_avg:147.20ms
step:103/1750 train_loss:4.6177 train_time:13690ms step_avg:147.20ms
step:104/1750 train_loss:4.6097 train_time:13837ms step_avg:147.20ms
step:105/1750 train_loss:4.6034 train_time:13984ms step_avg:147.20ms
step:106/1750 train_loss:4.6558 train_time:14131ms step_avg:147.20ms
step:107/1750 train_loss:4.5448 train_time:14278ms step_avg:147.20ms
step:108/1750 train_loss:4.3998 train_time:14426ms step_avg:147.20ms
step:109/1750 train_loss:4.5249 train_time:14573ms step_avg:147.20ms
step:110/1750 train_loss:4.5033 train_time:14720ms step_avg:147.20ms
step:111/1750 train_loss:4.4468 train_time:14868ms step_avg:147.21ms
step:112/1750 train_loss:4.6149 train_time:15015ms step_avg:147.20ms
step:113/1750 train_loss:4.5111 train_time:15162ms step_avg:147.21ms
step:114/1750 train_loss:4.3792 train_time:15310ms step_avg:147.21ms
step:115/1750 train_loss:4.5382 train_time:15457ms step_avg:147.21ms
step:116/1750 train_loss:4.5196 train_time:15605ms step_avg:147.22ms
step:117/1750 train_loss:4.4159 train_time:15752ms step_avg:147.21ms
step:118/1750 train_loss:4.6410 train_time:15899ms step_avg:147.21ms
step:119/1750 train_loss:4.5005 train_time:16046ms step_avg:147.21ms
step:120/1750 train_loss:4.3870 train_time:16193ms step_avg:147.21ms
step:121/1750 train_loss:4.3378 train_time:16340ms step_avg:147.21ms
step:122/1750 train_loss:4.4903 train_time:16488ms step_avg:147.21ms
step:123/1750 train_loss:4.3314 train_time:16635ms step_avg:147.21ms
step:124/1750 train_loss:4.6379 train_time:16782ms step_avg:147.21ms
step:125/1750 train_loss:4.5071 train_time:16929ms step_avg:147.21ms
step:125/1750 val_loss:4.4525 train_time:16966ms step_avg:147.53ms
step:126/1750 train_loss:4.4621 train_time:17077ms step_avg:147.21ms
step:127/1750 train_loss:4.4885 train_time:17226ms step_avg:147.23ms
step:128/1750 train_loss:4.4269 train_time:17374ms step_avg:147.24ms
step:129/1750 train_loss:4.7320 train_time:17521ms step_avg:147.24ms
step:130/1750 train_loss:4.4166 train_time:17668ms step_avg:147.24ms
step:131/1750 train_loss:4.4279 train_time:17818ms step_avg:147.26ms
step:132/1750 train_loss:4.3711 train_time:17968ms step_avg:147.28ms
step:133/1750 train_loss:4.4760 train_time:18119ms step_avg:147.31ms
step:134/1750 train_loss:4.2876 train_time:18270ms step_avg:147.34ms
step:135/1750 train_loss:4.4712 train_time:18420ms step_avg:147.36ms
step:136/1750 train_loss:4.2401 train_time:18570ms step_avg:147.38ms
step:137/1750 train_loss:4.3897 train_time:18721ms step_avg:147.41ms
step:138/1750 train_loss:4.3043 train_time:18873ms step_avg:147.44ms
step:139/1750 train_loss:4.4004 train_time:19024ms step_avg:147.47ms
step:140/1750 train_loss:4.4955 train_time:19175ms step_avg:147.50ms
step:141/1750 train_loss:4.3353 train_time:19325ms step_avg:147.52ms
step:142/1750 train_loss:4.3288 train_time:19476ms step_avg:147.54ms
step:143/1750 train_loss:4.2769 train_time:19627ms step_avg:147.57ms
step:144/1750 train_loss:4.3734 train_time:19777ms step_avg:147.59ms
step:145/1750 train_loss:4.3206 train_time:19928ms step_avg:147.61ms
step:146/1750 train_loss:4.1905 train_time:20078ms step_avg:147.63ms
step:147/1750 train_loss:4.3475 train_time:20229ms step_avg:147.66ms
step:148/1750 train_loss:4.3774 train_time:20379ms step_avg:147.67ms
step:149/1750 train_loss:4.3196 train_time:20530ms step_avg:147.69ms
step:150/1750 train_loss:4.4540 train_time:20679ms step_avg:147.71ms
step:151/1750 train_loss:4.2885 train_time:20830ms step_avg:147.73ms
step:152/1750 train_loss:4.3078 train_time:20980ms step_avg:147.74ms
step:153/1750 train_loss:4.3904 train_time:21132ms step_avg:147.78ms
step:154/1750 train_loss:4.3786 train_time:21282ms step_avg:147.79ms
step:155/1750 train_loss:4.3020 train_time:21433ms step_avg:147.81ms
step:156/1750 train_loss:4.3664 train_time:21583ms step_avg:147.83ms
step:157/1750 train_loss:4.4244 train_time:21735ms step_avg:147.85ms
step:158/1750 train_loss:4.2624 train_time:21885ms step_avg:147.87ms
step:159/1750 train_loss:4.3248 train_time:22036ms step_avg:147.89ms
step:160/1750 train_loss:4.1253 train_time:22186ms step_avg:147.91ms
step:161/1750 train_loss:4.3609 train_time:22336ms step_avg:147.92ms
step:162/1750 train_loss:4.3784 train_time:22486ms step_avg:147.94ms
step:163/1750 train_loss:4.3615 train_time:22637ms step_avg:147.95ms
step:164/1750 train_loss:4.2182 train_time:22787ms step_avg:147.97ms
step:165/1750 train_loss:4.3094 train_time:22937ms step_avg:147.98ms
step:166/1750 train_loss:4.3773 train_time:23087ms step_avg:148.00ms
step:167/1750 train_loss:4.2294 train_time:23238ms step_avg:148.01ms
step:168/1750 train_loss:4.3060 train_time:23388ms step_avg:148.03ms
step:169/1750 train_loss:4.1737 train_time:23538ms step_avg:148.04ms
step:170/1750 train_loss:4.0399 train_time:23689ms step_avg:148.05ms
step:171/1750 train_loss:4.2274 train_time:23838ms step_avg:148.06ms
step:172/1750 train_loss:4.2354 train_time:23989ms step_avg:148.08ms
step:173/1750 train_loss:4.2928 train_time:24138ms step_avg:148.09ms
step:174/1750 train_loss:4.4523 train_time:24288ms step_avg:148.10ms
step:175/1750 train_loss:4.2760 train_time:24439ms step_avg:148.12ms
step:176/1750 train_loss:4.1184 train_time:24589ms step_avg:148.12ms
step:177/1750 train_loss:4.0886 train_time:24739ms step_avg:148.14ms
step:178/1750 train_loss:4.2154 train_time:24890ms step_avg:148.15ms
step:179/1750 train_loss:4.1557 train_time:25039ms step_avg:148.16ms
step:180/1750 train_loss:4.1469 train_time:25189ms step_avg:148.17ms
step:181/1750 train_loss:4.3236 train_time:25339ms step_avg:148.18ms
step:182/1750 train_loss:4.1799 train_time:25489ms step_avg:148.19ms
step:183/1750 train_loss:4.1556 train_time:25639ms step_avg:148.20ms
step:184/1750 train_loss:4.1526 train_time:25789ms step_avg:148.22ms
step:185/1750 train_loss:4.2293 train_time:25939ms step_avg:148.22ms
step:186/1750 train_loss:4.1922 train_time:26089ms step_avg:148.24ms
step:187/1750 train_loss:4.2548 train_time:26240ms step_avg:148.25ms
step:188/1750 train_loss:4.1981 train_time:26514ms step_avg:148.95ms
step:189/1750 train_loss:4.1424 train_time:26820ms step_avg:149.83ms
step:190/1750 train_loss:4.2506 train_time:26972ms step_avg:149.84ms
step:191/1750 train_loss:4.1221 train_time:27123ms step_avg:149.85ms
step:192/1750 train_loss:4.0605 train_time:27273ms step_avg:149.85ms
step:193/1750 train_loss:4.2805 train_time:27424ms step_avg:149.86ms
step:194/1750 train_loss:4.2088 train_time:27574ms step_avg:149.86ms
step:195/1750 train_loss:4.3881 train_time:27724ms step_avg:149.86ms
step:196/1750 train_loss:4.2120 train_time:27874ms step_avg:149.86ms
step:197/1750 train_loss:4.0693 train_time:28023ms step_avg:149.86ms
step:198/1750 train_loss:4.2003 train_time:28173ms step_avg:149.85ms
step:199/1750 train_loss:4.0511 train_time:28322ms step_avg:149.85ms
step:200/1750 train_loss:4.1484 train_time:28472ms step_avg:149.85ms
step:201/1750 train_loss:4.0272 train_time:28622ms step_avg:149.85ms
step:202/1750 train_loss:4.2761 train_time:28771ms step_avg:149.85ms
step:203/1750 train_loss:4.0759 train_time:28921ms step_avg:149.85ms
step:204/1750 train_loss:4.2039 train_time:29071ms step_avg:149.85ms
step:205/1750 train_loss:4.2676 train_time:29220ms step_avg:149.84ms
step:206/1750 train_loss:3.9671 train_time:29369ms step_avg:149.84ms
step:207/1750 train_loss:4.1145 train_time:29518ms step_avg:149.84ms
step:208/1750 train_loss:4.1247 train_time:29668ms step_avg:149.84ms
step:209/1750 train_loss:4.2504 train_time:29817ms step_avg:149.84ms
step:210/1750 train_loss:4.2004 train_time:29967ms step_avg:149.83ms
step:211/1750 train_loss:4.0722 train_time:30116ms step_avg:149.83ms
step:212/1750 train_loss:4.1307 train_time:30265ms step_avg:149.83ms
step:213/1750 train_loss:4.0654 train_time:30415ms step_avg:149.83ms
step:214/1750 train_loss:4.1209 train_time:30565ms step_avg:149.83ms
step:215/1750 train_loss:3.9646 train_time:30715ms step_avg:149.83ms
step:216/1750 train_loss:4.0177 train_time:30864ms step_avg:149.83ms
step:217/1750 train_loss:4.0249 train_time:31014ms step_avg:149.83ms
step:218/1750 train_loss:4.0899 train_time:31164ms step_avg:149.83ms
step:219/1750 train_loss:4.0814 train_time:31314ms step_avg:149.83ms
step:220/1750 train_loss:4.1020 train_time:31462ms step_avg:149.82ms
step:221/1750 train_loss:4.1017 train_time:31614ms step_avg:149.83ms
step:222/1750 train_loss:4.0077 train_time:31762ms step_avg:149.82ms
step:223/1750 train_loss:4.0071 train_time:31913ms step_avg:149.83ms
step:224/1750 train_loss:4.3088 train_time:32063ms step_avg:149.83ms
step:225/1750 train_loss:3.9098 train_time:32213ms step_avg:149.83ms
step:226/1750 train_loss:4.0050 train_time:32362ms step_avg:149.82ms
step:227/1750 train_loss:3.9988 train_time:32512ms step_avg:149.83ms
step:228/1750 train_loss:4.1639 train_time:32661ms step_avg:149.82ms
step:229/1750 train_loss:3.9501 train_time:32812ms step_avg:149.83ms
step:230/1750 train_loss:4.0698 train_time:32962ms step_avg:149.83ms
step:231/1750 train_loss:3.9198 train_time:33113ms step_avg:149.83ms
step:232/1750 train_loss:3.9922 train_time:33261ms step_avg:149.83ms
step:233/1750 train_loss:4.1040 train_time:33412ms step_avg:149.83ms
step:234/1750 train_loss:4.0495 train_time:33561ms step_avg:149.83ms
step:235/1750 train_loss:3.9328 train_time:33712ms step_avg:149.83ms
step:236/1750 train_loss:4.1084 train_time:33861ms step_avg:149.83ms
step:237/1750 train_loss:4.1049 train_time:34013ms step_avg:149.84ms
step:238/1750 train_loss:3.9616 train_time:34163ms step_avg:149.84ms
step:239/1750 train_loss:4.1074 train_time:34313ms step_avg:149.84ms
step:240/1750 train_loss:4.1327 train_time:34462ms step_avg:149.84ms
step:241/1750 train_loss:3.9865 train_time:34613ms step_avg:149.84ms
step:242/1750 train_loss:4.1654 train_time:34762ms step_avg:149.84ms
step:243/1750 train_loss:4.0424 train_time:34913ms step_avg:149.84ms
step:244/1750 train_loss:4.0961 train_time:35062ms step_avg:149.84ms
step:245/1750 train_loss:4.1739 train_time:35212ms step_avg:149.84ms
step:246/1750 train_loss:4.0925 train_time:35361ms step_avg:149.84ms
step:247/1750 train_loss:4.0322 train_time:35512ms step_avg:149.84ms
step:248/1750 train_loss:4.1462 train_time:35660ms step_avg:149.83ms
step:249/1750 train_loss:3.9380 train_time:35811ms step_avg:149.84ms
step:250/1750 train_loss:3.9945 train_time:35960ms step_avg:149.83ms
step:250/1750 val_loss:4.0305 train_time:35999ms step_avg:150.00ms
step:251/1750 train_loss:4.1017 train_time:36112ms step_avg:149.84ms
step:252/1750 train_loss:4.1932 train_time:36261ms step_avg:149.84ms
step:253/1750 train_loss:3.9562 train_time:36412ms step_avg:149.84ms
step:254/1750 train_loss:3.9096 train_time:36561ms step_avg:149.84ms
step:255/1750 train_loss:4.0929 train_time:36711ms step_avg:149.84ms
step:256/1750 train_loss:4.0157 train_time:36859ms step_avg:149.83ms
step:257/1750 train_loss:4.0138 train_time:37009ms step_avg:149.83ms
step:258/1750 train_loss:4.0054 train_time:37158ms step_avg:149.83ms
step:259/1750 train_loss:4.0479 train_time:37308ms step_avg:149.83ms
step:260/1750 train_loss:4.0866 train_time:37456ms step_avg:149.82ms
step:261/1750 train_loss:4.0421 train_time:37608ms step_avg:149.83ms
step:262/1750 train_loss:4.0119 train_time:37761ms step_avg:149.85ms
step:263/1750 train_loss:3.9180 train_time:37913ms step_avg:149.85ms
step:264/1750 train_loss:4.0117 train_time:38066ms step_avg:149.86ms
step:265/1750 train_loss:3.8914 train_time:38219ms step_avg:149.88ms
step:266/1750 train_loss:3.9379 train_time:38370ms step_avg:149.88ms
step:267/1750 train_loss:3.9489 train_time:38523ms step_avg:149.89ms
step:268/1750 train_loss:3.9703 train_time:38676ms step_avg:149.91ms
step:269/1750 train_loss:3.8763 train_time:38829ms step_avg:149.92ms
step:270/1750 train_loss:4.1192 train_time:38981ms step_avg:149.93ms
step:271/1750 train_loss:3.9915 train_time:39134ms step_avg:149.94ms
step:272/1750 train_loss:3.9436 train_time:39286ms step_avg:149.95ms
step:273/1750 train_loss:3.9637 train_time:39438ms step_avg:149.95ms
step:274/1750 train_loss:4.0537 train_time:39590ms step_avg:149.96ms
step:275/1750 train_loss:4.0732 train_time:39743ms step_avg:149.97ms
step:276/1750 train_loss:4.2472 train_time:39895ms step_avg:149.98ms
step:277/1750 train_loss:4.0553 train_time:40048ms step_avg:149.99ms
step:278/1750 train_loss:4.1055 train_time:40201ms step_avg:150.00ms
step:279/1750 train_loss:4.0129 train_time:40354ms step_avg:150.01ms
step:280/1750 train_loss:4.1926 train_time:40507ms step_avg:150.03ms
step:281/1750 train_loss:3.9846 train_time:40658ms step_avg:150.03ms
step:282/1750 train_loss:3.9657 train_time:40812ms step_avg:150.04ms
step:283/1750 train_loss:3.9329 train_time:40963ms step_avg:150.05ms
step:284/1750 train_loss:4.0628 train_time:41115ms step_avg:150.05ms
step:285/1750 train_loss:4.0851 train_time:41268ms step_avg:150.06ms
step:286/1750 train_loss:4.1027 train_time:41420ms step_avg:150.07ms
step:287/1750 train_loss:3.9313 train_time:41573ms step_avg:150.08ms
step:288/1750 train_loss:4.0320 train_time:41726ms step_avg:150.09ms
step:289/1750 train_loss:3.9045 train_time:41877ms step_avg:150.10ms
step:290/1750 train_loss:3.8796 train_time:42031ms step_avg:150.11ms
step:291/1750 train_loss:3.9323 train_time:42183ms step_avg:150.12ms
step:292/1750 train_loss:3.8818 train_time:42336ms step_avg:150.13ms
step:293/1750 train_loss:3.9313 train_time:42488ms step_avg:150.14ms
step:294/1750 train_loss:3.9697 train_time:42641ms step_avg:150.15ms
step:295/1750 train_loss:3.8571 train_time:42794ms step_avg:150.15ms
step:296/1750 train_loss:3.8805 train_time:42948ms step_avg:150.17ms
step:297/1750 train_loss:3.8896 train_time:43099ms step_avg:150.17ms
step:298/1750 train_loss:3.9989 train_time:43252ms step_avg:150.18ms
step:299/1750 train_loss:3.8336 train_time:43404ms step_avg:150.19ms
step:300/1750 train_loss:3.9831 train_time:43557ms step_avg:150.20ms
step:301/1750 train_loss:3.9973 train_time:43710ms step_avg:150.21ms
step:302/1750 train_loss:3.9543 train_time:43862ms step_avg:150.21ms
step:303/1750 train_loss:4.0052 train_time:44015ms step_avg:150.22ms
step:304/1750 train_loss:3.9850 train_time:44168ms step_avg:150.23ms
step:305/1750 train_loss:4.4855 train_time:44320ms step_avg:150.24ms
step:306/1750 train_loss:3.9566 train_time:44473ms step_avg:150.25ms
step:307/1750 train_loss:3.8560 train_time:44626ms step_avg:150.26ms
step:308/1750 train_loss:4.0028 train_time:44778ms step_avg:150.26ms
step:309/1750 train_loss:3.8757 train_time:44931ms step_avg:150.27ms
step:310/1750 train_loss:4.1013 train_time:45083ms step_avg:150.28ms
step:311/1750 train_loss:3.9526 train_time:45236ms step_avg:150.29ms
step:312/1750 train_loss:3.8890 train_time:45388ms step_avg:150.29ms
step:313/1750 train_loss:3.9615 train_time:45539ms step_avg:150.29ms
step:314/1750 train_loss:4.0923 train_time:45692ms step_avg:150.30ms
step:315/1750 train_loss:3.9657 train_time:45844ms step_avg:150.31ms
step:316/1750 train_loss:3.8177 train_time:45996ms step_avg:150.31ms
step:317/1750 train_loss:3.8957 train_time:46150ms step_avg:150.33ms
step:318/1750 train_loss:3.9405 train_time:46301ms step_avg:150.33ms
step:319/1750 train_loss:3.9148 train_time:46454ms step_avg:150.34ms
step:320/1750 train_loss:4.0362 train_time:46607ms step_avg:150.34ms
step:321/1750 train_loss:3.9782 train_time:46758ms step_avg:150.35ms
step:322/1750 train_loss:3.9481 train_time:46911ms step_avg:150.36ms
step:323/1750 train_loss:4.0306 train_time:47063ms step_avg:150.36ms
step:324/1750 train_loss:3.9710 train_time:47215ms step_avg:150.37ms
step:325/1750 train_loss:4.0359 train_time:47368ms step_avg:150.38ms
step:326/1750 train_loss:3.9149 train_time:47520ms step_avg:150.38ms
step:327/1750 train_loss:4.4072 train_time:47672ms step_avg:150.39ms
step:328/1750 train_loss:4.0964 train_time:47824ms step_avg:150.39ms
step:329/1750 train_loss:3.8133 train_time:47975ms step_avg:150.39ms
step:330/1750 train_loss:3.7676 train_time:48128ms step_avg:150.40ms
step:331/1750 train_loss:3.9926 train_time:48280ms step_avg:150.40ms
step:332/1750 train_loss:3.9330 train_time:48432ms step_avg:150.41ms
step:333/1750 train_loss:3.8999 train_time:48583ms step_avg:150.41ms
step:334/1750 train_loss:3.8562 train_time:48735ms step_avg:150.42ms
step:335/1750 train_loss:4.0258 train_time:48886ms step_avg:150.42ms
step:336/1750 train_loss:3.9799 train_time:49037ms step_avg:150.42ms
step:337/1750 train_loss:4.4417 train_time:49190ms step_avg:150.43ms
step:338/1750 train_loss:3.9671 train_time:49341ms step_avg:150.43ms
step:339/1750 train_loss:3.8896 train_time:49492ms step_avg:150.43ms
step:340/1750 train_loss:3.9522 train_time:49646ms step_avg:150.44ms
step:341/1750 train_loss:3.8739 train_time:49797ms step_avg:150.44ms
step:342/1750 train_loss:3.8280 train_time:49950ms step_avg:150.45ms
step:343/1750 train_loss:3.8582 train_time:50101ms step_avg:150.45ms
step:344/1750 train_loss:4.0137 train_time:50252ms step_avg:150.46ms
step:345/1750 train_loss:3.8449 train_time:50404ms step_avg:150.46ms
step:346/1750 train_loss:3.7857 train_time:50555ms step_avg:150.46ms
step:347/1750 train_loss:3.8223 train_time:50707ms step_avg:150.47ms
step:348/1750 train_loss:3.8721 train_time:50858ms step_avg:150.47ms
step:349/1750 train_loss:3.8523 train_time:51011ms step_avg:150.47ms
step:350/1750 train_loss:3.5830 train_time:51162ms step_avg:150.48ms
step:351/1750 train_loss:3.8397 train_time:51314ms step_avg:150.48ms
step:352/1750 train_loss:4.2055 train_time:51465ms step_avg:150.48ms
step:353/1750 train_loss:3.6748 train_time:51617ms step_avg:150.49ms
step:354/1750 train_loss:3.9460 train_time:51769ms step_avg:150.49ms
step:355/1750 train_loss:3.8029 train_time:51921ms step_avg:150.50ms
step:356/1750 train_loss:3.8962 train_time:52073ms step_avg:150.50ms
step:357/1750 train_loss:3.8020 train_time:52224ms step_avg:150.50ms
step:358/1750 train_loss:3.8725 train_time:52375ms step_avg:150.50ms
step:359/1750 train_loss:3.8100 train_time:52529ms step_avg:150.51ms
step:360/1750 train_loss:3.4457 train_time:52680ms step_avg:150.51ms
step:361/1750 train_loss:4.0394 train_time:52832ms step_avg:150.52ms
step:362/1750 train_loss:3.9352 train_time:52984ms step_avg:150.52ms