kubeflow / model-registry

Apache License 2.0
76 stars 42 forks source link

MLFLOW MR & HuggingFace & KFMR logical model comparison #94

Open mzhl1111 opened 4 months ago

mzhl1111 commented 4 months ago

Is your feature request related to a problem? Please describe.

Describe the solution you'd like finalize the design for schema of middle layer that transform outer MR logical model to KFMR MLFlow ref

Schema KFMR MLFlow Existed Huggingface integratoin
Registered Model Git repo, CR repo/name, Hugging Face Repo, Name String Name string + (mlflow artifact)version can offer a run id (can be seen as a repo inside mlflow) Hugging Face repo
Model Version A git tag, A container image tag, string represent user input user input
Model Artifact ONIX, pickle, .ckpt file download by API(pass the URL) down load with API
Doc Artifact A README.md file If exists as an artifact of the same run, can be downloaded If exists in the repo, can be downloaded

Discussion needed

Note: the structure inside the map can be different

image
mzhl1111 commented 4 months ago

/assign @mzhl1111

mzhl1111 commented 4 months ago

draft version "https://github.com/mzhl1111/model-registry/commit/abd424295dd03520260d303f8cc47012a1cc1442"

updated (unit test added) https://github.com/mzhl1111/model-registry/commit/a5a2edd9487297f32748ee64d70fe76b3cee3eea

mzhl1111 commented 2 months ago

To track the model artifact from mlflow, we need to follow the following steps

get the "Source" URL in mlflow

This can be done directly via the mlflow Api (Green), but lead us only to the parent directory of the model artifact(gray). The image is an example of a registered model with Pytorch format.

image

what we want is the file in the blue file, thus we need the metadata

image

To locate the model artifact we need to contact the source URL and the filename we get from the metadata.

Issue we have.

Different model format/flavor have different info-storing structures of the metadata.

The following is sklearn format, and it uses different keys in metadata to store the filename of the model artifact

image

model artifact name in metadata may change

I found the touch model artifact changed from pickled_model.pth to model.pth, but now this is hard-coded in our code, because we can only get '/data' from metadata and concat with source URL.

If we use the mlflow Runtime as the downstream format for Kserve to use, which they support, we do not need to do these hard coding parts to get an absolute directory of the model artifact.