Pydantic 2
antoinejeannot opened this issue · 2 comments
Modelkit has pinned pydantic < 2 a few months ago since the latest 2.x version breaks BaseSettings.
A previous issue written by @victorbenichoux (see #189) and corresponding PR was merged to pin pydantic < 2 as a quick fix.
Nonetheless, as stated by @victorbenichoux (again) and backed by several profiling initiatives throughout the years:
- pydantic input and output validations represent a large overhead (around 30% of the inference time for models with lots of typed model dependencies)
- disabling
MODELKIT_ENABLE_VALIDATION
does not work with complex data types (it attempts at recursively and manually recreating the object without validating it in the first part) but still comes with the reconstruction overhead
As such, migrating modelkit to Pydantic 2 seems like a no-brainer, especially since it is now 2.4.x with a whole summer of patches, fixes and improvements!
It will be a good opportunity to bump a major version as well to celebrate the huge step forward in terms of speed (finally!)
@victorbenichoux would you still be happy to propose a PR, or discuss it ? :-)
Available in the 0.1.0.b1
pre-release on pypi!
Soon to be actually released under the stable 0.1.0
version once several migration tests have been carried out successfully
Now available as part of the modelkit 0.1.0
release & on main 🎉