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

[Fix] Avoid unnecessary engine reload by correctly comparing ChatOption and AppConfig objects #399

Merged
merged 1 commit into from
May 15, 2024

Conversation

Neet-Nestor
Copy link
Contributor

Overview

Currently, even the client is initializing the worker engine with the exact same configurations, the worker will not correctly recognize this but instead it will unnecessarily re-initialize itself. The root cause is due to the use of === to compare object equity which is actually comparing object reference equity instead of value equity.

This PR fixed it by create utility functions for deep comparing the VALUE of these config objects. The code is tedious and thus I generated using AI models.

Test

Tested on https://chat.neet.coffee with the following code added to web_service_worker.ts.

        console.log("modelId same? " + this.modelId === params.modelId);
        console.log("chatOpts same? " + areChatOptionsEqual(this.chatOpts, params.chatOpts));
        console.log("appConfig same? " + areAppConfigsEqual(this.appConfig, params.appConfig));

Before the fix:

modelId same? true
chatOpts same? false
appConfig same? false

After:

modelId same? true
chatOpts same? true
appConfig same? true
Already loaded the model. Skip loading

@Neet-Nestor Neet-Nestor merged commit 4d1915e into mlc-ai:main May 15, 2024
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.

None yet

1 participant