forked from KellerJordan/modded-nanogpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
c87bb826-797b-4f37-98c7-d3a5dad2de74.txt
3654 lines (3581 loc) · 238 KB
/
c87bb826-797b-4f37-98c7-d3a5dad2de74.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
# -----------------------------------------------------------------------------
# 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}' \sim 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.inv_freq = 1.0 / (base ** (torch.arange(0, dim, 2).float() / dim))
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.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).to(x.device)
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=None):
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 = F.scaled_dot_product_attention(q.transpose(1, 2), k.transpose(1, 2), v.transpose(1, 2), is_causal=True)
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):
x = self.lambdas[0] * x + self.lambdas[1] * x0
x1, v1 = self.attn(F.rms_norm(x, (x.size(-1),)), v1)
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__()
self.config = config
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)]),
))
# U-net design by @brendanh0gan
self.encoder_layers = config.n_layer // 2 # Half of the layers for encoder
self.decoder_layers = config.n_layer - self.encoder_layers # Remaining for decoder
# Add learnable skip connection weights for decoder layers
self.skip_weights = nn.Parameter(torch.ones(self.decoder_layers))
self.lm_head = CastedLinear(config.n_embd, config.vocab_size, bias=False)
self.lm_head.weight.data.zero_() # @Grad62304977
def forward(self, idx, target):
# forward the GPT model itself
x = self.transformer.wte(idx) # 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.encoder_layers):
x, v1 = self.transformer.h[i](x, v1, x0)
skip_connections.append(x) # Store the output for skip connections
# Decoder pass - process the remaining blocks with weighted skip connections
for i in range(self.decoder_layers):
skip_connection = skip_connections.pop() # Get the corresponding encoder output
# Apply learnable weight to skip connection
weighted_skip = self.skip_weights[i] * skip_connection
x, v1 = self.transformer.h[self.encoder_layers + i](x + weighted_skip, v1, x0)
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.float()
# -----------------------------------------------------------------------------
# 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
# kick things off
self.reset()
def reset(self):
self.current_shard = 0
self.current_position = self.process_rank * self.B * self.T
self.tokens = _load_data_shard(self.files[self.current_shard])
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):
B = self.B
T = self.T
buf = self.tokens[self.current_position : self.current_position+B*T+1]
buf = torch.tensor(buf.astype(np.int32), dtype=torch.long)
x = (buf[:-1]).view(B, T) # inputs
y = (buf[1:]).view(B, T) # targets
# advance current position and load next shard if necessary
self.current_position += B * T * self.num_processes
if self.current_position + (B * T * self.num_processes + 1) > 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*64 # batch size, in sequences, across all devices
device_batch_size : int = 64 # batch size, in sequences, per device
sequence_length : int = 1024 # sequence length, in tokens
num_iterations : int = 3000 # number of iterations to run
warmup_iters : int = 0
warmdown_iters : int = 900 # number of iterations of linear warmup/warmdown 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.
# 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)
if master_process:
print(f"Training DataLoader: total number of tokens: {train_loader.ntok_total} across {len(train_loader.files)} files")
print(f"Validation DataLoader: total number of tokens: {val_loader.ntok_total} across {len(val_loader.files)} files")
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.9, 0.95), fused=True)
optimizer2 = torch.optim.Adam([raw_model.lm_head.weight], lr=0.008, betas=(0.9, 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.04, momentum=0.95)
optimizer4 = torch.optim.Adam(scalar_params, lr=0.04, betas=(0.9, 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 warmdown)
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.warmdown_iters:
return 1.0
# 3) linear warmdown
else:
decay_ratio = (args.num_iterations - it) / args.warmdown_iters
return decay_ratio
schedulers = [torch.optim.lr_scheduler.LambdaLR(opt, get_lr) for opt in optimizers]
# begin logging
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')
# log information about the hardware/software environment this is running on
# and print the full `nvidia-smi` to file
f.write(f"Running pytorch {torch.version.__version__} compiled for CUDA {torch.version.cuda}\nnvidia-smi:\n")
import subprocess
result = subprocess.run(['nvidia-smi'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
f.write(f'{result.stdout}\n')
f.write('='*100 + '\n')
training_time_ms = 0
# start the clock
torch.cuda.synchronize()
t0 = time.time()
# begin training
train_loader.reset()
for step in range(args.num_iterations + 1):
last_step = (step == args.num_iterations)
# 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)
dist.all_reduce(val_loss, op=dist.ReduceOp.AVG)
val_loss /= val_steps
# log val loss to console and to logfile
if master_process:
print(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')
with open(logfile, "a") as f:
f.write(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\n')
# 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)
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/500, 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
if master_process:
approx_time = training_time_ms + 1000 * (time.time() - t0)
print(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")
with open(logfile, "a") as f:
f.write(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\n")
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.5.1+cu124 compiled for CUDA 12.4
nvidia-smi:
Sun Nov 10 19:09:29 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 28C P0 113W / 700W | 5156MiB / 81559MiB | 1% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 1 NVIDIA H100 80GB HBM3 Off | 00000000:2A:00.0 Off | 0 |
| N/A 31C P0 116W / 700W | 5204MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 2 NVIDIA H100 80GB HBM3 Off | 00000000:3A:00.0 Off | 0 |
| N/A 32C P0 115W / 700W | 5204MiB / 81559MiB | 7% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 3 NVIDIA H100 80GB HBM3 Off | 00000000:5D:00.0 Off | 0 |
| N/A 28C P0 115W / 700W | 5204MiB / 81559MiB | 6% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 4 NVIDIA H100 80GB HBM3 Off | 00000000:84:00.0 Off | 0 |
| N/A 28C P0 115W / 700W | 5204MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 5 NVIDIA H100 80GB HBM3 Off | 00000000:8B:00.0 Off | 0 |
| N/A 31C P0 115W / 700W | 5204MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 6 NVIDIA H100 80GB HBM3 Off | 00000000:91:00.0 Off | 0 |
| N/A 30C P0 114W / 700W | 5204MiB / 81559MiB | 6% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
| 7 NVIDIA H100 80GB HBM3 Off | 00000000:E4:00.0 Off | 0 |
| N/A 28C P0 117W / 700W | 4964MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| 0 N/A N/A 157229 C /usr/bin/python3 0MiB |
| 1 N/A N/A 157230 C /usr/bin/python3 0MiB |
| 2 N/A N/A 157231 C /usr/bin/python3 0MiB |
| 3 N/A N/A 157232 C /usr/bin/python3 0MiB |
| 4 N/A N/A 157233 C /usr/bin/python3 0MiB |
| 5 N/A N/A 157234 C /usr/bin/python3 0MiB |
| 6 N/A N/A 157235 C /usr/bin/python3 0MiB |
| 7 N/A N/A 157236 C /usr/bin/python3 0MiB |
+-----------------------------------------------------------------------------------------+
====================================================================================================
step:0/3000 val_loss:10.8258 train_time:411ms step_avg:nanms
step:1/3000 train_loss:10.8258 train_time:14600ms step_avg:nanms
step:2/3000 train_loss:9.5118 train_time:14707ms step_avg:nanms
step:3/3000 train_loss:8.4756 train_time:14844ms step_avg:nanms
step:4/3000 train_loss:8.0097 train_time:14985ms step_avg:nanms
step:5/3000 train_loss:7.5120 train_time:15126ms step_avg:nanms
step:6/3000 train_loss:7.2826 train_time:15267ms step_avg:nanms
step:7/3000 train_loss:6.9171 train_time:15409ms step_avg:nanms
step:8/3000 train_loss:7.1124 train_time:15556ms step_avg:nanms
step:9/3000 train_loss:6.7596 train_time:15706ms step_avg:nanms
step:10/3000 train_loss:6.6236 train_time:15849ms step_avg:nanms
step:11/3000 train_loss:6.5634 train_time:106ms step_avg:nanms
step:12/3000 train_loss:6.5905 train_time:249ms step_avg:nanms
step:13/3000 train_loss:6.4862 train_time:392ms step_avg:130.53ms
step:14/3000 train_loss:6.3646 train_time:535ms step_avg:133.65ms
step:15/3000 train_loss:6.3322 train_time:678ms step_avg:135.64ms
step:16/3000 train_loss:6.2824 train_time:824ms step_avg:137.34ms
step:17/3000 train_loss:6.2691 train_time:970ms step_avg:138.53ms
step:18/3000 train_loss:6.3454 train_time:1115ms step_avg:139.35ms
step:19/3000 train_loss:6.1535 train_time:1257ms step_avg:139.64ms
step:20/3000 train_loss:6.1644 train_time:1398ms step_avg:139.84ms
step:21/3000 train_loss:5.8851 train_time:1542ms step_avg:140.15ms
step:22/3000 train_loss:6.1650 train_time:1687ms step_avg:140.59ms
step:23/3000 train_loss:6.3783 train_time:1834ms step_avg:141.07ms
step:24/3000 train_loss:6.0796 train_time:1977ms step_avg:141.23ms
step:25/3000 train_loss:6.2266 train_time:2121ms step_avg:141.40ms
step:26/3000 train_loss:5.9066 train_time:2264ms step_avg:141.52ms
step:27/3000 train_loss:5.8187 train_time:2409ms step_avg:141.71ms
step:28/3000 train_loss:6.0527 train_time:2552ms step_avg:141.80ms
step:29/3000 train_loss:5.6964 train_time:2696ms step_avg:141.89ms
step:30/3000 train_loss:5.9238 train_time:2840ms step_avg:141.98ms
step:31/3000 train_loss:5.7351 train_time:2985ms step_avg:142.14ms
step:32/3000 train_loss:5.7140 train_time:3132ms step_avg:142.38ms
step:33/3000 train_loss:5.5725 train_time:3276ms step_avg:142.43ms
step:34/3000 train_loss:5.8444 train_time:3420ms step_avg:142.48ms
step:35/3000 train_loss:5.7806 train_time:3563ms step_avg:142.51ms
step:36/3000 train_loss:5.9140 train_time:3707ms step_avg:142.57ms
step:37/3000 train_loss:5.8207 train_time:3852ms step_avg:142.67ms
step:38/3000 train_loss:5.7391 train_time:3997ms step_avg:142.74ms
step:39/3000 train_loss:5.6048 train_time:4141ms step_avg:142.79ms
step:40/3000 train_loss:5.6009 train_time:4286ms step_avg:142.88ms
step:41/3000 train_loss:5.5260 train_time:4432ms step_avg:142.98ms
step:42/3000 train_loss:5.5092 train_time:4575ms step_avg:142.97ms
step:43/3000 train_loss:5.4288 train_time:4719ms step_avg:143.00ms
step:44/3000 train_loss:5.5299 train_time:4862ms step_avg:143.00ms
step:45/3000 train_loss:5.4996 train_time:5008ms step_avg:143.08ms
step:46/3000 train_loss:5.6457 train_time:5153ms step_avg:143.13ms
step:47/3000 train_loss:5.4348 train_time:5297ms step_avg:143.15ms
step:48/3000 train_loss:5.3142 train_time:5440ms step_avg:143.15ms
step:49/3000 train_loss:5.4901 train_time:5584ms step_avg:143.18ms
step:50/3000 train_loss:5.3885 train_time:5730ms step_avg:143.25ms
step:51/3000 train_loss:5.5243 train_time:5873ms step_avg:143.25ms
step:52/3000 train_loss:5.4120 train_time:6017ms step_avg:143.25ms
step:53/3000 train_loss:5.2482 train_time:6159ms step_avg:143.24ms
step:54/3000 train_loss:5.3877 train_time:6305ms step_avg:143.29ms
step:55/3000 train_loss:5.2555 train_time:6450ms step_avg:143.32ms
step:56/3000 train_loss:5.6425 train_time:6594ms step_avg:143.36ms
step:57/3000 train_loss:5.2742 train_time:6737ms step_avg:143.34ms
step:58/3000 train_loss:5.1168 train_time:6882ms step_avg:143.37ms
step:59/3000 train_loss:5.2245 train_time:7027ms step_avg:143.41ms
step:60/3000 train_loss:5.2294 train_time:7171ms step_avg:143.42ms
step:61/3000 train_loss:5.3408 train_time:7315ms step_avg:143.44ms
step:62/3000 train_loss:5.0759 train_time:7457ms step_avg:143.40ms
step:63/3000 train_loss:5.1987 train_time:7601ms step_avg:143.42ms
step:64/3000 train_loss:5.1882 train_time:7746ms step_avg:143.44ms
step:65/3000 train_loss:4.8413 train_time:7891ms step_avg:143.48ms
step:66/3000 train_loss:5.0236 train_time:8036ms step_avg:143.49ms
step:67/3000 train_loss:5.1505 train_time:8178ms step_avg:143.47ms
step:68/3000 train_loss:5.0399 train_time:8322ms step_avg:143.49ms
step:69/3000 train_loss:5.3209 train_time:8466ms step_avg:143.49ms
step:70/3000 train_loss:4.9200 train_time:8612ms step_avg:143.54ms
step:71/3000 train_loss:5.0072 train_time:8755ms step_avg:143.53ms
step:72/3000 train_loss:5.2001 train_time:8899ms step_avg:143.54ms
step:73/3000 train_loss:5.0981 train_time:9043ms step_avg:143.54ms
step:74/3000 train_loss:4.9796 train_time:9188ms step_avg:143.57ms
step:75/3000 train_loss:5.1104 train_time:9333ms step_avg:143.59ms
step:76/3000 train_loss:5.0924 train_time:9475ms step_avg:143.57ms
step:77/3000 train_loss:5.0097 train_time:9619ms step_avg:143.57ms
step:78/3000 train_loss:5.1233 train_time:9762ms step_avg:143.55ms
step:79/3000 train_loss:5.2696 train_time:9907ms step_avg:143.57ms
step:80/3000 train_loss:4.9988 train_time:10052ms step_avg:143.60ms
step:81/3000 train_loss:5.0664 train_time:10195ms step_avg:143.59ms
step:82/3000 train_loss:4.8429 train_time:10339ms step_avg:143.59ms
step:83/3000 train_loss:5.0232 train_time:10482ms step_avg:143.60ms
step:84/3000 train_loss:4.9798 train_time:10627ms step_avg:143.61ms
step:85/3000 train_loss:4.9659 train_time:10772ms step_avg:143.62ms
step:86/3000 train_loss:4.8246 train_time:10916ms step_avg:143.64ms
step:87/3000 train_loss:5.0222 train_time:11059ms step_avg:143.62ms
step:88/3000 train_loss:4.9316 train_time:11203ms step_avg:143.62ms
step:89/3000 train_loss:4.9636 train_time:11348ms step_avg:143.65ms
step:90/3000 train_loss:4.9152 train_time:11492ms step_avg:143.65ms
step:91/3000 train_loss:4.8617 train_time:11636ms step_avg:143.65ms
step:92/3000 train_loss:4.8496 train_time:11779ms step_avg:143.64ms
step:93/3000 train_loss:4.9879 train_time:11922ms step_avg:143.64ms
step:94/3000 train_loss:4.8195 train_time:12067ms step_avg:143.65ms
step:95/3000 train_loss:4.8462 train_time:12212ms step_avg:143.67ms
step:96/3000 train_loss:4.8739 train_time:12356ms step_avg:143.67ms
step:97/3000 train_loss:4.7754 train_time:12499ms step_avg:143.67ms
step:98/3000 train_loss:4.8416 train_time:12642ms step_avg:143.66ms
step:99/3000 train_loss:4.7600 train_time:12787ms step_avg:143.67ms
step:100/3000 train_loss:4.8583 train_time:12933ms step_avg:143.70ms
step:101/3000 train_loss:4.8539 train_time:13076ms step_avg:143.69ms
step:102/3000 train_loss:4.7116 train_time:13220ms step_avg:143.70ms
step:103/3000 train_loss:4.8685 train_time:13363ms step_avg:143.69ms
step:104/3000 train_loss:4.7718 train_time:13508ms step_avg:143.70ms
step:105/3000 train_loss:4.6944 train_time:13652ms step_avg:143.71ms
step:106/3000 train_loss:4.7237 train_time:13796ms step_avg:143.71ms
step:107/3000 train_loss:4.8175 train_time:13938ms step_avg:143.69ms
step:108/3000 train_loss:4.6881 train_time:14082ms step_avg:143.70ms
step:109/3000 train_loss:4.5080 train_time:14227ms step_avg:143.71ms
step:110/3000 train_loss:4.6457 train_time:14372ms step_avg:143.72ms
step:111/3000 train_loss:4.6387 train_time:14516ms step_avg:143.72ms
step:112/3000 train_loss:4.5831 train_time:14658ms step_avg:143.71ms
step:113/3000 train_loss:4.7349 train_time:14802ms step_avg:143.71ms
step:114/3000 train_loss:4.6384 train_time:14946ms step_avg:143.71ms
step:115/3000 train_loss:4.4999 train_time:15092ms step_avg:143.73ms
step:116/3000 train_loss:4.6427 train_time:15235ms step_avg:143.73ms
step:117/3000 train_loss:4.5970 train_time:15378ms step_avg:143.72ms
step:118/3000 train_loss:4.5058 train_time:15522ms step_avg:143.72ms
step:119/3000 train_loss:4.7097 train_time:15666ms step_avg:143.72ms
step:120/3000 train_loss:4.5873 train_time:15811ms step_avg:143.74ms
step:121/3000 train_loss:4.4731 train_time:15955ms step_avg:143.74ms
step:122/3000 train_loss:4.4383 train_time:16099ms step_avg:143.74ms
step:123/3000 train_loss:4.5754 train_time:16241ms step_avg:143.73ms
step:124/3000 train_loss:4.3962 train_time:16387ms step_avg:143.74ms
step:125/3000 train_loss:4.7078 train_time:16533ms step_avg:143.76ms
step:125/3000 val_loss:4.5262 train_time:16570ms step_avg:144.09ms
step:126/3000 train_loss:4.5741 train_time:16686ms step_avg:143.85ms
step:127/3000 train_loss:4.5231 train_time:16833ms step_avg:143.88ms
step:128/3000 train_loss:4.5517 train_time:16976ms step_avg:143.87ms
step:129/3000 train_loss:4.4821 train_time:17118ms step_avg:143.85ms
step:130/3000 train_loss:4.7820 train_time:17260ms step_avg:143.84ms
step:131/3000 train_loss:4.4520 train_time:17403ms step_avg:143.83ms
step:132/3000 train_loss:4.4960 train_time:17545ms step_avg:143.81ms
step:133/3000 train_loss:4.4454 train_time:17693ms step_avg:143.84ms
step:134/3000 train_loss:4.5549 train_time:17841ms step_avg:143.88ms
step:135/3000 train_loss:4.3711 train_time:17984ms step_avg:143.87ms
step:136/3000 train_loss:4.5423 train_time:18126ms step_avg:143.86ms
step:137/3000 train_loss:4.3013 train_time:18269ms step_avg:143.85ms
step:138/3000 train_loss:4.4656 train_time:18412ms step_avg:143.84ms
step:139/3000 train_loss:4.3772 train_time:18555ms step_avg:143.83ms
step:140/3000 train_loss:4.4598 train_time:18701ms step_avg:143.85ms
step:141/3000 train_loss:4.5398 train_time:18845ms step_avg:143.86ms
step:142/3000 train_loss:4.4025 train_time:18989ms step_avg:143.85ms
step:143/3000 train_loss:4.3762 train_time:19133ms step_avg:143.85ms
step:144/3000 train_loss:4.3234 train_time:19277ms step_avg:143.85ms
step:145/3000 train_loss:4.4335 train_time:19420ms step_avg:143.85ms
step:146/3000 train_loss:4.3911 train_time:19562ms step_avg:143.84ms
step:147/3000 train_loss:4.2602 train_time:19707ms step_avg:143.84ms
step:148/3000 train_loss:4.3971 train_time:19850ms step_avg:143.84ms
step:149/3000 train_loss:4.4389 train_time:19997ms step_avg:143.86ms
step:150/3000 train_loss:4.3793 train_time:20140ms step_avg:143.86ms
step:151/3000 train_loss:4.5150 train_time:20283ms step_avg:143.85ms
step:152/3000 train_loss:4.3494 train_time:20428ms step_avg:143.86ms
step:153/3000 train_loss:4.3456 train_time:20570ms step_avg:143.84ms
step:154/3000 train_loss:4.4266 train_time:20715ms step_avg:143.85ms
step:155/3000 train_loss:4.4339 train_time:20859ms step_avg:143.86ms
step:156/3000 train_loss:4.3549 train_time:21004ms step_avg:143.86ms
step:157/3000 train_loss:4.4160 train_time:21146ms step_avg:143.85ms
step:158/3000 train_loss:4.4827 train_time:21289ms step_avg:143.85ms
step:159/3000 train_loss:4.3180 train_time:21433ms step_avg:143.85ms
step:160/3000 train_loss:4.3809 train_time:21577ms step_avg:143.85ms
step:161/3000 train_loss:4.1862 train_time:21721ms step_avg:143.85ms
step:162/3000 train_loss:4.4194 train_time:21865ms step_avg:143.85ms
step:163/3000 train_loss:4.4144 train_time:22008ms step_avg:143.84ms
step:164/3000 train_loss:4.3985 train_time:22152ms step_avg:143.84ms
step:165/3000 train_loss:4.2500 train_time:22297ms step_avg:143.85ms
step:166/3000 train_loss:4.3339 train_time:22440ms step_avg:143.84ms
step:167/3000 train_loss:4.4214 train_time:22582ms step_avg:143.84ms
step:168/3000 train_loss:4.2570 train_time:22726ms step_avg:143.83ms
step:169/3000 train_loss:4.3220 train_time:22870ms step_avg:143.84ms
step:170/3000 train_loss:4.2154 train_time:23016ms step_avg:143.85ms
step:171/3000 train_loss:4.0866 train_time:23161ms step_avg:143.86ms
step:172/3000 train_loss:4.2498 train_time:23304ms step_avg:143.85ms
step:173/3000 train_loss:4.2764 train_time:23446ms step_avg:143.84ms
step:174/3000 train_loss:4.3114 train_time:23590ms step_avg:143.84ms
step:175/3000 train_loss:4.4810 train_time:23734ms step_avg:143.84ms
step:176/3000 train_loss:4.3008 train_time:23879ms step_avg:143.85ms
step:177/3000 train_loss:4.1587 train_time:24023ms step_avg:143.85ms
step:178/3000 train_loss:4.1317 train_time:24166ms step_avg:143.85ms
step:179/3000 train_loss:4.2416 train_time:24308ms step_avg:143.84ms
step:180/3000 train_loss:4.1906 train_time:24452ms step_avg:143.84ms
step:181/3000 train_loss:4.1679 train_time:24597ms step_avg:143.84ms
step:182/3000 train_loss:4.3506 train_time:24741ms step_avg:143.84ms
step:183/3000 train_loss:4.2080 train_time:24883ms step_avg:143.84ms
step:184/3000 train_loss:4.1898 train_time:25027ms step_avg:143.83ms
step:185/3000 train_loss:4.1870 train_time:25171ms step_avg:143.83ms
step:186/3000 train_loss:4.2641 train_time:25316ms step_avg:143.84ms
step:187/3000 train_loss:4.2419 train_time:25461ms step_avg:143.85ms
step:188/3000 train_loss:4.3007 train_time:25604ms step_avg:143.84ms
step:189/3000 train_loss:4.2315 train_time:25864ms step_avg:144.49ms
step:190/3000 train_loss:4.1682 train_time:26151ms step_avg:145.28ms
step:191/3000 train_loss:4.2656 train_time:26292ms step_avg:145.26ms
step:192/3000 train_loss:4.1482 train_time:26435ms step_avg:145.25ms
step:193/3000 train_loss:4.0851 train_time:26577ms step_avg:145.23ms
step:194/3000 train_loss:4.3162 train_time:26720ms step_avg:145.22ms
step:195/3000 train_loss:4.2302 train_time:26862ms step_avg:145.20ms
step:196/3000 train_loss:4.4159 train_time:27007ms step_avg:145.20ms
step:197/3000 train_loss:4.2392 train_time:27156ms step_avg:145.22ms
step:198/3000 train_loss:4.0918 train_time:27302ms step_avg:145.23ms
step:199/3000 train_loss:4.2305 train_time:27445ms step_avg:145.21ms
step:200/3000 train_loss:4.0901 train_time:27587ms step_avg:145.20ms
step:201/3000 train_loss:4.1752 train_time:27729ms step_avg:145.18ms
step:202/3000 train_loss:4.0694 train_time:27872ms step_avg:145.17ms
step:203/3000 train_loss:4.3032 train_time:28017ms step_avg:145.17ms
step:204/3000 train_loss:4.1226 train_time:28161ms step_avg:145.16ms
step:205/3000 train_loss:4.2472 train_time:28306ms step_avg:145.16ms
step:206/3000 train_loss:4.2976 train_time:28449ms step_avg:145.15ms
step:207/3000 train_loss:3.9943 train_time:28593ms step_avg:145.14ms
step:208/3000 train_loss:4.1465 train_time:28737ms step_avg:145.14ms
step:209/3000 train_loss:4.1449 train_time:28879ms step_avg:145.12ms
step:210/3000 train_loss:4.2933 train_time:29023ms step_avg:145.12ms
step:211/3000 train_loss:4.2461 train_time:29167ms step_avg:145.11ms
step:212/3000 train_loss:4.1242 train_time:29312ms step_avg:145.11ms
step:213/3000 train_loss:4.1413 train_time:29457ms step_avg:145.11ms
step:214/3000 train_loss:4.0978 train_time:29601ms step_avg:145.10ms
step:215/3000 train_loss:4.1717 train_time:29744ms step_avg:145.09ms
step:216/3000 train_loss:3.9967 train_time:29886ms step_avg:145.08ms
step:217/3000 train_loss:4.0528 train_time:30031ms step_avg:145.08ms
step:218/3000 train_loss:4.0577 train_time:30176ms step_avg:145.07ms
step:219/3000 train_loss:4.1389 train_time:30321ms step_avg:145.08ms
step:220/3000 train_loss:4.1205 train_time:30464ms step_avg:145.07ms
step:221/3000 train_loss:4.1453 train_time:30608ms step_avg:145.06ms
step:222/3000 train_loss:4.1676 train_time:30750ms step_avg:145.05ms
step:223/3000 train_loss:4.0519 train_time:30894ms step_avg:145.04ms
step:224/3000 train_loss:4.0278 train_time:31039ms step_avg:145.04ms
step:225/3000 train_loss:4.3561 train_time:31182ms step_avg:145.03ms
step:226/3000 train_loss:3.9796 train_time:31326ms step_avg:145.03ms
step:227/3000 train_loss:4.0410 train_time:31469ms step_avg:145.02ms
step:228/3000 train_loss:4.0347 train_time:31615ms step_avg:145.02ms
step:229/3000 train_loss:4.1980 train_time:31759ms step_avg:145.02ms
step:230/3000 train_loss:3.9792 train_time:31903ms step_avg:145.01ms
step:231/3000 train_loss:4.1087 train_time:32045ms step_avg:145.00ms
step:232/3000 train_loss:3.9565 train_time:32188ms step_avg:144.99ms
step:233/3000 train_loss:4.0301 train_time:32333ms step_avg:144.99ms
step:234/3000 train_loss:4.1562 train_time:32477ms step_avg:144.99ms
step:235/3000 train_loss:4.0816 train_time:32623ms step_avg:144.99ms
step:236/3000 train_loss:3.9585 train_time:32765ms step_avg:144.98ms
step:237/3000 train_loss:4.1246 train_time:32908ms step_avg:144.97ms
step:238/3000 train_loss:4.1341 train_time:33053ms step_avg:144.97ms
step:239/3000 train_loss:3.9934 train_time:33198ms step_avg:144.97ms
step:240/3000 train_loss:4.1259 train_time:33343ms step_avg:144.97ms
step:241/3000 train_loss:4.1713 train_time:33485ms step_avg:144.96ms
step:242/3000 train_loss:4.0157 train_time:33628ms step_avg:144.95ms
step:243/3000 train_loss:4.1972 train_time:33771ms step_avg:144.94ms
step:244/3000 train_loss:4.0799 train_time:33915ms step_avg:144.94ms
step:245/3000 train_loss:4.1408 train_time:34059ms step_avg:144.93ms
step:246/3000 train_loss:4.2061 train_time:34202ms step_avg:144.92ms
step:247/3000 train_loss:4.1254 train_time:34345ms step_avg:144.92ms
step:248/3000 train_loss:4.0626 train_time:34487ms step_avg:144.90ms
step:249/3000 train_loss:4.1690 train_time:34630ms step_avg:144.90ms
step:250/3000 train_loss:3.9779 train_time:34774ms step_avg:144.89ms
step:250/3000 val_loss:4.0672 train_time:34813ms step_avg:145.05ms
step:251/3000 train_loss:4.0330 train_time:34931ms step_avg:144.94ms
step:252/3000 train_loss:4.1335 train_time:35076ms step_avg:144.94ms
step:253/3000 train_loss:4.2245 train_time:35218ms step_avg:144.93ms
step:254/3000 train_loss:4.0026 train_time:35360ms step_avg:144.92ms
step:255/3000 train_loss:3.9401 train_time:35502ms step_avg:144.91ms
step:256/3000 train_loss:4.1216 train_time:35646ms step_avg:144.90ms
step:257/3000 train_loss:4.0343 train_time:35789ms step_avg:144.89ms
step:258/3000 train_loss:4.0454 train_time:35936ms step_avg:144.90ms
step:259/3000 train_loss:4.0313 train_time:36081ms step_avg:144.90ms
step:260/3000 train_loss:4.0862 train_time:36226ms step_avg:144.91ms
step:261/3000 train_loss:4.1122 train_time:36369ms step_avg:144.90ms
step:262/3000 train_loss:4.0743 train_time:36511ms step_avg:144.89ms
step:263/3000 train_loss:4.0533 train_time:36653ms step_avg:144.87ms
step:264/3000 train_loss:3.9617 train_time:36795ms step_avg:144.86ms
step:265/3000 train_loss:4.0402 train_time:36941ms step_avg:144.87ms
step:266/3000 train_loss:3.9239 train_time:37087ms step_avg:144.87ms
step:267/3000 train_loss:3.9761 train_time:37231ms step_avg:144.87ms
step:268/3000 train_loss:3.9763 train_time:37373ms step_avg:144.86ms
step:269/3000 train_loss:4.0133 train_time:37515ms step_avg:144.85ms
step:270/3000 train_loss:3.9078 train_time:37658ms step_avg:144.84ms
step:271/3000 train_loss:4.1566 train_time:37801ms step_avg:144.83ms
step:272/3000 train_loss:4.0342 train_time:37946ms step_avg:144.83ms
step:273/3000 train_loss:3.9743 train_time:38090ms step_avg:144.83ms
step:274/3000 train_loss:4.0085 train_time:38233ms step_avg:144.82ms
step:275/3000 train_loss:4.0926 train_time:38375ms step_avg:144.81ms
step:276/3000 train_loss:4.1204 train_time:38518ms step_avg:144.80ms
step:277/3000 train_loss:4.2916 train_time:38661ms step_avg:144.80ms
step:278/3000 train_loss:4.0969 train_time:38805ms step_avg:144.80ms
step:279/3000 train_loss:4.1376 train_time:38949ms step_avg:144.79ms
step:280/3000 train_loss:4.0504 train_time:39092ms step_avg:144.78ms
step:281/3000 train_loss:4.2219 train_time:39235ms step_avg:144.78ms
step:282/3000 train_loss:4.0204 train_time:39379ms step_avg:144.77ms
step:283/3000 train_loss:4.0107 train_time:39523ms step_avg:144.77ms
step:284/3000 train_loss:3.9730 train_time:39668ms step_avg:144.77ms
step:285/3000 train_loss:4.1174 train_time:39811ms step_avg:144.77ms
step:286/3000 train_loss:4.1262 train_time:39954ms step_avg:144.76ms
step:287/3000 train_loss:4.1559 train_time:40096ms step_avg:144.75ms
step:288/3000 train_loss:3.9759 train_time:40240ms step_avg:144.75ms
step:289/3000 train_loss:4.0760 train_time:40384ms step_avg:144.75ms
step:290/3000 train_loss:3.9257 train_time:40529ms step_avg:144.75ms
step:291/3000 train_loss:3.9186 train_time:40672ms step_avg:144.74ms
step:292/3000 train_loss:3.9777 train_time:40816ms step_avg:144.74ms
step:293/3000 train_loss:3.9181 train_time:40958ms step_avg:144.73ms
step:294/3000 train_loss:3.9722 train_time:41102ms step_avg:144.72ms
step:295/3000 train_loss:4.0066 train_time:41247ms step_avg:144.73ms
step:296/3000 train_loss:3.8979 train_time:41390ms step_avg:144.72ms
step:297/3000 train_loss:3.9242 train_time:41534ms step_avg:144.72ms
step:298/3000 train_loss:3.9216 train_time:41675ms step_avg:144.70ms
step:299/3000 train_loss:4.0290 train_time:41819ms step_avg:144.70ms
step:300/3000 train_loss:3.8886 train_time:41963ms step_avg:144.70ms
step:301/3000 train_loss:4.0130 train_time:42108ms step_avg:144.70ms
step:302/3000 train_loss:4.0354 train_time:42251ms step_avg:144.69ms
step:303/3000 train_loss:3.9921 train_time:42393ms step_avg:144.69ms
step:304/3000 train_loss:4.0435 train_time:42537ms step_avg:144.68ms
step:305/3000 train_loss:4.0155 train_time:42680ms step_avg:144.68ms
step:306/3000 train_loss:4.5136 train_time:42825ms step_avg:144.68ms
step:307/3000 train_loss:3.9960 train_time:42968ms step_avg:144.67ms
step:308/3000 train_loss:3.8988 train_time:43111ms step_avg:144.67ms
step:309/3000 train_loss:4.0459 train_time:43254ms step_avg:144.66ms
step:310/3000 train_loss:3.9280 train_time:43398ms step_avg:144.66ms
step:311/3000 train_loss:4.1526 train_time:43542ms step_avg:144.66ms
step:312/3000 train_loss:3.9857 train_time:43686ms step_avg:144.66ms
step:313/3000 train_loss:3.9275 train_time:43830ms step_avg:144.65ms
step:314/3000 train_loss:3.9981 train_time:43972ms step_avg:144.64ms
step:315/3000 train_loss:4.1285 train_time:44114ms step_avg:144.64ms
step:316/3000 train_loss:4.0144 train_time:44257ms step_avg:144.63ms
step:317/3000 train_loss:3.8540 train_time:44401ms step_avg:144.63ms
step:318/3000 train_loss:3.9383 train_time:44546ms step_avg:144.63ms
step:319/3000 train_loss:3.9775 train_time:44689ms step_avg:144.62ms
step:320/3000 train_loss:3.9517 train_time:44832ms step_avg:144.62ms
step:321/3000 train_loss:4.0685 train_time:44974ms step_avg:144.61ms
step:322/3000 train_loss:4.0180 train_time:45116ms step_avg:144.60ms
step:323/3000 train_loss:3.9943 train_time:45259ms step_avg:144.60ms
step:324/3000 train_loss:4.0750 train_time:45404ms step_avg:144.60ms
step:325/3000 train_loss:4.0229 train_time:45549ms step_avg:144.60ms
step:326/3000 train_loss:4.0807 train_time:45691ms step_avg:144.59ms
step:327/3000 train_loss:3.9448 train_time:45834ms step_avg:144.59ms
step:328/3000 train_loss:4.4525 train_time:45977ms step_avg:144.58ms
step:329/3000 train_loss:4.1320 train_time:46120ms step_avg:144.58ms
step:330/3000 train_loss:3.8645 train_time:46265ms step_avg:144.58ms
step:331/3000 train_loss:3.8146 train_time:46409ms step_avg:144.58ms
step:332/3000 train_loss:4.0322 train_time:46551ms step_avg:144.57ms
step:333/3000 train_loss:3.9700 train_time:46693ms step_avg:144.56ms
step:334/3000 train_loss:3.9394 train_time:46837ms step_avg:144.56ms
step:335/3000 train_loss:3.9110 train_time:46981ms step_avg:144.56ms
step:336/3000 train_loss:4.0781 train_time:47126ms step_avg:144.56ms
step:337/3000 train_loss:4.0181 train_time:47269ms step_avg:144.55ms
step:338/3000 train_loss:4.4934 train_time:47412ms step_avg:144.55ms
step:339/3000 train_loss:4.0015 train_time:47554ms step_avg:144.54ms
step:340/3000 train_loss:3.9417 train_time:47697ms step_avg:144.54ms
step:341/3000 train_loss:3.9904 train_time:47841ms step_avg:144.54ms
step:342/3000 train_loss:3.9146 train_time:47986ms step_avg:144.53ms
step:343/3000 train_loss:3.8778 train_time:48130ms step_avg:144.53ms
step:344/3000 train_loss:3.9089 train_time:48272ms step_avg:144.53ms
step:345/3000 train_loss:4.0592 train_time:48414ms step_avg:144.52ms
step:346/3000 train_loss:3.8991 train_time:48557ms step_avg:144.51ms
step:347/3000 train_loss:3.8326 train_time:48700ms step_avg:144.51ms
step:348/3000 train_loss:3.8686 train_time:48844ms step_avg:144.51ms
step:349/3000 train_loss:3.9286 train_time:48989ms step_avg:144.51ms
step:350/3000 train_loss:3.8880 train_time:49132ms step_avg:144.51ms
step:351/3000 train_loss:3.6234 train_time:49274ms step_avg:144.50ms
step:352/3000 train_loss:3.8823 train_time:49417ms step_avg:144.49ms
step:353/3000 train_loss:4.2428 train_time:49560ms step_avg:144.49ms
step:354/3000 train_loss:3.7234 train_time:49705ms step_avg:144.49ms
step:355/3000 train_loss:3.9949 train_time:49848ms step_avg:144.49ms
step:356/3000 train_loss:3.8539 train_time:49991ms step_avg:144.48ms
step:357/3000 train_loss:3.9579 train_time:50134ms step_avg:144.48ms
step:358/3000 train_loss:3.8585 train_time:50276ms step_avg:144.47ms
step:359/3000 train_loss:3.9195 train_time:50420ms step_avg:144.47ms
step:360/3000 train_loss:3.8977 train_time:50566ms step_avg:144.47ms
step:361/3000 train_loss:3.4966 train_time:50710ms step_avg:144.47ms
step:362/3000 train_loss:4.0851 train_time:50852ms step_avg:144.47ms
step:363/3000 train_loss:3.9905 train_time:50995ms step_avg:144.46ms
step:364/3000 train_loss:3.9122 train_time:51139ms step_avg:144.46ms
step:365/3000 train_loss:3.8094 train_time:51283ms step_avg:144.46ms
step:366/3000 train_loss:3.9867 train_time:51428ms step_avg:144.46ms
step:367/3000 train_loss:3.9420 train_time:51571ms step_avg:144.46ms
step:368/3000 train_loss:3.9366 train_time:51714ms step_avg:144.45ms