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

[FFI] Re-introduce the boxed primitive values #17257

Merged
merged 3 commits into from
Aug 12, 2024

Conversation

Lunderberg
Copy link
Contributor

Initially introduced in #16183, these changes were reverted in #17252 due to performance degredation in some Relax models. This could occur when a model contained a large number of calls to "vm.builtin.tuple_getitem", which may occur when model weights are provided as a tuple.

This PR re-applies the changes from #16183, but with the performance degredation resolved. The root cause was unnecessary type-checking when converting from an untyped tvm::ArrayNode* to the typed tvm::Array<T>, in the case where T is ObjectRef.

Initially introduced in apache#16183,
these changes were reverted in
apache#17252 due to performance
degredation in some Relax models.  This could occur when a model
contained a large number of calls to `"vm.builtin.tuple_getitem"`,
which may occur when model weights are provided as a tuple.

This PR re-applies the changes from
apache#16183, but with the performance
degredation resolved.  The root cause was unnecessary type-checking
when converting from an untyped `tvm::ArrayNode*` to the typed
`tvm::Array<T>`, in the case where `T` is `ObjectRef`.
@Lunderberg Lunderberg requested a review from tqchen August 8, 2024 19:45
@tqchen
Copy link
Member

tqchen commented Aug 8, 2024

cc @vinx13 , would be great to confirm LLM perf before we merge this

@vinx13
Copy link
Member

vinx13 commented Aug 8, 2024

Confirmed the performance is good

@Lunderberg
Copy link
Contributor Author

Thank you on the confirmation! With how many parts could be impacted by this change, I very much appreciate the QC check.

@tqchen tqchen merged commit 02f4882 into apache:main Aug 12, 2024
19 checks passed
@Lunderberg Lunderberg deleted the ffi_boxed_primitive_values_take_2 branch August 12, 2024 13:17
Lunderberg added a commit to Lunderberg/tvm that referenced this pull request Aug 12, 2024
This reverts commit `02f48828e4b56995be0021c9a98e1705a837e712`.  The
post-merge builds on `main` are failing in CI on both MacOS and
Windows.  The failure modes do not appear to be caused by the FFI
changes, but the FFI changes impact enough parts of TVM that it's
difficult to say that definitively.
CharlieFRuan added a commit to mlc-ai/web-llm that referenced this pull request Aug 23, 2024
### Change
- #555

### TVMjs
- Updated to current head:
apache/tvm@1518008
  - Main change is apache/tvm#17251
- This is needed for WASMs compiled after
apache/tvm#17257 is merged (e.g. Phi-3.5). TVM
global functions that returns bool need this PR to run correctly (e.g.
`AcceptToken()` in BNFGrammar) in runtime.
- However, these are backward compatible to WASMs compiled prior to this
PR. Tested with Phi-3 (old WASM) running grammar.
jzhao62 pushed a commit to jzhao62/web-llm that referenced this pull request Dec 8, 2024
### Change
- mlc-ai#555

### TVMjs
- Updated to current head:
apache/tvm@1518008
  - Main change is apache/tvm#17251
- This is needed for WASMs compiled after
apache/tvm#17257 is merged (e.g. Phi-3.5). TVM
global functions that returns bool need this PR to run correctly (e.g.
`AcceptToken()` in BNFGrammar) in runtime.
- However, these are backward compatible to WASMs compiled prior to this
PR. Tested with Phi-3 (old WASM) running grammar.
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.

3 participants