Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Paged Optimizers (Adam, Adamw), 8-bit optimizers, and new optimizers: LARS, LAMB and LION #3588

Merged
merged 30 commits into from
Sep 8, 2023

Conversation

arnavgarg1
Copy link
Contributor

@arnavgarg1 arnavgarg1 commented Sep 6, 2023

This PR adds support for a variety of new optimizers, including paged and 8-bit variants. All of these are useful for fine-tuning. I will add better descriptions for parameters in a follow-up PR when I better understand some of the underlying papers for LAMB, LARS and LION. I will also add tests once #3578 PR lands.

What are paged optimizers?

Paged Optimizers use NVIDIA unified memory 3 feature which does automatic page-to-page transfers between the CPU and GPU for error-free GPU processing in the scenario where the GPU occasionally runs out-of-memory. The feature works like regular memory paging between CPU RAM and the disk. This allocates paged memory for the optimizer states which are then automatically evicted to CPU RAM when the GPU runs out-of-memory and paged back into GPU memory when the memory is needed in the optimizer update step.

Screenshot 2023-09-05 at 8 23 14 PM

What new optimizers are being added to Ludwig?

Here's a summary of the new optimizers that will be added with this PR:

  • SGD: 8-bit support
  • Adam: 8-bit, Paged Adam, Paged Adam 8-bit
  • AdamW: 8-bit, Paged AdamW, Paged AdamW 8-bit
  • Adagrad: 8-bit
  • RMSProp: 8-bit
  • LAMB, Lamb 8-bit
  • LARS, LARS 8-bit
  • LION, LION 8-bit, Paged LION, Paged LION 8-bit

Here's an example of how you can set these different variants:

Regular AdamW

trainer:
  optimizer:
    type: adamw

8-Bit AdamW

trainer:
  optimizer:
    type: adamw_8bit

Paged AdamW

trainer:
  optimizer:
    type: paged_adamw

Paged AdamW 8-bit

trainer:
  optimizer:
    type: paged_adamw_8bit

All of this has been made possible through a deeper integration with the bitsandbytes library directly. Note that the 8-bit and paged optimizers only work on GPU machines, and they are not compatible with Deepspeed.

@github-actions
Copy link

github-actions bot commented Sep 6, 2023

Unit Test Results

       6 files  ±0         6 suites  ±0   1h 40m 56s ⏱️ + 16m 20s
2 830 tests +3  2 794 ✔️ +4  12 💤 ±0  24  - 1 
2 873 runs  +3  2 828 ✔️ +4  21 💤 ±0  24  - 1 

For more details on these failures, see this check.

Results for commit 0158d03. ± Comparison against base commit 3d2ff0b.

♻️ This comment has been updated with latest results.

@arnavgarg1 arnavgarg1 marked this pull request as ready for review September 6, 2023 18:07
@arnavgarg1 arnavgarg1 changed the title [WIP] Add support for Paged Optimizers (Adam, Adamw), 8-bit optimizers, and new optimizers: LARS, LAMB and LION Add support for Paged Optimizers (Adam, Adamw), 8-bit optimizers, and new optimizers: LARS, LAMB and LION Sep 6, 2023
ludwig/config_validation/checks.py Outdated Show resolved Hide resolved
ludwig/schema/optimizers.py Show resolved Hide resolved
@arnavgarg1 arnavgarg1 requested a review from tgaddair September 6, 2023 20:47
ludwig/models/llm.py Outdated Show resolved Hide resolved
@arnavgarg1 arnavgarg1 merged commit 6f9ed8f into master Sep 8, 2023
@arnavgarg1 arnavgarg1 deleted the paged_adamw branch September 8, 2023 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants