-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Open
Labels
coreIssues that should be addressed in Ray CoreIssues that should be addressed in Ray CoreperformanceserveRay Serve Related IssueRay Serve Related Issuetech-debtThe issue that's due to tech debtThe issue that's due to tech debt
Description
Summary
This RPC proposes dropping support for Pydantic v1 in Ray and migrating all code to use Pydantic v2 native APIs. This will simplify the codebase, remove technical debt from the compatibility layer, and allow Ray to take advantage of Pydantic v2's performance improvements and modern features.
Motivation
Current State
Ray currently supports both Pydantic v1 and Pydantic v2 through a compatibility layer (ray._common.pydantic_compat). When Pydantic v2 is installed, Ray imports from pydantic.v1 to maintain backward compatibility. This approach has several drawbacks, but most prominent are Performance and Feature limitation.
Pydantic v1 End of Life
- Pydantic v1 has been superseded by v2 since June 2024
- Pydantic v2 has been stable for over 2 years
- The Python ecosystem has largely migrated to Pydantic v2
- Continued v1 support limits Ray's ability to adopt modern dependencies
Proposal
Migration Timeline
We propose a phased approach to dropping Pydantic v1 support:
Phase 1: Announcement (Ray 2.53)
- Send announcement to ray-dev mailing list about upcoming Pydantic v1 deprecation
- Update Ray documentation to mention Pydantic v2 requirement in future releases
- Add deprecation notice to release notes
- Add runtime check to emit clear error message if Pydantic v1 detected
Phase 2: Drop Support (Ray 2.56)
- Update
setup.pyto set pydantic version constraint:pydantic>=2.5,<3 - Update CI/CD pipelines to remove tests for Pydantic v1
- Communicate changes in release notes
Phase 3: Migrate Ray Code to v2 (Ray 2.59)
- Remove
python/ray/_common/pydantic_compat.pycompatibility layer - Update all imports to use native Pydantic v2 APIs:
-
ray.servecomponents -
ray.traincomponents -
ray.llmcomponents -
ray.util.statecomponents - Core serialization code
-
- Remove all
IS_PYDANTIC_2conditional checks - Update imports from
pydantic.v1topydanticthroughout codebase - Remove dual-path test code that validates both v1 and v2
- Final release notes documenting completion of migration
References
akshay-anyscale
Metadata
Metadata
Assignees
Labels
coreIssues that should be addressed in Ray CoreIssues that should be addressed in Ray CoreperformanceserveRay Serve Related IssueRay Serve Related Issuetech-debtThe issue that's due to tech debtThe issue that's due to tech debt