Skip to content

Conversation

@mrwyattii
Copy link
Contributor

@mrwyattii mrwyattii commented Jun 9, 2022

Brings Pydantic into the zero config:

  • Defines a base DeepSpeedConfigModel class which ZeRO and offload configs inherit. This class allows us to enforce extra params are not provided in the config and also implements logic for deprecated config params
  • Unify the ZeRO (and offload) constants.py and config.py into a single Pydantic class that contains the default values for all parameters
  • Changes in the rest of the code to remove values defined in constants.py

@mrwyattii mrwyattii changed the title Refactor Zero Configs to us Pydantic Refactor Zero Configs to use Pydantic Jun 9, 2022
@mrwyattii mrwyattii changed the title Refactor Zero Configs to use Pydantic Refactor ZeRO configs to use Pydantic Jun 9, 2022
@jeffra
Copy link
Collaborator

jeffra commented Jun 9, 2022

This PR is aiming to help with this longstanding issue #653

/cc @stas00

@stas00
Copy link
Collaborator

stas00 commented Jun 9, 2022

Wonderful! Thank you for the heads up, Jeff!

Also probably extending hjson-support to the rest of DS config would be great, but doesn't have to be part of this PR - just a suggestion.

@jeffra
Copy link
Collaborator

jeffra commented Jun 9, 2022

Absolutely, I think adding hjson + pydantic support is the eventual goal. Once all of our configs are managed by pydantic the goal is to also replace the config-json page with a read-the-docs style page that is auto-generated from doc-strings that are easier to maintain and more accurate. However, one step at a time :)

@mrwyattii mrwyattii requested a review from samadejacobs as a code owner July 26, 2022 19:51
prev_best_metric_val=0):
config_zero = tuning_space.get(ZERO_OPTIMIZATION, {})
stage = config_zero.get(ZERO_OPTIMIZATION_STAGE, ZERO_OPTIMIZATION_STAGE_DEFAULT)
stage = config_zero.stage
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this a bug if config_zero equals {}, and leads to evaluation of {}.stage?

pydantic.BaseModel to allow for deprecated fields. To enable this feature,
add deprecated=True to pydantic.Field:
my_dep_field: int = Field(0, deprecated=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you document first argument of Field(, i.e., 0.?

@tjruwase tjruwase merged commit 5997589 into deepspeedai:master Jul 27, 2022
rahilbathwal5 added a commit to neevaco/DeepSpeed that referenced this pull request Aug 3, 2022
rahilbathwal5 added a commit to neevaco/DeepSpeed that referenced this pull request Aug 3, 2022
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.

4 participants