CarperAI / CarperAI/trlx

About the weight of word embedding being nan

Open
#503 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
4.8k
Forks
487
PR merge metrics
No merged PRs in 30d

Description

### 🐛 Describe the bug

In accelerate_base_trainer.py
```
for _ in range(self.config.train.epochs):
# For each batch
for mbs in MiniBatchIterator(self.train_dataloader, self.mb_size, self.num_mb):
# For each update per batch
for _ in range(self.n_updates_per_batch):
# Note that whereas standard policy gradient methods perform one
# gradient update per batch, PPO for example commonly performs
# multiple gradient updates on the same batch of data.
# https://arxiv.org/pdf/1707.06347.pdf
forward_time = 0
backward_time = 0
stats_accum = []
for mb in mbs:
with self._accumulate():
forward_time -= time()
loss, stats = self.loss(mb)
```
the first loop, the total loss be 0.11, when continue, I find the loss changed to nan, even if the input(mb) is the same. After debug I find that from the second loop, the weight of word_embedding changed to nan, I don't why.
![image](https://github.com/CarperAI/trlx/assets/13641798/87d027cd-30c0-458f-9d34-aafd9614d12f)
![image](https://github.com/CarperAI/trlx/assets/13641798/f1aef8ba-9ed2-46f6-b2a9-4ca907fdca3a)

![image](https://github.com/CarperAI/trlx/assets/13641798/2874f841-b7db-44d5-9bca-4f51f65bb864)

BTW, I changed some code in trlx to suit chatglm.

### Which trlX version are you using?

_No response_

### Additional system and package information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.