Fix mlserver_huggingface settings device type#1486
Merged
Conversation
Contributor
|
@adriangonz, please take a look when you have a chance. It's a small change |
adriangonz
suggested changes
Nov 23, 2023
adriangonz
left a comment
Contributor
There was a problem hiding this comment.
Looks great @geodavic! 🚀
Would it make sense adding a small test to make sure this behaviour doesn't change in the future? This could be as simple as loading a model with device set to empty, -1, or cpu? And just asserting that the model loads correctly.
Contributor
Author
|
@adriangonz Thanks! I added a test that passes |
Contributor
Author
|
@adriangonz :) |
Contributor
Author
|
@sakoush if you don't mind taking a look, much appreciated! |
|
is there anything holding this back? |
sakoush
approved these changes
Mar 11, 2024
sakoush
left a comment
Contributor
There was a problem hiding this comment.
Lgtm. Many thanks for your contribution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If using a
model-settings.jsonof the following form:{ "name": "my-model", "implementation": "mlserver_huggingface.HuggingFaceRuntime", "parameters": { "extra": { "task": "text-generation", "pretrained_model": "model/path", "model_kwargs": { "load_in_8bit": true } } } }an error occurs when spinning up the server:
because the
load_in_8bitmodel kwarg makes forces the model to be loaded with Accelerate, andHuggingFaceSettings.devicedefault value of -1 is passed. I tried simply passing"device": nullto the model settings json to prevent this default value, but this wasn't accepted because the schema is typed toint.The solution is to expand the typing of
HuggingFaceSettings.deviceto accept null (and string, while we're at it). Therefore I have updated the typing toOptional[Union[int,str]], which is very close to the type hint used in the underlying transformers pipeline.I have tested the above model settings json with this change and the server starts as expected.