Skip to content

Pydantic v2 migration#5167

Merged
loadams merged 68 commits into
masterfrom
mrwyattii/pydantic-2-support
Aug 22, 2024
Merged

Pydantic v2 migration#5167
loadams merged 68 commits into
masterfrom
mrwyattii/pydantic-2-support

Conversation

@mrwyattii

@mrwyattii mrwyattii commented Feb 21, 2024

Copy link
Copy Markdown
Contributor

Pydantic v2 has been out for some time now. We have been relying on using the v1 API available in v2 until now. This is a refresh of #3902 to bring proper v2 support to DeepSpeed.

Corresponding DeepSpeed-MII PR here.

@loadams

Comment thread requirements/requirements.txt
@loadams

loadams commented Feb 27, 2024

Copy link
Copy Markdown
Collaborator

Do you want to do what we did on the previous pydantic update of updating the nv-mii test to use your branch rather than main so that it passes here?

Comment thread .github/workflows/nv-a6000.yml
@mrwyattii

Copy link
Copy Markdown
Contributor Author

CI with deepspeedai/DeepSpeed-MII#423 for nv-a6000 and nv-mii

Comment thread .github/workflows/python.yml
@loadams

loadams commented Jul 1, 2024

Copy link
Copy Markdown
Collaborator

CI triggered using updates in MII

nv-a6000
nv-mii

Both tests now passing.

@loadams

loadams commented Aug 20, 2024

Copy link
Copy Markdown
Collaborator

Tested in #6382.

@loadams

loadams commented Aug 22, 2024

Copy link
Copy Markdown
Collaborator

@loadams
loadams merged commit 0a4457c into master Aug 22, 2024
weiji14 added a commit to regro-cf-autotick-bot/deepspeed-feedstock that referenced this pull request Aug 23, 2024
weiji14 added a commit to conda-forge/deepspeed-feedstock that referenced this pull request Aug 29, 2024
* updated v0.15.0

* MNT: Re-rendered with conda-build 24.7.1, conda-smithy 3.38.0, and conda-forge-pinning 2024.08.23.00.41.48

* Remove ninja as runtime dependency

Xref #1

* Remove note about pydantic<2.0.0 pin

Since deepspeedai/DeepSpeed#5167 is merged already.

---------

Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
mauryaavinash95 pushed a commit to DataStates/DeepSpeed that referenced this pull request Mar 20, 2025
Pydantic v2 has been out for some time now. We have been relying on
using the v1 API available in v2 until now. This is a refresh of deepspeedai#3902
to bring proper v2 support to DeepSpeed.

Corresponding DeepSpeed-MII PR
[here](deepspeedai/DeepSpeed-MII#423).

@loadams

---------

Co-authored-by: Logan Adams <114770087+loadams@users.noreply.github.com>
Co-authored-by: Logan Adams <loadams@microsoft.com>
Co-authored-by: Olatunji Ruwase <olruwase@microsoft.com>
Co-authored-by: Abhishek Kulkarni <11399+adk9@users.noreply.github.com>
Co-authored-by: Abhishek Kulkarni <abkulkarni@microsoft.com>
Co-authored-by: Lev Kurilenko <113481193+lekurile@users.noreply.github.com>
banxingmjj pushed a commit to openanolis/DeepSpeed that referenced this pull request Jul 17, 2026
…eepspeedai#8145)

`DeepSpeedInferenceConfig.moe` is typed `Union[bool,
DeepSpeedMoEConfig]`, and the `moe_backward_compat` validator explicitly
handles the bool form (the old `init_inference(..., moe=<bool>)`
interface). But it builds `DeepSpeedMoEConfig(moe=field_value)` — and
`DeepSpeedMoEConfig` has no `moe` field (it has `enabled`). Since
`DeepSpeedConfigModel` sets `extra="forbid"`, every bool `moe` raises a
`ValidationError` instead of building the config:

```python
>>> from deepspeed.inference.config import DeepSpeedInferenceConfig
>>> DeepSpeedInferenceConfig(moe=True)
pydantic_core._pydantic_core.ValidationError: 1 validation error for DeepSpeedMoEConfig
moe
  Extra inputs are not permitted [type=extra_forbidden, ...]
```

Both `moe=True` and `moe=False` crash, so the documented backward-compat
path is unusable. The fix passes `enabled=field_value` (the actual
field) so the bool is turned into a `DeepSpeedMoEConfig` as intended.

The line dates back to deepspeedai#2516 and survived the pydantic-v2 migration
(deepspeedai#5167) unchanged.

Added a regression test (`test_moe_backward_compat_bool`) asserting the
bool form builds a `DeepSpeedMoEConfig` with the matching `enabled`.
`yapf` and `flake8` clean.

Signed-off-by: winklemad <winklemad@outlook.com>
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.

6 participants