Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions RWKV-v5/src/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def on_train_batch_start(self, trainer, pl_module, batch, batch_idx):
args = self.args
# if args.cuda_cleanup > 0:
# torch.cuda.empty_cache()
real_step = trainer.global_step + args.epoch_begin * args.epoch_steps
real_step = trainer.global_step + args.epoch_begin * (args.epoch_steps // args.accumulate_grad_batches)

# LR schedule
w_step = args.warmup_steps
Expand All @@ -58,8 +58,8 @@ def on_train_batch_start(self, trainer, pl_module, batch, batch_idx):
# print(trainer.global_step, decay_step, decay_total, w_step, progress, lr)

if args.my_exit_tokens != 0: # cosine decay
real_tokens = real_step * args.ctx_len * args.real_bsz
warmup_tokens = w_step * args.ctx_len * args.real_bsz
real_tokens = real_step * args.ctx_len * args.real_bsz * args.accumulate_grad_batches
warmup_tokens = w_step * args.ctx_len * args.real_bsz * args.accumulate_grad_batches
progress = (real_tokens - warmup_tokens) / (abs(args.my_exit_tokens) - warmup_tokens)
progress = max(0, min(1, progress))
lr_final_factor = args.lr_final / args.lr_init
Expand Down Expand Up @@ -123,7 +123,7 @@ def on_train_batch_start(self, trainer, pl_module, batch, batch_idx):
def on_train_batch_end(self, trainer, pl_module, outputs, batch, batch_idx):
args = self.args
token_per_step = args.ctx_len * args.real_bsz
real_step = trainer.global_step + args.epoch_begin * args.epoch_steps
real_step = trainer.global_step + args.epoch_begin * (args.epoch_steps // args.accumulate_grad_batches)
if trainer.is_global_zero: # logging
t_now = time.time_ns()
kt_s = 0
Expand Down
2 changes: 2 additions & 0 deletions RWKV-v5/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@
args.max_epochs = -1 # continue forever
args.betas = (args.beta1, args.beta2)
args.real_bsz = int(args.num_nodes) * int(args.devices) * args.micro_bsz
if args.accumulate_grad_batches is None:
args.accumulate_grad_batches = 1
os.environ["RWKV_MY_TESTING"] = args.my_testing
os.environ["RWKV_CTXLEN"] = str(args.ctx_len)
os.environ["RWKV_HEAD_SIZE_A"] = str(args.head_size_a)
Expand Down