+
Skip to content

Conversation

bsowell
Copy link
Contributor

@bsowell bsowell commented Nov 6, 2024

There was a bug in how we pickled OpenAI class instances specifically with Azure. Azure OpenAI is a bit weird in that the "deployment name" of a model can be different than the normal OpenAI name. This makes it impossible to use the standard models from the OpenAIModels Enum. Instead, we typically created separate OpenAIModel instances. The problem was that when we pickled the OpenAI object, it saved just the model name, and then tried to recreate the model option by using the Enum. This change pickles the entire OpenAIModel class instead of just the name. Also adds a test that demonstrates the bug (and fix). The other tests were passing because they called the OpenAI methods directly and didn't pickle the object. The object will be pickled in basically any Sycamore job using ray.

There was a bug in how we pickled OpenAI class instances specifically with
Azure. Azure OpenAI is a bit weird in that the "deployment name" of a model
can be different than the normal OpenAI name. This makes it impossible to use
the standard models from the OpenAIModels Enum. Instead, we typically created
separate OpenAIModel instances. The problem was that when we pickled the
OpenAI object, it saved just the model name, and then tried to recreate the
model option by using the Enum. This change pickles the entire
OpenAIModel class instead of just the name. Also adds a test that
demonstrates the bug (and fix). The other tests were passing because they
called the OpenAI methods directly and didn't pickle the object. The object
will be pickled in basically any Sycamore job using ray.
@bsowell bsowell requested a review from HenryL27 November 6, 2024 04:49
Copy link
Collaborator

@HenryL27 HenryL27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

def test_azure_pickle(azure_llm):
pickled = pickle.dumps(azure_llm)
_ = pickle.loads(pickled)
assert True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe assert that the original and dumped/loaded are pointing at the same endpoint or something?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess if the point is just 'this doesn't crash' then it dont matter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my intention here was that it doesn't raise. I think we can rely on the pickle protocol assuming that it doesn't crash.

@bsowell bsowell merged commit c89374d into main Nov 6, 2024
14 checks passed
@bsowell bsowell deleted the fix_azure_openai_pickle branch November 6, 2024 14:58
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.

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载