Giter Club home page Giter Club logo

Comments (9)

Ledzy avatar Ledzy commented on August 24, 2024

Thanks for your watch on our project. We now support deepspeed ZeRO-3 when using BAdam, please see our detailed instruction: https://github.com/Ledzy/BAdam?tab=readme-ov-file#partition-by-module-model-parallel.

from badam.

paulcx avatar paulcx commented on August 24, 2024

Could you provide a bit more detail, for example on how to use BAdamCallback? The examples in the Readme are not complete, are they?

from badam.

Ledzy avatar Ledzy commented on August 24, 2024

Could you provide a bit more detail, for example on how to use BAdamCallback? The examples in the Readme are not complete, are they?

Hi @paulcx , please follow the provided example:

from badam.utils import BAdamCallback

callbacks = original_callbacks.append(BAdamCallback) # add the callback
trainer = YourTrainerClass(
    ...,
    callbacks=callbacks
)

If there is no original_callbacks, just pass callbacks=[BAdamCallback] when initializing your Trainer.

from badam.

paulcx avatar paulcx commented on August 24, 2024

Could you provide a bit more detail, for example on how to use BAdamCallback? The examples in the Readme are not complete, are they?

Hi @paulcx , please follow the provided example:

from badam.utils import BAdamCallback

callbacks = original_callbacks.append(BAdamCallback) # add the callback
trainer = YourTrainerClass(
    ...,
    callbacks=callbacks
)

If there is no original_callbacks, just pass callbacks=[BAdamCallback] when initializing your Trainer.

My understanding is that BAdam doesn’t need to be initialized? How about the zero3 config. Is anything need to be done except these codes above?

from badam.

Ledzy avatar Ledzy commented on August 24, 2024

To use ZeRO-3, you should create a configuration file which specifies ZeRO stage and other configurations; see https://github.com/Ledzy/BAdam/blob/master/sample_ds_zero3.json for an example. You script should be launched using deepspeed or accelerate launch or other distributed launching command, depending on your circumstance.

The aforementioned part is the setup of Deepspeed and is decouple with the optimizers, e.g. BAdam. Using BAdam under ZeRO-3 is almost the same as using it in single GPU mode, except that one needs to

  1. pass ds_zero3_enabled=True when creating BlockOptimizer, and
  2. create a reference to deepspeed optimizer, which can be achieved by
  • approach 1: simply set block_optim.ds_optimizer = ds_optimizer after deepspeed.initialize, or
  • approach 2: add an additional BAdamCallback when instancing your Trainer, which actually does the same thing as approach 1; this is cleaner when using huggingface Trainer.

Hope my response is helpful for you. Feel free to reach us if you have any other questions.

from badam.

paulcx avatar paulcx commented on August 24, 2024

In approach 2, step 1 (pass ds_zero3_enabled=True when creating BlockOptimizer) is not required?

from badam.

Ledzy avatar Ledzy commented on August 24, 2024

It's required for the current version.

from badam.

paulcx avatar paulcx commented on August 24, 2024

In deepspeed+huggingface Trainer approach, the optimizer parameters are saved in ds_config.json. For example,
"optimizer": { "type": "AdamW", "params": { "lr": "auto", "betas": [ 0.9, 0.999 ], "eps": 1e-8, "weight_decay": "auto" }
Is an example of BlockOptimizer?

from badam.

Ledzy avatar Ledzy commented on August 24, 2024

BlockOptimizer inherit configurations in ds_config.json

from badam.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.