-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Support custom imported module serialization with cloudpickle #8286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Left 2 minor comments, otherwise LGTM!
I added a section to the "Saving and Loading your DSPy program" tutorial explaining how to use the new dspy/docs/docs/tutorials/saving/index.md Lines 99 to 129 in e4b7148
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Description
This pull request implements the ability to pickle imported modules by value when saving whole programs.
This aims to solve issue #8285; a saved dspy program cannot be reliably loaded from a different directory if it uses an imported signature from another file.
Changes
A new optional
modules_to_serialize
parameter is added to thesave
method, allowing users to specify custom imported modules for serialization with cloudpickle.modules_to_serialize
is a list of modules, which are then registered for serialization by value usingcloudpickle.register_pickle_by_value
.For example, saving a module which uses an imported module:
Using this, modules can be loaded using
dspy.load
in a separate directory without any problems related to importing modules. This improves the ability to share dspy programs across computers and repositories, without any import issues.