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

feat: allow to import local models #771

Merged
merged 15 commits into from
Apr 11, 2024
Merged

feat: allow to import local models #771

merged 15 commits into from
Apr 11, 2024

Conversation

lstocchi
Copy link
Contributor

@lstocchi lstocchi commented Apr 2, 2024

What does this PR do?

It allows to import .gguf models that have already been downloaded by the user and that are on his machine.
After imported, the user can start a service, open its folder and delete it

Screenshot / video of UI

import_model

What issues does this PR fix or reference?

it resolves #173

Fixes #814

How to test this PR?

  1. download a gguf model which is not listed in the catalog (e.g. take the first ones from here https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF/tree/main
  2. go to models, import, select the gguf file
  3. once imported, try to play with it (inference server + playground)
  4. then delete it (it will be removed from catalog and disk)

@slemeur
Copy link
Contributor

slemeur commented Apr 2, 2024

Nice!

@lstocchi lstocchi force-pushed the i173 branch 2 times, most recently from 6e4bc2f to 869ee6e Compare April 3, 2024 09:16
@lstocchi lstocchi marked this pull request as ready for review April 3, 2024 09:17
@lstocchi lstocchi requested review from benoitf and a team as code owners April 3, 2024 09:17
@lstocchi
Copy link
Contributor Author

lstocchi commented Apr 3, 2024

There is an issue when you delete a model having an inference server using it and you stop/start ai lab again. Fixing it

Copy link
Contributor

@axel7083 axel7083 left a comment

Choose a reason for hiding this comment

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

Nice feature ! I added some comment

packages/backend/src/managers/catalogManager.ts Outdated Show resolved Hide resolved
});
}

const customCatalog = path.resolve(this.appUserDirectory, 'catalog.json');
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should have two catalog here. I am not in favor of overwriting the native catalog, I feel it would be more appropriate to have some kind of user-models.json in the appUserDirectory what do you think ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my point of view the operation that the user is doing here it is just updating the custom catalog.json file that we already support. It is just that we guide them. But if someone wants to add a new model manually we are already saying that they need to create a catalog.json file (copy/paste the assets/ai.json) inside the ai-lab folder and update it.

So i wouldn't create a new file as it may overcomplicate stuff, but let's see what others think

Copy link
Contributor

Choose a reason for hiding this comment

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

How do you handle the case where we update on our side the catalog ? Are we losing the user imported models ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When importing, if the catalog.json file already exists, it just adds the new models in there and update the file on disk. If it does not exists it creates it on disk by copying the content from the native ai.json and adding the imported models.

So if the user wants to update the catalog after having imported models he would work as before. Open the catalog.json file which would also contain the imported models and edit it.

Copy link
Contributor

Choose a reason for hiding this comment

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

What if some day we want to remove a model ? like we did with llama2 ? the mechanism you describe would not be suitable ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the same thing that may happen today. If i create my custom catalog.json and we update ai.json, ai-lab will still point to the custom catalog. We have to refactor how the custom catalog + ai.json work or inform the user any update. Opening an issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

-> #792

Copy link
Contributor

Choose a reason for hiding this comment

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

Okey good to have follow up issue thanks !

Copy link
Contributor

Choose a reason for hiding this comment

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

What about having the 2 files but merging them instead of choosing one over the other

Copy link
Contributor

@axel7083 axel7083 left a comment

Choose a reason for hiding this comment

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

Almost looking good just some stuff I find out while testing it

Breadcrumb

image

Could we have the breadcrumb allowing to go back to models page ?

Import timeout

Taking very long time to select a file in explorer gave a timeout

image

We probably need to find out some kind of way to get back this value and update the form. (This could be skipped, but would need to be address at some point)

Selected file

Maybe I should not be able to select files inside the models folder ?

image

If I import a model from the AI-Studio, it gets weird

image

@lstocchi
Copy link
Contributor Author

lstocchi commented Apr 3, 2024

Nice catches!!

Almost looking good just some stuff I find out while testing it

Breadcrumb

Done

Import timeout

Taking very long time to select a file in explorer gave a timeout

I'll give a look on desktop side as the timeout is really tight. For the moment i added an error message if something unexpected happen so the user is informed.

Selected file

Maybe I should not be able to select files inside the models folder ?

Added a check to verify that the selected model is not already in the catalog.

@lstocchi lstocchi requested a review from axel7083 April 3, 2024 23:49
@jeffmaury
Copy link
Contributor

The size information is missing and I'm wondering how the RAM usage is computed

Copy link
Contributor

@jeffmaury jeffmaury left a comment

Choose a reason for hiding this comment

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

The timeout issue is to be fixed because it breaks the user experience

@lstocchi
Copy link
Contributor Author

lstocchi commented Apr 4, 2024

The size information is missing and I'm wondering how the RAM usage is computed

The RAM usage is = size of the file as it seems to me that that is the value we use in the catalog, no?

@lstocchi
Copy link
Contributor Author

lstocchi commented Apr 4, 2024

@jeffmaury timeout removed and size + creation date added

@feloy
Copy link
Contributor

