Skip to content

Commit

Permalink
[Docs] Update the usage of bitsandbytes in Chinese document (#1359)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouzaida authored Sep 15, 2023
1 parent e91bfa4 commit 9b94af4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/en/common_usage/better_optimizers.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ runner = Runner(
model=ResNet18(),
work_dir='./work_dir',
train_dataloader=train_dataloader_cfg,
# To view the input parameters for DAdaptAdaGrad, you can refer to
# https://github.com/facebookresearch/dadaptation/blob/main/dadaptation/dadapt_adagrad.py
# To view the input parameters for AdamW8bit, you can refer to
# https://github.com/TimDettmers/bitsandbytes/blob/main/bitsandbytes/optim/adamw.py
optim_wrapper=dict(optimizer=dict(type='AdamW8bit', lr=1e-4, weight_decay=1e-2)),
train_cfg=dict(by_epoch=True, max_epochs=3),
)
Expand Down
31 changes: 31 additions & 0 deletions docs/zh_cn/common_usage/better_optimizers.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,34 @@ runner = Runner(
)
runner.train()
```

## bitsandbytes

[bitsandbytes](https://github.com/TimDettmers/bitsandbytes) 提供了 `AdamW8bit``Adam8bit``Adagrad8bit``PagedAdam8bit``PagedAdamW8bit``LAMB8bit``LARS8bit``RMSprop8bit``Lion8bit``PagedLion8bit``SGD8bit` 优化器。

```{note}
如使用 D-Adaptation 提供的优化器,需将 mmengine 升级至 `0.8.5`。
```

- 安装

```bash
pip install bitsandbytes
```

- 使用

`AdamW8bit` 为例。

```python
runner = Runner(
model=ResNet18(),
work_dir='./work_dir',
train_dataloader=train_dataloader_cfg,
# 如需查看 AdamW8bit 的输入参数,可查看
# https://github.com/TimDettmers/bitsandbytes/blob/main/bitsandbytes/optim/adamw.py
optim_wrapper=dict(optimizer=dict(type='AdamW8bit', lr=1e-4, weight_decay=1e-2)),
train_cfg=dict(by_epoch=True, max_epochs=3),
)
runner.train()
```

0 comments on commit 9b94af4

Please sign in to comment.