[Web] Support string[] in setPackedFunc() and exceptionally long arrays#16910
Merged
MasterJH5574 merged 2 commits intoapache:mainfrom Apr 21, 2024
Merged
[Web] Support string[] in setPackedFunc() and exceptionally long arrays#16910MasterJH5574 merged 2 commits intoapache:mainfrom
MasterJH5574 merged 2 commits intoapache:mainfrom
Conversation
tqchen
reviewed
Apr 21, 2024
CharlieFRuan
added a commit
to mlc-ai/web-llm
that referenced
this pull request
Apr 22, 2024
### Changes Main changes include: - Support for JSON schema via #371 ### WASM Version All WASMs are updated to `v0_2_34` reflect the change in MLC's runtime. ### TVMjs TVMjs compiled at apache/tvm@57316da - Main change: apache/tvm#16910 ### Note on wasm versioning We updated all WASMs, as reflected by `modelVersion` in `src/config.ts` (reflected by the new folder `v0_2_34` in [binary-mlc-llm-libs](https://github.com/mlc-ai/binary-mlc-llm-libs/tree/main/web-llm-models)) and hence the implicitly updated `webllm.prebuiltAppConfig`. See mlc-ai/binary-mlc-llm-libs#118 on the commits of MLC and TVM when compiling these models. <0.2.34 users can still use WebLLM without breaking as we keep v0_2_30 models, and the links bind to the npm. Users also do not need to clear cache since `0.2.34` models have a different
atebites-hub
pushed a commit
to atebites-hub/web-llm
that referenced
this pull request
Oct 4, 2025
…#375) ### Changes Main changes include: - Support for JSON schema via mlc-ai#371 ### WASM Version All WASMs are updated to `v0_2_34` reflect the change in MLC's runtime. ### TVMjs TVMjs compiled at apache/tvm@57316da - Main change: apache/tvm#16910 ### Note on wasm versioning We updated all WASMs, as reflected by `modelVersion` in `src/config.ts` (reflected by the new folder `v0_2_34` in [binary-mlc-llm-libs](https://github.com/mlc-ai/binary-mlc-llm-libs/tree/main/web-llm-models)) and hence the implicitly updated `webllm.prebuiltAppConfig`. See mlc-ai/binary-mlc-llm-libs#118 on the commits of MLC and TVM when compiling these models. <0.2.34 users can still use WebLLM without breaking as we keep v0_2_30 models, and the links bind to the npm. Users also do not need to clear cache since `0.2.34` models have a different
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are two changes in this PR.
Change 1: Support
string[]insetPackedFunc()Prior to this PR, we cannot pass in
string[]from typescript to a TVM PackedFunc and need to convert it toTVMArray<TVMString>(for instance ingetParamsFromCacheByName()). This may not be the most convenient if the PackedFunc's caller is not internal to tvmjs. Thus, this PR moves the conversion tosetPackedFunc()instead.Change 2: Support exceptionally long TVM arrays
The second change is dealing with exceptionally long TVM arrays. In cases like passing in a token table, we need to pass in a long
string[](in Llama-3's case, of size 128000), leading to JS errorRangeError: Maximum call stack size exceededsince we treat each string element as an argument, shown inthis.ctx.arrayMake(...inputs).This PR sets an empirical call stack limit of 30000 and chunks the array elements in
makeTVMArray(), converting each chunk to its own TVMArray. Then we concatenate them with the newly implementedruntime.ArrayConcatthat concatenates N TVMArrays.Tested end-to-end in WebLLM.