Skip to content

Use Android llm benchmark runner #5094

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 14 commits into from
Sep 6, 2024
Merged

Conversation

huydhn
Copy link
Contributor

@huydhn huydhn commented Sep 4, 2024

The current solution is to:

  1. Run the benchmark activity
  2. Poll the result for up to 10m as 1 is async as @kirklandsign points out. This looks like an arbitrary threshold for me, but it works so I think we can keep it for now until a better solution comes along
  3. Store the JSON result as a local artifact so that we can download it later. I will have a follow-up PR to propose its format. I need to cat the result here instead of pulling the file from device as the latter ends up with permission error

Testing

https://github.com/pytorch/executorch/actions/runs/10731052861/job/29761525913

Download the artifacts from AWS and confirm that the benchmark_results.json file are there together with the instrument.log

{"generateEnd":1725590151329,"generateStart":1725590150258,"loadEnd":1725590150258,"loadStart":1725590149993,"tokens":"tokens/second: 115.530304"}

Copy link

pytorch-bot bot commented Sep 4, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 0f45f39 with merge base ee752f0 (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 Sep 4, 2024
- |
adb -s $DEVICEFARM_DEVICE_UDID shell am start -n com.example.executorchllamademo/.Benchmarking \
--es "model_dir" "/data/local/tmp/llama" \
--es "tokenizer_path" "/data/local/tmp/llama/tokenizer.bin"
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you! Exactly what i want to do :D

Need to find a way to wait for the file to result file to appear. shell am start is async

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, got it. TIL. I'm still working on this to make the command works, so stay tuned :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this kind of stuff work? 🤔
adb shell while [ ! -f /data/local/tmp/result.txt ]; do sleep 1; done

Copy link
Contributor Author

@huydhn huydhn Sep 6, 2024

Choose a reason for hiding this comment

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

adb shell doesn't like the way I write bash script, so I need to look for a work around by cat-ing the results. It works nonetheless, so I guess we are good :)

@kirklandsign
Copy link
Contributor

Please format 🥲 https://github.com/google/google-java-format/releases download the binary and run... sorry no built in tool right now

# TODO (huydhn): Polling like this looks brittle, figure out if there is a better way to wait
# for the benchmark results
adb -s $DEVICEFARM_DEVICE_UDID shell run-as com.example.executorchllamademo \
while ! test -f files/benchmark_results.json; do echo "Waiting for benchmark results..."; sleep 30; done
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have a maximum timeout? Or just rely on GH to timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, we can have a maximum timeout, as GH action timeout is 1 hour which is a bit too long.

- adb -s $DEVICEFARM_DEVICE_UDID shell "ls -la /data/local/tmp/llama/"
- echo "Wait for the results"
- |
# TODO (huydhn): Polling like this looks brittle, figure out if there is a better way to wait
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious what could be brittle with this approach?

Copy link
Contributor Author

@huydhn huydhn Sep 6, 2024

Choose a reason for hiding this comment

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

I just feel that there might be a better approach out there, so put a TODO here to remind myself for now. I don't like pooling for results in general, feel like a waste of requests :)

@huydhn huydhn marked this pull request as ready for review September 6, 2024 01:52
@huydhn huydhn requested a review from kirklandsign September 6, 2024 01:52
@facebook-github-bot
Copy link
Contributor

@huydhn 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 40720f0 into main Sep 6, 2024
49 checks passed
@facebook-github-bot facebook-github-bot deleted the use-llm-benchmark-runner branch September 6, 2024 04:12
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.

3 participants