Open Anuj040 opened 1 year ago
I was able to solve the memory related issues. However I am still stuck with following issues: With the following strategy
elif args.strategy == 'colossalai_gemini':
strategy = ColossalAIStrategy(stage=3, placement_policy='cuda', initial_scale=2**5, shard_init=True)
leads to
AssertionError: You should use `zero_ddp_wrapper` first
โญโโโโโโโโโโโโโโโโโโโโโ Traceback (most recent call last) โโโโโโโโโโโโโโโโโโโโโโโฎ
โ /rlhf/applications/Chat/train_prompts.py:286 in <module> โ
โ โ
โ 283 โ parser.add_argument('--kl_coef', type=float, default=0.1) โ
โ 284 โ parser.add_argument('--ptx_coef', type=float, default=0.9) โ
โ 285 โ args = parser.parse_args() โ
โ โฑ 286 โ main(args) โ
โ 287 โ
โ โ
โ /rlhf/applications/Chat/train_prompts.py:213 in main โ
โ โ
โ 210 โ โ return {k: v.to(torch.cuda.current_device()) for k, v in batch โ
โ 211 โ if is_rank_0(): โ
โ 212 โ โ print("12") โ
โ โฑ 213 โ (actor, actor_optim), (critic, critic_optim) = strategy.prepare((a โ
โ 214 โ if is_rank_0(): โ
โ 215 โ โ print("15") โ
โ 216 โ
โ โ
โ /rlhf/applications/Chat/coati/trainer/strategies/base.py:84 in prepare โ
โ โ
โ 81 โ โ โ โ assert len(arg) == 2, f'Expect (model, optimizer) pair โ
โ 82 โ โ โ โ model, optimizer = arg โ
โ 83 โ โ โ โ model = prepare_model(model) โ
โ โฑ 84 โ โ โ โ optimizer = self.setup_optimizer(optimizer, self._unwr โ
โ 85 โ โ โ โ rets.append((model, optimizer)) โ
โ 86 โ โ โ elif isinstance(arg, nn.Module): โ
โ 87 โ โ โ โ rets.append(prepare_model(arg)) โ
โ โ
โ /rlhf/applications/Chat/coati/trainer/strategies/colossalai.py:147 in โ
โ setup_optimizer โ
โ โ
โ 144 โ โ
โ 145 โ def setup_optimizer(self, optimizer: optim.Optimizer, model: nn.Mo โ
โ 146 โ โ assert isinstance(optimizer, (CPUAdam, HybridAdam)), f'Unsuppo โ
โ โฑ 147 โ โ return zero_optim_wrapper(model, optimizer, optim_config=self. โ
โ 148 โ โ
โ 149 โ def backward(self, loss: torch.Tensor, model: nn.Module, optimizer โ
โ 150 โ โ optimizer.backward(loss) โ
โ โ
โ /opt/conda/lib/python3.9/site-packages/colossalai/zero/wrapper.py:83 in โ
โ zero_optim_wrapper โ
โ โ
โ 80 โ โ โ โ >>> zero2_config = dict(reduce_bucket_size=12 * 1024 * โ
โ 81 โ โ โ โ >>> optim = zero_optim_wrapper(model, optim, optim_con โ
โ 82 โ """ โ
โ โฑ 83 โ assert hasattr(model, "_colo_zero_stage"), "You should use `zero_d โ
โ 84 โ zero_stage = getattr(model, "_colo_zero_stage") โ
โ 85 โ โ
โ 86 โ assert norm_type == 2.0, "Current ZeRO optimizers only support 'no โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
๐ Describe the bug
I am following this blog https://medium.com/pytorch/colossalchat-an-open-source-solution-for-cloning-chatgpt-with-a-complete-rlhf-pipeline-5edf08fb538b to train a 6.7B parameter model. The blog outlines training scheme for a 7B model. So I expect it to be more or less same.
When I use
colossalai_zero2_cpu
, the execution stops with the following tracebackBelieving it to be the case of insufficient GPU memory, I thought perhaps the model needs to be sharded. With
colossalai_gemini
startegy, the job crashed with the same errors as before.Next I though of trying a mix and match of last two strategies
For the sake of testing, I reduced the size of reward model to 2.7B while keeping the actor model size to 6.7B. It led to following errors/warnings
Following the advice here, I implemented the following
Something to notice, even with
shard_init = True
I would have expected the pipeline parallel size or tensor parallel size to be different from 1.
After implemented the above hacky sharding solution, the models were initialized alright but the job crashed with the following traceback
when both the models were 6.7B parameters.
All help will be appreciated.
Environment
8 Tesla V100 32GB RAM shm: 512 CUDA Version 11.6