Skip to content

Android App with MediaTek Mode #6304

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

Merged
merged 23 commits into from
Oct 29, 2024
Merged

Android App with MediaTek Mode #6304

merged 23 commits into from
Oct 29, 2024

Conversation

cmodi-meta
Copy link
Contributor

@cmodi-meta cmodi-meta commented Oct 16, 2024

Purpose: Modify the existing demo Android App to support MediaTek e2e flow.

Pre-requisite: This diff should sit on top of #6208 changes. We plan to rebase to this once #6208 changes are complete in total.

Planned Changes:

  • Backend selector
  • UI Layout
  • Enable to use MTK runner

How to Run:

  1. Compile .aar using MTK Android Llama Runner #6208 . This places .aar in executorch/examples/demo-apps/android/LlamaDemo. Make sure to modify the tokenizer, embedding file and model file path in llama_runner_values.h before doing so.
  2. Build+launch app using Android Studio for example. (or alternative)
  3. In the Setttings widget in the app, select MTK backend and then click Load Model (ensure Llama 3 by default)
  4. After model loads, type "once upon a time". Press enter.
  5. Generated output will appear.

Copy link

pytorch-bot bot commented Oct 16, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/6304

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 85f3304 with merge base 47bca20 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 16, 2024
@cmodi-meta cmodi-meta marked this pull request as draft October 16, 2024 20:40
@cmodi-meta
Copy link
Contributor Author

I've confirmed that the output works (after a bit of hacky change to the if() condition in the checkForUpdateAndReloadModel() method). This was required because I initially thought that modelPath and tokenizerPath wouldn't need to be selected but this is not the case. Having paths selected is part of the trigger to load the model.

In order to prevent a one-off, I'll need to make changes to how modelPath and tokenizerPath is selected. Maybe select 1 .pte modelPath or have a json file that contains the paths.

@cmodi-meta
Copy link
Contributor Author

I've confirmed that the output works (after a bit of hacky change to the if() condition in the checkForUpdateAndReloadModel() method). This was required because I initially thought that modelPath and tokenizerPath wouldn't need to be selected but this is not the case. Having paths selected is part of the trigger to load the model.

In order to prevent a one-off, I'll need to make changes to how modelPath and tokenizerPath is selected. Maybe select 1 .pte modelPath or have a json file that contains the paths.

I've added a temporary placeholder modelPath and tokenizerPath for the MTK backend to support model loading.

@cmodi-meta
Copy link
Contributor Author

Open for review but TODO (once @kirklandsign makes jni changes) is to modify the LlamaModule initialization based on JNI change for how to select MediaTek backend.

@facebook-github-bot
Copy link
Contributor

@cmodi-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@cccclai cccclai left a comment

Choose a reason for hiding this comment

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

It looks to me that the mtk_llama_runner is added by you, and the rest of the changes are mostly related to android, and I'll lean on @kirklandsign to review them. I'll approve and @neuropilot-captain please let us know if you have any concern.

@facebook-github-bot
Copy link
Contributor

@cmodi-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@cccclai
Copy link
Contributor

cccclai commented Oct 22, 2024

@kirklandsign mentioned the code was mostly borrowed from the runner provided by MediaTek, meaning it's pretty much a fork. The risk is that once the llama runner from mediatek change, this new runner will fail. Let's describe it somewhere in the doc or code

@facebook-github-bot
Copy link
Contributor

@cmodi-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@cmodi-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot merged commit 538575f into main Oct 29, 2024
40 checks passed
@facebook-github-bot facebook-github-bot deleted the mtk-android branch October 29, 2024 22:51
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 Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants