forked from KellerJordan/modded-nanogpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf2546c91-e2b3-4906-9f5b-bee25b47216f.txt
2162 lines (2089 loc) · 107 KB
/
f2546c91-e2b3-4906-9f5b-bee25b47216f.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 time
import contextlib
from dataclasses import dataclass
from pathlib import Path
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
from torch.nn.attention.flex_attention import BlockMask, flex_attention #KoszarskyB
# -----------------------------------------------------------------------------
# Muon optimizer
@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
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)
ns_steps: The number of Newton-Schulz iteration steps to use.
"""
def __init__(self, params, lr=0.02, momentum=0.95, nesterov=True, ns_steps=5):
self.world_size = int(os.environ['WORLD_SIZE'])
self.rank = int(os.environ['RANK'])
defaults = dict(lr=lr, momentum=momentum, nesterov=nesterov, ns_steps=ns_steps)
params = list(params)
assert all(isinstance(p, torch.Tensor) for p in params)
sizes = {p.numel() for p in params}
param_groups = [
{
'params': [p for p in params if p.numel() == size],
'update_buffer': [
torch.empty(size, device='cuda', dtype=torch.bfloat16)
for _ in range(self.world_size)
],
}
for size in sizes
]
super().__init__(param_groups, defaults)
def step(self):
for group in self.param_groups:
lr = group['lr']
momentum = group['momentum']
nesterov = group['nesterov']
ns_steps = group['ns_steps']
update_buffers = group['update_buffer']
# generate weight updates in distributed fashion
params = group['params']
assert len(params) % self.world_size == 0
handle = None
params_world = None
def update_prev():
if params_world is None:
return
assert handle is not None
handle.wait()
for p_world, g_world in zip(params_world, update_buffers):
p_world.data.add_(
g_world.view_as(p_world),
alpha=-lr * max(1, p_world.size(0) / p_world.size(1)) ** 0.5,
)
for base_i in range(len(params))[::self.world_size]:
p = params[base_i + self.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.lerp_(g, 1 - momentum)
g = g.lerp_(buf, momentum) if nesterov else buf
g = zeropower_via_newtonschulz5(g, steps=ns_steps).flatten()
update_prev()
handle = dist.all_gather(update_buffers, g, async_op=True)
params_world = params[base_i : base_i + self.world_size]
update_prev()
# -----------------------------------------------------------------------------
# PyTorch nn.Module definitions for the GPT-2 model
def norm(x):
return F.rms_norm(x, (x.size(-1),))
class CastedLinear(nn.Linear):
def __init__(self, in_features, out_features):
super().__init__(in_features, out_features, bias=False)
def forward(self, x):
return F.linear(x, self.weight.to(x.dtype))
class Rotary(torch.nn.Module):
def __init__(self, dim, base=10000):
super().__init__()
self.register_buffer('inv_freq', (1 / base) ** (torch.arange(0, dim, 2) / 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:
t = torch.arange(seq_len, device=x.device)
freqs = torch.outer(t, self.inv_freq)
self.seq_len_cached = seq_len
self.cos_cached = freqs.cos()
self.sin_cached = freqs.sin()
cos, sin = self.cos_cached[None, :, None, :], self.sin_cached[None, :, None, :]
# apply_rotary_emb(x, cos, sin)
x1, x2 = x.chunk(2, dim=3)
y1 = x1 * cos + x2 * sin
y2 = x1 * (-sin) + x2 * cos
return torch.cat((y1, y2), 3).type_as(x)
class CausalSelfAttention(nn.Module):
def __init__(self, dim, num_heads):
super().__init__()
assert dim % num_heads == 0
self.num_heads = num_heads
self.c_q = CastedLinear(dim, dim)
self.c_k = CastedLinear(dim, dim)
self.c_v = CastedLinear(dim, dim)
self.lambdas = nn.Parameter(torch.tensor([0.5, 0.5]))
self.rotary = Rotary(dim // num_heads) # dim // num_heads = head_dim
self.c_proj = CastedLinear(dim, dim)
self.c_proj.weight.data.zero_() # zero init suggested by @Grad62304977
def forward(self, x, vi, block_mask):
B, T = x.size(0), x.size(1) # batch size, sequence length
assert B == 1, "Must use batch size = 1 for FlexAttention"
q = self.c_q(x).view(B, T, self.num_heads, -1)
k = self.c_k(x).view(B, T, self.num_heads, -1)
v = self.c_v(x).view(B, T, self.num_heads, -1)
v = self.lambdas[0] * v + self.lambdas[1] * vi.view_as(v) # @KoszarskyB & @Grad62304977
q, k = norm(q), norm(k) # QK norm @Grad62304977
q, k = self.rotary(q), self.rotary(k)
y = flex_attention(q.transpose(1, 2), k.transpose(1, 2), v.transpose(1, 2), block_mask=block_mask, enable_gqa=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
class MLP(nn.Module):
def __init__(self, dim):
super().__init__()
self.c_fc = CastedLinear(dim, 4 * dim)
self.c_proj = CastedLinear(4 * dim, dim)
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.model_dim, config.num_heads)
self.mlp = MLP(config.model_dim)
self.lambdas = nn.Parameter(torch.tensor([1., 0.]))
def forward(self, x, vi, x0, block_mask):
x = self.lambdas[0] * x + self.lambdas[1] * x0
x = x + self.attn(norm(x), vi, block_mask)
x = x + self.mlp(norm(x))
return x
class ValueEmbedding(nn.Module):
def __init__(self, config: "GPTConfig"):
super().__init__()
self.__setattr__
self.embed = nn.ModuleList([
nn.Embedding(config.vocab_size, config.model_dim)
for _ in range(6)
])
def forward(self, inputs) -> "list[torch.Tensor]":
ve = [emb(inputs) for emb in self.embed]
ve += reversed(ve)
return ve
# -----------------------------------------------------------------------------
# The main GPT-2 model
@dataclass
class GPTConfig:
vocab_size : int = 50304
num_layers : int = 12
num_heads : int = 6 # head dim 128 suggested by @Grad62304977
model_dim : int = 768
class GPT(nn.Module):
def __init__(self, config: GPTConfig):
super().__init__()
self.num_layers = config.num_layers
# U-net design by @brendanh0gan
self.num_encoder_layers = config.num_layers // 2 # Half of the layers for encoder
self.num_decoder_layers = config.num_layers - 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.embed = nn.Embedding(config.vocab_size, config.model_dim)
self.blocks = nn.ModuleList([Block(config) for _ in range(config.num_layers)])
# token value embeddings by @KoszarskyB - inspired by @Grad62304977's value residual learning
# U-net structure on token value embeddings by @leloykun
self.value_embeds = ValueEmbedding(config)
self.lm_head = CastedLinear(config.model_dim, config.vocab_size)
self.lm_head.weight.data.zero_() # @Grad62304977
def forward(
self,
inputs: torch.Tensor,
targets: torch.Tensor,
sliding_window_num_blocks: torch.Tensor,
):
BLOCK_SIZE = 128
assert inputs.ndim == 1
docs = (inputs == 50256).cumsum(0)
docs_low = docs.view(-1, BLOCK_SIZE)[:, 0].contiguous()
docs_high = docs.view(-1, BLOCK_SIZE)[:, -1].contiguous()
def document_causal(b, h, q_idx, kv_idx):
causal_mask = q_idx >= kv_idx
document_mask = docs[q_idx] == docs[kv_idx]
return causal_mask & document_mask
def dense_to_ordered(dense_mask: torch.Tensor):
num_blocks = dense_mask.sum(dim=-1, dtype=torch.int32)
indices = dense_mask.argsort(dim=-1, descending=True, stable=True).to(torch.int32)
return num_blocks[None, None].contiguous(), indices[None, None].contiguous()
def create_doc_swc_block_mask(sliding_window_num_blocks: torch.Tensor):
kv_idx = block_idx = torch.arange(512, dtype=torch.int32, device="cuda")
q_idx = block_idx[:, None]
causal_bm = q_idx >= kv_idx
causal_full_bm = q_idx > kv_idx
window_bm = q_idx - kv_idx < sliding_window_num_blocks
window_full_bm = window_bm
# document_bm = (docs_low[q_idx] <= docs_high[kv_idx]) & (docs_low[kv_idx] <= docs_high[q_idx])
document_bm = (docs_low[:, None] <= docs_high) & (docs_low <= docs_high[:, None])
document_full_bm = (docs_low[:, None] == docs_high) & (docs_low == docs_high[:, None])
nonzero_bm = causal_bm & window_bm & document_bm
full_bm = causal_full_bm & window_full_bm & document_full_bm
kv_num_blocks, kv_indices = dense_to_ordered(nonzero_bm ^ full_bm)
full_kv_num_blocks, full_kv_indices = dense_to_ordered(full_bm)
return BlockMask.from_kv_blocks(
kv_num_blocks,
kv_indices,
full_kv_num_blocks,
full_kv_indices,
BLOCK_SIZE=BLOCK_SIZE,
mask_mod=document_causal,
)
block_mask = create_doc_swc_block_mask(sliding_window_num_blocks)
# forward the GPT model itself
x = self.embed(inputs[None]) # token embeddings of shape (b, t, model_dim)
x = norm(x) # @Grad62304977
x0 = x
ve = self.value_embeds(inputs)
ve_enc, ve_dec = ve[:self.num_encoder_layers], ve[self.num_encoder_layers:]
# 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 = self.blocks[i](x, ve_enc[i], 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()
# U-net structure on token value embeddings by @leloykun
x = self.blocks[self.num_encoder_layers + i](x, ve_dec[i], x0, block_mask)
x = norm(x)
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)), targets.view(-1))
return loss
# -----------------------------------------------------------------------------
# Our own simple Distributed Data Loader
def _peek_data_shard(file: Path):
# only reads the header, returns header data
# header is 256 int32
header = torch.from_file(f"{file}", False, 256, dtype=torch.int32)
assert header[0] == 20240520, "magic number mismatch in the data .bin file"
assert header[1] == 1, "unsupported version"
return int(header[2]) # number of tokens (claimed)
def _load_data_shard(path: Path, num_tokens):
with path.open("rb", buffering=0) as f:
tokens = torch.empty(num_tokens, dtype=torch.uint16, pin_memory=True)
f.seek(256 * 4)
nbytes = f.readinto(tokens.numpy())
assert nbytes == 2 * num_tokens, "number of tokens read does not match header?"
return tokens
class DistributedDataLoader:
def __init__(self, filename_pattern, seq_len, process_rank, num_processes):
self.process_rank = process_rank
self.num_processes = num_processes
self.seq_len = seq_len
# glob files that match the pattern
self.files = sorted(Path.cwd().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
self.files_num_tokens = [_peek_data_shard(file) for file in self.files]
assert min(self.files_num_tokens) >= num_processes * seq_len + 1
self.total_num_tokens = sum(self.files_num_tokens)
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.seq_len
self.tokens = _load_data_shard(self.files[self.current_shard], self.files_num_tokens[self.current_shard])
def next_batch(self):
batch_size = self.seq_len * self.num_processes
buf = self.tokens[self.current_position:self.current_position+self.seq_len+1]
# host side async is sufficient;
# no performance improvement was observed when introducing a separate stream.
inputs = buf[:-1].to(device="cuda", dtype=torch.int32, non_blocking=True) # inputs
targets = buf[1:].to(device="cuda", dtype=torch.int64, non_blocking=True) # targets
# advance current position and load next shard if necessary
self.current_position += batch_size
if self.current_position + batch_size + 1 >= len(self.tokens):
self.advance()
return inputs, targets
# -----------------------------------------------------------------------------
# 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
sequence_length : int = 64*1024 # sequence length, in tokens
num_iterations : int = 1480 # number of iterations to run
warmup_iters : int = 0
cooldown_iters : int = 600 # 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
ddp_rank = int(os.environ['RANK'])
ddp_local_rank = int(os.environ['LOCAL_RANK'])
ddp_world_size = int(os.environ['WORLD_SIZE'])
assert torch.cuda.is_available()
device = torch.device(f"cuda:{ddp_local_rank}")
torch.cuda.set_device(device)
print(f"using device: {device}")
dist.init_process_group(backend='nccl', device_id=device)
dist.barrier()
master_process = (ddp_rank == 0) # this process will do logging, checkpointing etc.
# begin logging
logfile = None
if master_process:
run_id = uuid.uuid4()
logdir = Path("logs") / f"{run_id}"
logdir.mkdir(exist_ok=True)
logfile = Path("logs") / f"{run_id}.txt"
print(logfile.stem)
# create the log file
with logfile.open("w") as f:
# begin the log by printing this file (the Python code)
print(code, file=f)
print("=" * 100, file=f)
def print0(s, logonly=False):
if master_process:
with logfile.open("a") as f:
if not logonly:
print(s)
print(s, file=f)
# log information about the hardware/software environment this is running on
# and print the full `nvidia-smi` to file
print0(f"Running python {sys.version}")
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)
# calculate the number of steps to take in the val loop.
assert args.val_tokens % (args.sequence_length * ddp_world_size) == 0
val_steps = args.val_tokens // (args.sequence_length * ddp_world_size)
# calculate the steps of gradient accumulation required to attain the desired global batch size.
assert args.batch_size % (ddp_world_size) == 0
train_accumulation_steps = args.batch_size // ddp_world_size
# load tokens
train_loader = DistributedDataLoader(args.input_bin, args.sequence_length, ddp_rank, ddp_world_size)
val_loader = DistributedDataLoader(args.input_val_bin, args.sequence_length, ddp_rank, ddp_world_size)
print0(f"Training DataLoader: total number of tokens: {train_loader.total_num_tokens} across {len(train_loader.files)} files")
print0(f"Validation DataLoader: total number of tokens: {val_loader.total_num_tokens} across {len(val_loader.files)} files")
print0('='*100, logonly=True)
inputs_train, targets_train = 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, num_layers=12, num_heads=6, model_dim=768))
model = model.cuda().bfloat16()
for m in model.modules():
if isinstance(m, CastedLinear):
m.float()
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], broadcast_buffers=False, gradient_as_bucket_view=True)
raw_model = model.module # always contains the "raw" unwrapped model
# init the optimizer(s)
embed_params = [*raw_model.embed.parameters(), *raw_model.value_embeds.parameters()]
optimizer1 = torch.optim.Adam(embed_params, 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.blocks.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)
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]
sliding_window_num_blocks = torch.tensor(1, dtype=torch.int32, device="cuda")
sw_num_blocks_prev = 1
# Start training loop
training_time_ms = 0
# start the clock
torch.cuda.synchronize()
t0 = time.perf_counter()
# begin training
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.perf_counter()
timed_steps = float('nan') if step <= 11 else (step - 10) + 1 # <= 11 to avoid bug in val
# Linearly increase the sliding window size over training in chunks of 64 from 64 -> 1792. By @fernbear.bsky.social
frac_done = step / args.num_iterations # training progress
sw_num_blocks = int(((1 - frac_done) * 64 + frac_done * 1792 + 64) // 128)
if sw_num_blocks != sw_num_blocks_prev:
sliding_window_num_blocks.copy_(sw_num_blocks, non_blocking=True)
sw_num_blocks_prev = sw_num_blocks
# 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.perf_counter() - t0)
# run validation batches
model.eval()
val_loader.reset()
val_loss = 0.0
for _ in range(val_steps):
with torch.no_grad():
inputs_val, targets_val = val_loader.next_batch()
val_loss += model(inputs_val, targets_val, sliding_window_num_blocks)
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.perf_counter()
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.perf_counter() - 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.perf_counter()
# 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):
with contextlib.ExitStack() as stack:
if i < train_accumulation_steps: # there's no need to sync gradients every accumulation step
stack.enter_context(model.no_sync())
if step >= 5:
stack.enter_context(torch.compiler.set_stance(skip_guard_eval_unsafe=True))
model(inputs_train, targets_train, sliding_window_num_blocks).backward()
inputs_train, targets_train = train_loader.next_batch()
if train_accumulation_steps != 1:
for p in model.parameters():
p.grad /= train_accumulation_steps
# momentum warmup for Muon
frac = min(step/300, 1)
for group in optimizer3.param_groups:
group['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.
approx_time = training_time_ms + 1000 * (time.perf_counter() - t0)
print0(f"step:{step+1}/{args.num_iterations} train_time:{approx_time:.0f}ms step_avg:{approx_time/timed_steps:.2f}ms")
print0(f"peak memory consumption: {torch.cuda.max_memory_allocated() // 1024 // 1024} MiB")
# -------------------------------------------------------------------------
# clean up nice
dist.destroy_process_group()
====================================================================================================
Running python 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0]
Running pytorch 2.6.0.dev20241203+cu124 compiled for CUDA 12.4
nvidia-smi:
Wed Dec 11 08:33:33 2024
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.183.06 Driver Version: 535.183.06 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
| 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 On | 00000000:19:00.0 Off | 0 |
| N/A 38C P0 126W / 700W | 7084MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+----------------------+----------------------+
| 1 NVIDIA H100 80GB HBM3 On | 00000000:3B:00.0 Off | 0 |
| N/A 30C P0 116W / 700W | 3451MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+----------------------+----------------------+
| 2 NVIDIA H100 80GB HBM3 On | 00000000:4C:00.0 Off | 0 |
| N/A 28C P0 112W / 700W | 3451MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+----------------------+----------------------+
| 3 NVIDIA H100 80GB HBM3 On | 00000000:5D:00.0 Off | 0 |
| N/A 36C P0 114W / 700W | 3451MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+----------------------+----------------------+
| 4 NVIDIA H100 80GB HBM3 On | 00000000:9B:00.0 Off | 0 |
| N/A 38C P0 120W / 700W | 3451MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+----------------------+----------------------+
| 5 NVIDIA H100 80GB HBM3 On | 00000000:BB:00.0 Off | 0 |
| N/A 30C P0 118W / 700W | 3451MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+----------------------+----------------------+
| 6 NVIDIA H100 80GB HBM3 On | 00000000:CB:00.0 Off | 0 |
| N/A 36C P0 119W / 700W | 3451MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+----------------------+----------------------+
| 7 NVIDIA H100 80GB HBM3 On | 00000000:DB:00.0 Off | 0 |
| N/A 30C P0 118W / 700W | 3211MiB / 81559MiB | 0% Default |
| | | Disabled |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
+---------------------------------------------------------------------------------------+
====================================================================================================
Training DataLoader: total number of tokens: 1000000000 across 10 files
Validation DataLoader: total number of tokens: 100000000 across 1 files
====================================================================================================
step:0/1480 val_loss:10.8258 train_time:0ms step_avg:nanms
step:1/1480 train_time:28859ms step_avg:nanms
step:2/1480 train_time:29048ms step_avg:nanms
step:3/1480 train_time:29174ms step_avg:nanms
step:4/1480 train_time:29312ms step_avg:nanms
step:5/1480 train_time:29454ms step_avg:nanms
step:6/1480 train_time:29595ms step_avg:nanms
step:7/1480 train_time:29738ms step_avg:nanms
step:8/1480 train_time:29880ms step_avg:nanms
step:9/1480 train_time:30023ms step_avg:nanms
step:10/1480 train_time:30166ms step_avg:nanms
step:11/1480 train_time:143ms step_avg:nanms
step:12/1480 train_time:283ms step_avg:nanms
step:13/1480 train_time:425ms step_avg:141.80ms
step:14/1480 train_time:569ms step_avg:142.15ms
step:15/1480 train_time:714ms step_avg:142.78ms
step:16/1480 train_time:857ms step_avg:142.89ms
step:17/1480 train_time:999ms step_avg:142.73ms
step:18/1480 train_time:1141ms step_avg:142.65ms
step:19/1480 train_time:1283ms step_avg:142.57ms
step:20/1480 train_time:1427ms step_avg:142.65ms
step:21/1480 train_time:1569ms step_avg:142.65ms
step:22/1480 train_time:1713ms step_avg:142.77ms
step:23/1480 train_time:1856ms step_avg:142.76ms
step:24/1480 train_time:1998ms step_avg:142.70ms
step:25/1480 train_time:2140ms step_avg:142.64ms
step:26/1480 train_time:2282ms step_avg:142.64ms
step:27/1480 train_time:2425ms step_avg:142.67ms
step:28/1480 train_time:2567ms step_avg:142.63ms
step:29/1480 train_time:2714ms step_avg:142.85ms
step:30/1480 train_time:3229ms step_avg:161.45ms
step:31/1480 train_time:3330ms step_avg:158.58ms
step:32/1480 train_time:3473ms step_avg:157.88ms
step:33/1480 train_time:3616ms step_avg:157.21ms
step:34/1480 train_time:3759ms step_avg:156.61ms
step:35/1480 train_time:3900ms step_avg:155.98ms
step:36/1480 train_time:4042ms step_avg:155.44ms
step:37/1480 train_time:4187ms step_avg:155.07ms
step:38/1480 train_time:4333ms step_avg:154.74ms
step:39/1480 train_time:4477ms step_avg:154.38ms
step:40/1480 train_time:4619ms step_avg:153.96ms
step:41/1480 train_time:4760ms step_avg:153.56ms
step:42/1480 train_time:4902ms step_avg:153.18ms
step:43/1480 train_time:5043ms step_avg:152.82ms
step:44/1480 train_time:5186ms step_avg:152.52ms
step:45/1480 train_time:5329ms step_avg:152.26ms
step:46/1480 train_time:5472ms step_avg:152.01ms
step:47/1480 train_time:5615ms step_avg:151.77ms
step:48/1480 train_time:5758ms step_avg:151.52ms
step:49/1480 train_time:5900ms step_avg:151.29ms
step:50/1480 train_time:6042ms step_avg:151.06ms
step:51/1480 train_time:6183ms step_avg:150.81ms
step:52/1480 train_time:6328ms step_avg:150.66ms
step:53/1480 train_time:6471ms step_avg:150.48ms
step:54/1480 train_time:6615ms step_avg:150.33ms
step:55/1480 train_time:6757ms step_avg:150.15ms
step:56/1480 train_time:6900ms step_avg:150.00ms
step:57/1480 train_time:7045ms step_avg:149.89ms
step:58/1480 train_time:7187ms step_avg:149.72ms
step:59/1480 train_time:7330ms step_avg:149.59ms
step:60/1480 train_time:7476ms step_avg:149.53ms
step:61/1480 train_time:7618ms step_avg:149.37ms
step:62/1480 train_time:7759ms step_avg:149.22ms
step:63/1480 train_time:7901ms step_avg:149.07ms
step:64/1480 train_time:8043ms step_avg:148.94ms
step:65/1480 train_time:8185ms step_avg:148.82ms
step:66/1480 train_time:8329ms step_avg:148.73ms
step:67/1480 train_time:8473ms step_avg:148.65ms
step:68/1480 train_time:8616ms step_avg:148.56ms
step:69/1480 train_time:8760ms step_avg:148.47ms
step:70/1480 train_time:8901ms step_avg:148.35ms
step:71/1480 train_time:9043ms step_avg:148.25ms
step:72/1480 train_time:9185ms step_avg:148.15ms
step:73/1480 train_time:9329ms step_avg:148.09ms
step:74/1480 train_time:9472ms step_avg:148.01ms
step:75/1480 train_time:9615ms step_avg:147.93ms
step:76/1480 train_time:9757ms step_avg:147.84ms
step:77/1480 train_time:9900ms step_avg:147.76ms
step:78/1480 train_time:10042ms step_avg:147.67ms
step:79/1480 train_time:10570ms step_avg:153.19ms
step:80/1480 train_time:11074ms step_avg:158.20ms
step:81/1480 train_time:11569ms step_avg:162.94ms
step:82/1480 train_time:11667ms step_avg:162.04ms
step:83/1480 train_time:11810ms step_avg:161.78ms
step:84/1480 train_time:11951ms step_avg:161.51ms
step:85/1480 train_time:12093ms step_avg:161.24ms
step:86/1480 train_time:12236ms step_avg:161.00ms
step:87/1480 train_time:12378ms step_avg:160.76ms
step:88/1480 train_time:12521ms step_avg:160.53ms
step:89/1480 train_time:12666ms step_avg:160.32ms
step:90/1480 train_time:12809ms step_avg:160.11ms
step:91/1480 train_time:12952ms step_avg:159.91ms
step:92/1480 train_time:13096ms step_avg:159.71ms
step:93/1480 train_time:13239ms step_avg:159.51ms
step:94/1480 train_time:13381ms step_avg:159.30ms
step:95/1480 train_time:13524ms step_avg:159.10ms
step:96/1480 train_time:13667ms step_avg:158.91ms
step:97/1480 train_time:13809ms step_avg:158.72ms
step:98/1480 train_time:13951ms step_avg:158.54ms
step:99/1480 train_time:14094ms step_avg:158.36ms
step:100/1480 train_time:14238ms step_avg:158.21ms
step:101/1480 train_time:14386ms step_avg:158.09ms
step:102/1480 train_time:14523ms step_avg:157.86ms
step:103/1480 train_time:14665ms step_avg:157.69ms
step:104/1480 train_time:14809ms step_avg:157.54ms
step:105/1480 train_time:14954ms step_avg:157.41ms
step:106/1480 train_time:15095ms step_avg:157.24ms
step:107/1480 train_time:15239ms step_avg:157.11ms
step:108/1480 train_time:15384ms step_avg:156.97ms
step:109/1480 train_time:15525ms step_avg:156.81ms
step:110/1480 train_time:15668ms step_avg:156.68ms
step:111/1480 train_time:15812ms step_avg:156.56ms
step:112/1480 train_time:15958ms step_avg:156.45ms
step:113/1480 train_time:16103ms step_avg:156.34ms
step:114/1480 train_time:16250ms step_avg:156.25ms
step:115/1480 train_time:16396ms step_avg:156.15ms
step:116/1480 train_time:16541ms step_avg:156.04ms
step:117/1480 train_time:16687ms step_avg:155.95ms
step:118/1480 train_time:16833ms step_avg:155.86ms
step:119/1480 train_time:16979ms step_avg:155.77ms
step:120/1480 train_time:17124ms step_avg:155.67ms
step:121/1480 train_time:17269ms step_avg:155.58ms
step:122/1480 train_time:17416ms step_avg:155.50ms
step:123/1480 train_time:17561ms step_avg:155.41ms
step:124/1480 train_time:17706ms step_avg:155.32ms
step:125/1480 train_time:17853ms step_avg:155.24ms
step:125/1480 val_loss:4.4154 train_time:17918ms step_avg:155.81ms
step:126/1480 train_time:18011ms step_avg:155.27ms
step:127/1480 train_time:18156ms step_avg:155.18ms
step:128/1480 train_time:18301ms step_avg:155.10ms
step:129/1480 train_time:18446ms step_avg:155.01ms
step:130/1480 train_time:18592ms step_avg:154.93ms
step:131/1480 train_time:18738ms step_avg:154.86ms
step:132/1480 train_time:18882ms step_avg:154.77ms
step:133/1480 train_time:19029ms step_avg:154.70ms
step:134/1480 train_time:19176ms step_avg:154.65ms
step:135/1480 train_time:19321ms step_avg:154.57ms
step:136/1480 train_time:19467ms step_avg:154.50ms
step:137/1480 train_time:19614ms step_avg:154.44ms
step:138/1480 train_time:19759ms step_avg:154.37ms
step:139/1480 train_time:19904ms step_avg:154.29ms
step:140/1480 train_time:20050ms step_avg:154.23ms
step:141/1480 train_time:20197ms step_avg:154.18ms
step:142/1480 train_time:20342ms step_avg:154.11ms
step:143/1480 train_time:20488ms step_avg:154.04ms
step:144/1480 train_time:20634ms step_avg:153.99ms
step:145/1480 train_time:20780ms step_avg:153.93ms
step:146/1480 train_time:20925ms step_avg:153.86ms
step:147/1480 train_time:21072ms step_avg:153.81ms
step:148/1480 train_time:21219ms step_avg:153.76ms
step:149/1480 train_time:21364ms step_avg:153.70ms
step:150/1480 train_time:21509ms step_avg:153.63ms
step:151/1480 train_time:21655ms step_avg:153.58ms
step:152/1480 train_time:21801ms step_avg:153.52ms
step:153/1480 train_time:21945ms step_avg:153.46ms
step:154/1480 train_time:22093ms step_avg:153.43ms
step:155/1480 train_time:22239ms step_avg:153.37ms
step:156/1480 train_time:22385ms step_avg:153.32ms
step:157/1480 train_time:22531ms step_avg:153.27ms
step:158/1480 train_time:22677ms step_avg:153.22ms
step:159/1480 train_time:22822ms step_avg:153.17ms
step:160/1480 train_time:22968ms step_avg:153.12ms
step:161/1480 train_time:23116ms step_avg:153.09ms
step:162/1480 train_time:23261ms step_avg:153.03ms
step:163/1480 train_time:23407ms step_avg:152.99ms
step:164/1480 train_time:23554ms step_avg:152.95ms
step:165/1480 train_time:23699ms step_avg:152.90ms
step:166/1480 train_time:23844ms step_avg:152.85ms
step:167/1480 train_time:23991ms step_avg:152.81ms
step:168/1480 train_time:24137ms step_avg:152.77ms
step:169/1480 train_time:24283ms step_avg:152.72ms
step:170/1480 train_time:24428ms step_avg:152.67ms
step:171/1480 train_time:24574ms step_avg:152.64ms
step:172/1480 train_time:24720ms step_avg:152.59ms
step:173/1480 train_time:24866ms step_avg:152.55ms
step:174/1480 train_time:25011ms step_avg:152.51ms
step:175/1480 train_time:25158ms step_avg:152.47ms
step:176/1480 train_time:25303ms step_avg:152.43ms
step:177/1480 train_time:25448ms step_avg:152.39ms
step:178/1480 train_time:25594ms step_avg:152.35ms
step:179/1480 train_time:25739ms step_avg:152.30ms
step:180/1480 train_time:25887ms step_avg:152.28ms
step:181/1480 train_time:26034ms step_avg:152.25ms
step:182/1480 train_time:26180ms step_avg:152.21ms
step:183/1480 train_time:26324ms step_avg:152.16ms
step:184/1480 train_time:26470ms step_avg:152.13ms
step:185/1480 train_time:26617ms step_avg:152.10ms
step:186/1480 train_time:26762ms step_avg:152.06ms
step:187/1480 train_time:26908ms step_avg:152.02ms
step:188/1480 train_time:27054ms step_avg:151.99ms
step:189/1480 train_time:27223ms step_avg:152.09ms
step:190/1480 train_time:27345ms step_avg:151.92ms
step:191/1480 train_time:27492ms step_avg:151.89ms
step:192/1480 train_time:27637ms step_avg:151.85ms
step:193/1480 train_time:27782ms step_avg:151.81ms
step:194/1480 train_time:27928ms step_avg:151.78ms
step:195/1480 train_time:28077ms step_avg:151.77ms
step:196/1480 train_time:28222ms step_avg:151.73ms
step:197/1480 train_time:28368ms step_avg:151.70ms
step:198/1480 train_time:28515ms step_avg:151.67ms
step:199/1480 train_time:28660ms step_avg:151.64ms
step:200/1480 train_time:28804ms step_avg:151.60ms
step:201/1480 train_time:28950ms step_avg:151.57ms
step:202/1480 train_time:29098ms step_avg:151.55ms
step:203/1480 train_time:29243ms step_avg:151.52ms
step:204/1480 train_time:29388ms step_avg:151.48ms
step:205/1480 train_time:29534ms step_avg:151.46ms
step:206/1480 train_time:29680ms step_avg:151.43ms
step:207/1480 train_time:29825ms step_avg:151.39ms
step:208/1480 train_time:29971ms step_avg:151.37ms
step:209/1480 train_time:30118ms step_avg:151.35ms
step:210/1480 train_time:30264ms step_avg:151.32ms
step:211/1480 train_time:30410ms step_avg:151.29ms
step:212/1480 train_time:30557ms step_avg:151.27ms
step:213/1480 train_time:30702ms step_avg:151.24ms
step:214/1480 train_time:30848ms step_avg:151.21ms
step:215/1480 train_time:30994ms step_avg:151.19ms
step:216/1480 train_time:31140ms step_avg:151.17ms
step:217/1480 train_time:31287ms step_avg:151.14ms
step:218/1480 train_time:31433ms step_avg:151.12ms
step:219/1480 train_time:31579ms step_avg:151.10ms
step:220/1480 train_time:31725ms step_avg:151.07ms
step:221/1480 train_time:32277ms step_avg:152.97ms
step:222/1480 train_time:32384ms step_avg:152.75ms
step:223/1480 train_time:32532ms step_avg:152.73ms
step:224/1480 train_time:32681ms step_avg:152.71ms
step:225/1480 train_time:32829ms step_avg:152.69ms
step:226/1480 train_time:32978ms step_avg:152.68ms
step:227/1480 train_time:33125ms step_avg:152.65ms
step:228/1480 train_time:33276ms step_avg:152.64ms
step:229/1480 train_time:33424ms step_avg:152.62ms
step:230/1480 train_time:33572ms step_avg:152.60ms
step:231/1480 train_time:33721ms step_avg:152.58ms
step:232/1480 train_time:33869ms step_avg:152.56ms
step:233/1480 train_time:34018ms step_avg:152.55ms
step:234/1480 train_time:34165ms step_avg:152.52ms
step:235/1480 train_time:34314ms step_avg:152.51ms
step:236/1480 train_time:34462ms step_avg:152.49ms
step:237/1480 train_time:34610ms step_avg:152.47ms
step:238/1480 train_time:34759ms step_avg:152.45ms
step:239/1480 train_time:34908ms step_avg:152.44ms
step:240/1480 train_time:35058ms step_avg:152.43ms
step:241/1480 train_time:35206ms step_avg:152.41ms
step:242/1480 train_time:35355ms step_avg:152.39ms
step:243/1480 train_time:35503ms step_avg:152.37ms
step:244/1480 train_time:35651ms step_avg:152.35ms
step:245/1480 train_time:35800ms step_avg:152.34ms
step:246/1480 train_time:35949ms step_avg:152.32ms
step:247/1480 train_time:36097ms step_avg:152.31ms
step:248/1480 train_time:36246ms step_avg:152.29ms
step:249/1480 train_time:36395ms step_avg:152.28ms
step:250/1480 train_time:36542ms step_avg:152.26ms
step:250/1480 val_loss:4.0014 train_time:36608ms step_avg:152.53ms
step:251/1480 train_time:36701ms step_avg:152.29ms
step:252/1480 train_time:36848ms step_avg:152.26ms
step:253/1480 train_time:36997ms step_avg:152.25ms
step:254/1480 train_time:37146ms step_avg:152.24ms
step:255/1480 train_time:37293ms step_avg:152.22ms
step:256/1480 train_time:37442ms step_avg:152.20ms
step:257/1480 train_time:37589ms step_avg:152.18ms
step:258/1480 train_time:37740ms step_avg:152.18ms
step:259/1480 train_time:37888ms step_avg:152.16ms
step:260/1480 train_time:38036ms step_avg:152.14ms
step:261/1480 train_time:38185ms step_avg:152.13ms
step:262/1480 train_time:38333ms step_avg:152.12ms
step:263/1480 train_time:38482ms step_avg:152.10ms
step:264/1480 train_time:38630ms step_avg:152.09ms
step:265/1480 train_time:38779ms step_avg:152.08ms
step:266/1480 train_time:38927ms step_avg:152.06ms
step:267/1480 train_time:39076ms step_avg:152.05ms
step:268/1480 train_time:39225ms step_avg:152.03ms
step:269/1480 train_time:39373ms step_avg:152.02ms
step:270/1480 train_time:39521ms step_avg:152.00ms
step:271/1480 train_time:39669ms step_avg:151.99ms
step:272/1480 train_time:39818ms step_avg:151.98ms
step:273/1480 train_time:39967ms step_avg:151.96ms
step:274/1480 train_time:40116ms step_avg:151.96ms
step:275/1480 train_time:40264ms step_avg:151.94ms
step:276/1480 train_time:40413ms step_avg:151.93ms
step:277/1480 train_time:40561ms step_avg:151.91ms
step:278/1480 train_time:40709ms step_avg:151.90ms
step:279/1480 train_time:40857ms step_avg:151.89ms
step:280/1480 train_time:41006ms step_avg:151.87ms
step:281/1480 train_time:41155ms step_avg:151.86ms
step:282/1480 train_time:41304ms step_avg:151.85ms
step:283/1480 train_time:41452ms step_avg:151.84ms
step:284/1480 train_time:41601ms step_avg:151.83ms
step:285/1480 train_time:41748ms step_avg:151.81ms
step:286/1480 train_time:41897ms step_avg:151.80ms
step:287/1480 train_time:42046ms step_avg:151.79ms
step:288/1480 train_time:42195ms step_avg:151.78ms
step:289/1480 train_time:42344ms step_avg:151.77ms
step:290/1480 train_time:42492ms step_avg:151.76ms
step:291/1480 train_time:42641ms step_avg:151.75ms
step:292/1480 train_time:42788ms step_avg:151.73ms
step:293/1480 train_time:42937ms step_avg:151.72ms
step:294/1480 train_time:43086ms step_avg:151.71ms
step:295/1480 train_time:43234ms step_avg:151.70ms
step:296/1480 train_time:43383ms step_avg:151.69ms
step:297/1480 train_time:43531ms step_avg:151.68ms
step:298/1480 train_time:43680ms step_avg:151.67ms
step:299/1480 train_time:43827ms step_avg:151.65ms
step:300/1480 train_time:43977ms step_avg:151.64ms
step:301/1480 train_time:44126ms step_avg:151.63ms
step:302/1480 train_time:44274ms step_avg:151.62ms
step:303/1480 train_time:44424ms step_avg:151.62ms
step:304/1480 train_time:44573ms step_avg:151.61ms
step:305/1480 train_time:44722ms step_avg:151.60ms
step:306/1480 train_time:44870ms step_avg:151.59ms
step:307/1480 train_time:45020ms step_avg:151.58ms
step:308/1480 train_time:45168ms step_avg:151.57ms
step:309/1480 train_time:45317ms step_avg:151.56ms
step:310/1480 train_time:45465ms step_avg:151.55ms
step:311/1480 train_time:45614ms step_avg:151.54ms
step:312/1480 train_time:45761ms step_avg:151.53ms
step:313/1480 train_time:45911ms step_avg:151.52ms
step:314/1480 train_time:46060ms step_avg:151.51ms
step:315/1480 train_time:46208ms step_avg:151.50ms
step:316/1480 train_time:46357ms step_avg:151.49ms
step:317/1480 train_time:46506ms step_avg:151.48ms
step:318/1480 train_time:46653ms step_avg:151.47ms
step:319/1480 train_time:46802ms step_avg:151.46ms
step:320/1480 train_time:46950ms step_avg:151.45ms
step:321/1480 train_time:47099ms step_avg:151.44ms
step:322/1480 train_time:47246ms step_avg:151.43ms
step:323/1480 train_time:47396ms step_avg:151.42ms
step:324/1480 train_time:47545ms step_avg:151.42ms
step:325/1480 train_time:47693ms step_avg:151.41ms
step:326/1480 train_time:47843ms step_avg:151.40ms
step:327/1480 train_time:47991ms step_avg:151.39ms
step:328/1480 train_time:48140ms step_avg:151.38ms
step:329/1480 train_time:48288ms step_avg:151.37ms