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

Prepare the script to run tests on Android emulator #4387

Closed
wants to merge 28 commits into from

Conversation

huydhn
Copy link
Contributor

@huydhn huydhn commented Jul 24, 2024

Unlike other Linux job where we can use Docker images, Android emulator needs to be run directly on our Linux runner as I don't know if Docker supports KVM which is needed to emulate the devices.

Copy link

pytorch-bot bot commented Jul 24, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 007633e with merge base 11b2fcb (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 Jul 24, 2024
@huydhn huydhn changed the title Run a mock Android emulator Prepare the script to run tests on Android emulators Jul 24, 2024
@huydhn huydhn requested review from kirklandsign and guangy10 July 24, 2024 09:21
@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.

@huydhn huydhn marked this pull request as ready for review July 24, 2024 09:35
@huydhn huydhn changed the title Prepare the script to run tests on Android emulators Prepare the script to run tests on Android emulator Jul 24, 2024
@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.

# Reuse the script that install Android on ET Docker image
sudo -E bash .ci/docker/common/install_android.sh

# NB: It takes about 10m to cold boot the emulator here
Copy link
Contributor

Choose a reason for hiding this comment

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

This is huge

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the emulator configurable? Like the RAM allocated to it. I know typically we would only use it to validate storiesM, but if it's configurable, it can be potentially used on a non-critical path to validate large GenAI model first before actual benchmarking on device.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it has something to do with our Linux runner, it should be faster when hardware accelerator is support according to https://github.com/ReactiveCircus/android-emulator-runner. Let me try to use GitHub runner and compare the perf.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/ReactiveCircus/android-emulator-runner?tab=readme-ov-file#configurations

ram-size maybe 12GB?

Also emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
might be helpful

Copy link
Contributor Author

@huydhn huydhn Jul 24, 2024

Choose a reason for hiding this comment

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

Yeah, it's worth to try out these options, the doc also mentions some caching setup that could make it faster. Quouting https://github.com/ReactiveCircus/android-emulator-runner

We can significantly reduce emulator startup time by setting up AVD snapshot caching:

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! Current cold startup time is slower than on device testing

@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
Copy link
Contributor

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

@huydhn
Copy link
Contributor Author

huydhn commented Jul 24, 2024

To document my findings so far:

  • Both AWS and GitHub runners don't support KVM because they are already using virtualization. So, the emulator is slow on Linux, at least on x86_64.
  • There is mentions of running the emulator on AWS metal hosts, which can use KVM.
  • The emulator for arm needs to be done on an arm runner (with Amazon Linux 2023). We can try them out later.
  • There is hints that running the emulator on Mac runner is faster here because it runs directly on the runner.

As nothing has been run on the emulator yet, we can follow up on this later to see how bad the perf is. A reference point is PT Android test https://github.com/pytorch/pytorch/actions/runs/10083807511/job/27881235211 which takes only 20+ minutes to finish, which is fine. It's not as sophisticated nor comprehensive as ET though.

@facebook-github-bot
Copy link
Contributor

@huydhn merged this pull request in 85d4d12.

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. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants