Skip to content

Automatically select CPU Adam when offloading optimizer#144

Open
sfc-gh-mwyatt wants to merge 2 commits into
mainfrom
mwyatt/auto-cpu-adam
Open

Automatically select CPU Adam when offloading optimizer#144
sfc-gh-mwyatt wants to merge 2 commits into
mainfrom
mwyatt/auto-cpu-adam

Conversation

@sfc-gh-mwyatt
Copy link
Copy Markdown
Collaborator

@sfc-gh-mwyatt sfc-gh-mwyatt commented Apr 10, 2025

Added a config validator that automatically modifies the optimizer type to use cpu_adam when the DeepSpeed config uses optimizer offload to CPU.

TODO:

  • Add unit test

Comment on lines +339 to +340
if self.deepspeed.get("cpu_offload", {}).get("device", None) == "cpu" and self.optimizer.type == "fusedadam":
self.optimizer.type = "cpu_adam"
Copy link
Copy Markdown
Collaborator

@sfc-gh-sbekman sfc-gh-sbekman Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it assert if a user has an explicit self.optimizer.type set to the wrong value? like:

zero_optimization.offload_optimizer.device.cpu is configured therefore optimizer.type=cpu_adam is required, but the config file has optimizer.type=... . Please either set it to cpu_adam or remove the explicit config and it'll be set automatically

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.

2 participants