Skip to content

Conversation

@Ygnas
Copy link
Contributor

@Ygnas Ygnas commented Aug 19, 2025

What does this PR do?

closes: #3150

Fixes the model cache not clearing when run.yaml model list changes by implementing proper cleanup mechanisms and adds unit tests.

Not sure exactly what is with all those models as listed_from_provider. At the moment they are still there.

Test Plan

Adding 2 models with:

curl -X POST http://127.0.0.1:8321/v1/models \
  -H "Content-Type: application/json" \
  -d '{
    "model_id": "my_llm",
    "provider_model_id": "gpt-3.5-turbo-0125",
    "provider_id": "openai",
    "model_type": "llm",
    "metadata": {}
  }'

And run.yaml

models:
  - metadata: {}
    model_id: testing-model
    provider_id: openai
    model_type: llm
    provider_model_id: gpt-4o-mini

Returned models looks like:

    "data": [
        {
            "identifier": "my_llm",
            "provider_resource_id": "gpt-3.5-turbo-0125",
            "provider_id": "openai",
            "type": "model",
            "metadata": {},
            "model_type": "llm"
        },
        {
            "identifier": "testing-model",
            "provider_resource_id": "gpt-4o-mini",
            "provider_id": "openai",
            "type": "model",
            "metadata": {},
            "model_type": "llm"
        },
...

After server restart and model removed from run.yaml only the manually added one remains:

    "data": [
        {
            "identifier": "my_llm",
            "provider_resource_id": "gpt-3.5-turbo-0125",
            "provider_id": "openai",
            "type": "model",
            "metadata": {},
            "model_type": "llm"
        },
...

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 19, 2025
@Ygnas Ygnas changed the title Fix model cache not clearing when run.yaml model list changes fix: clear model cache when run.yaml model list changes Aug 19, 2025
@Ygnas Ygnas force-pushed the model-cache branch 3 times, most recently from f32e42a to 91cf6a7 Compare August 19, 2025 11:31
@Ygnas Ygnas marked this pull request as ready for review August 19, 2025 11:35
Copy link
Contributor

@ashwinb ashwinb left a comment

Choose a reason for hiding this comment

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

I don't think we should do "store + cleanup" instead let's just not store things we don't want to be stored persistently. It seems like what we want to say generically is that there are three ways of registering models:

  • user provided (via the register API)
  • admin provided (via run.yaml)
  • provider provided (listed via the provider)

We need to only store the first parts and the rest are dynamically refreshed / loaded on every single startup of the server.

@cdoern
Copy link
Contributor

cdoern commented Sep 17, 2025

@Ygnas are you still working on this one?

@Ygnas Ygnas force-pushed the model-cache branch 2 times, most recently from 12d9a08 to db63f94 Compare September 18, 2025 10:30
@Ygnas Ygnas requested a review from ashwinb September 18, 2025 10:30
@Ygnas Ygnas changed the title fix: clear model cache when run.yaml model list changes WIP: fix: clear model cache when run.yaml model list changes Sep 18, 2025
@Ygnas Ygnas changed the title WIP: fix: clear model cache when run.yaml model list changes fix: clear model cache when run.yaml model list changes Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model cache is not cleared when model list in run.yaml is changed

4 participants