ViuAI commited on
Commit
3bb9733
·
verified ·
1 Parent(s): a29d041

Upload 2 files

Browse files
Files changed (1) hide show
  1. code/train.py +4 -6
code/train.py CHANGED
@@ -320,12 +320,10 @@ for step in range(start_step, end_step):
320
  accum_loss = 0.0
321
  for micro_i in range(GRAD_ACCUM):
322
  x, y = get_batch(shard_pool, MICRO_BATCH, CONTEXT_LEN)
323
- sync_ctx = model.no_sync() if micro_i < GRAD_ACCUM - 1 else contextlib.nullcontext()
324
- with sync_ctx:
325
- with torch.autocast(device_type="cuda", dtype=torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16):
326
- _, loss = model(x, y)
327
- loss = loss / GRAD_ACCUM
328
- loss.backward()
329
  accum_loss += loss.item()
330
  del x, y, loss
331
 
 
320
  accum_loss = 0.0
321
  for micro_i in range(GRAD_ACCUM):
322
  x, y = get_batch(shard_pool, MICRO_BATCH, CONTEXT_LEN)
323
+ with torch.autocast(device_type="cuda", dtype=torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16):
324
+ _, loss = model(x, y)
325
+ loss = loss / GRAD_ACCUM
326
+ loss.backward()
 
 
327
  accum_loss += loss.item()
328
  del x, y, loss
329