feloy commented Apr 4, 2024

The size information is missing and I'm wondering how the RAM usage is computed

The RAM usage is = size of the file as it seems to me that that is the value we use in the catalog, no?

No, the ram usage does not come from the file size. For the models in the catalog, it is computed with the script in .github/workflows/compute-model-sizes.yaml (see #674)

@lstocchi
Copy link
Contributor Author

lstocchi commented Apr 4, 2024

The size information is missing and I'm wondering how the RAM usage is computed

The RAM usage is = size of the file as it seems to me that that is the value we use in the catalog, no?

No, the ram usage does not come from the file size. For the models in the catalog, it is computed with the script in .github/workflows/compute-model-sizes.yaml (see #674)

Ah I completely missed that part. Thanks for telling me. Removed the memory property for the moment then. 👍

@lstocchi lstocchi requested a review from axel7083 April 4, 2024 10:35
@jeffmaury
Copy link
Contributor

The size information is missing and I'm wondering how the RAM usage is computed

The RAM usage is = size of the file as it seems to me that that is the value we use in the catalog, no?

No, the ram usage does not come from the file size. For the models in the catalog, it is computed with the script in .github/workflows/compute-model-sizes.yaml (see #674)

Ah I completely missed that part. Thanks for telling me. Removed the memory property for the moment then. 👍

I would rather default the memory field to the file size

@axel7083
Copy link
Contributor

axel7083 commented Apr 4, 2024

The size information is missing and I'm wondering how the RAM usage is computed

The RAM usage is = size of the file as it seems to me that that is the value we use in the catalog, no?

No, the ram usage does not come from the file size. For the models in the catalog, it is computed with the script in .github/workflows/compute-model-sizes.yaml (see #674)

Ah I completely missed that part. Thanks for telling me. Removed the memory property for the moment then. 👍

I would rather default the memory field to the file size

I think this is misleading and does not reflect reality

@vrothberg
Copy link
Member

If we don't have the information about the resource constraints of a model, I wouldn't guess it. Maybe we can display NA (not available) for imported models?

@lstocchi lstocchi requested a review from axel7083 April 4, 2024 14:18
@jeffmaury
Copy link
Contributor

The size information is missing and I'm wondering how the RAM usage is computed

The RAM usage is = size of the file as it seems to me that that is the value we use in the catalog, no?

No, the ram usage does not come from the file size. For the models in the catalog, it is computed with the script in .github/workflows/compute-model-sizes.yaml (see #674)

Ah I completely missed that part. Thanks for telling me. Removed the memory property for the moment then. 👍

I would rather default the memory field to the file size

I think this is misleading and does not reflect reality

Both are in the same order of magnitude (file size is a little bit bigger) and as we will check the machine size based on this data, I would rather ask a little bit of additional memory than risking failures

Copy link
Contributor

@axel7083 axel7083 left a comment

Choose a reason for hiding this comment

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

LGTM ! 🚀 thanks you for your patience and the fixes, great job!

lstocchi and others added 14 commits April 9, 2024 19:22
Signed-off-by: lstocchi <lstocchi@redhat.com>
Signed-off-by: lstocchi <lstocchi@redhat.com>
… on the catalog

Signed-off-by: lstocchi <lstocchi@redhat.com>
… it when modelManager is disposed

Signed-off-by: lstocchi <lstocchi@redhat.com>
…something unexpected happen when adding a new model and fix css inputs

Signed-off-by: lstocchi <lstocchi@redhat.com>
…nels

Signed-off-by: lstocchi <lstocchi@redhat.com>
Signed-off-by: lstocchi <lstocchi@redhat.com>
Signed-off-by: lstocchi <lstocchi@redhat.com>
Co-authored-by: axel7083 <42176370+axel7083@users.noreply.github.com>
Signed-off-by: Luca Stocchi <49404737+lstocchi@users.noreply.github.com>
Co-authored-by: axel7083 <42176370+axel7083@users.noreply.github.com>
Signed-off-by: Luca Stocchi <49404737+lstocchi@users.noreply.github.com>
Co-authored-by: axel7083 <42176370+axel7083@users.noreply.github.com>
Signed-off-by: Luca Stocchi <49404737+lstocchi@users.noreply.github.com>
Signed-off-by: lstocchi <lstocchi@redhat.com>
Signed-off-by: lstocchi <lstocchi@redhat.com>
Signed-off-by: lstocchi <lstocchi@redhat.com>
@lstocchi
Copy link
Contributor Author

lstocchi commented Apr 9, 2024

@jeffmaury set the memory value equals to the file size as you said. Let me know if there is something else to change.
Also rebased.

Signed-off-by: lstocchi <lstocchi@redhat.com>
Copy link
Contributor

@jeffmaury jeffmaury left a comment

Choose a reason for hiding this comment

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

LGTM

@lstocchi lstocchi merged commit af00eed into containers:main Apr 11, 2024
4 checks passed
@lstocchi lstocchi deleted the i173 branch April 11, 2024 07:33
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.

Downloading model fails when using a user's catalog Import model
6 participants