Skip to content
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

[BUG] Avoid serializing Callable kwargs during Completion #1862

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bahtman
Copy link

@bahtman bahtman commented Nov 26, 2024

Fixes #1759

@okhat
Copy link
Collaborator

okhat commented Nov 26, 2024

Wow super cool, thanks @bahtman ! I'll review this more carefully but I think we can merge soon

@okhat
Copy link
Collaborator

okhat commented Nov 26, 2024

Hmm, will the lru_cache work for callables? Do we need to add "ignore" parameter for the lru_cache to ignore callable_kwargs?

@bahtman
Copy link
Author

bahtman commented Nov 26, 2024

I was able to run the LM with a callable token provider. I’m unfamiliar with how the lru cache works, so unsure whether it actually caches the parameter.

This is a workaround so we don’t serialize it. But since we don’t serialize in the new Embed, it might be a relic? If that is the case we should just revert and remove the ujson part.

@bahtman
Copy link
Author

bahtman commented Nov 27, 2024

I did some digging. lru cache works as long as parameters are hashable (has hash() method)
https://docs.python.org/3/library/functools.html#functools.lru_cache

This is the case for callables, but not mutable containers like lists and dicts. This is probably the reason for the serialization.

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.

Using Azure token provider in dspy.LM
2 participants