web-llm icon indicating copy to clipboard operation
web-llm copied to clipboard

Invalidate cached WebAssembly binaries

Open christianliebel opened this issue 1 year ago • 8 comments

The model-specific WebAssembly binaries are cached and stored in the client-side cache on the user’s device (webllm/wasm). However, the JavaScript portion of WebLLM is distributed with the application. This can lead to scenarios where the library and the Wasm are updated, but the user still has an old WebAssembly binary in their cache, breaking the application (see #221). I propose introducing an invalidation system (e.g., using versions or hashes, etc.). If the WebLLM JS library is not compatible with the Wasm binary stored locally, it should remove the cache entry and attempt to download the Wasm binary again.

christianliebel avatar Feb 23 '24 09:02 christianliebel

Thanks for the suggestion! We are thinking about adding versioning to the binary name, say Llama-v0.2.21, then when updating it we update it to Llama-v0.2.22 so the outdated one in user's cache will not be used and be removed.

CharlieFRuan avatar Feb 23 '24 17:02 CharlieFRuan

but what recently changed that a re download was needed of the model? we can't make each user download 10+GB too many times... thanks

UXDart avatar Feb 26 '24 06:02 UXDart

I don't think the recent changes require redownloading. Besides, if we were to redownload a model, only the model library (tens of MB) is needed, not the weights.

CharlieFRuan avatar Feb 27 '24 03:02 CharlieFRuan

it's been already a few times that even on the chat demo, I need to clear the cache to be able to to make it work. it just happens in the last release of the npm web llm, I updated from .20 to .23 and get this error, I can't find the reason, when calling reload mistral model get ExitStatus {name: 'ExitStatus', message: 'Program terminated with exit(1)', status: 1} when it is on 40-60%. if I clear the cache it works but then it can't load from cache again. if I go back to .20 it works ok. what it could be? thanks - using chrome on mac

UXDart avatar Feb 27 '24 07:02 UXDart

it's been already a few times that even on the chat demo, I need to clear the cache to be able to to make it work. it just happens in the last release of the npm web llm, I updated from .20 to .23 and get this error, I can't find the reason, when calling reload mistral model get ExitStatus {name: 'ExitStatus', message: 'Program terminated with exit(1)', status: 1} when it is on 40-60%. if I clear the cache it works but then it can't load from cache again. if I go back to .20 it works ok. what it could be? thanks - using chrome on mac

Same happens to me for every model on chrome extension. Do not know how to fix it. I am also using chrome on mac

kudaibergenu avatar Mar 01 '24 09:03 kudaibergenu

@UXDart This shouldn't be related to the model library versioning issue described by the OP. Seems to be more related to https://github.com/mlc-ai/web-llm/issues/322 and https://github.com/mlc-ai/web-llm/issues/313. Will look into this issue today; meanwhile clearing the cache might alleviate the issue as a temporary workaround.

CharlieFRuan avatar Mar 01 '24 15:03 CharlieFRuan

@UXDart @kudaibergenu Just updated the npm to 0.2.24: https://github.com/mlc-ai/web-llm/pull/323

This should fix it. Let us know if issues persist. Thank you!

CharlieFRuan avatar Mar 02 '24 05:03 CharlieFRuan

Update: we now support wasm versioning such that whenever a new version of wasm is required, we will download the new wasm (since the URL is different). The idea is that each web-llm npm version binds to a wasm version. See the PR below for more:

  • https://github.com/mlc-ai/web-llm/pull/355

CharlieFRuan avatar Apr 10 '24 01:04 CharlieFRuan

Closing this issue as completed; feel free to open new ones!

CharlieFRuan avatar Jun 04 '24 19:06 CharlieFRuan