[PoC ONLY] Qualcomm AI Engine Direct - HF Exporter Mininal Script - #22400
[PoC ONLY] Qualcomm AI Engine Direct - HF Exporter Mininal Script#22400winskuo-quic wants to merge 2 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22400
Note: Links to docs will display an error until the docs builds have been completed. ❌ 4 New FailuresAs of commit fe92052 with merge base d750618 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
|
|
||
| if not args.pre_gen_pte: | ||
| # The whole export is this one call; everything after it is this script's business. | ||
| et_program_manager = ExecutorchExporter().export( |
There was a problem hiding this comment.
Hi @psiddh,
This is a PoC to demo how to run HuggingFace Exporter API with ExecuTorch. Please take a look at the summary section of this PR to see how to reproduce.
It requires applying another patch to HuggingFace repo.
Overall, we followed HuggingFace convention and design, using only this single API call to lower a model to backend.
This PR looks a little messy because I applied this on top of my HF model optimization PR: #22170, so please ignore the 2nd commit and just focus on the top commit of this PR.
Thanks
Summary
This PR serves as a PoC demo how to use hf-transformer exporter to export a HF LLM model.
Since this is just a PoC, a lot of stuff in the patch and this PR is hardcoded. e.g., the example script is set to Llama3.2 1B. A lot of implementations for hf-transformer exporter patch is hardcoded and not the best design, it is just to prove we can get the same performance using hf-transformer exporter flow.
Steps
Notes: All these will be done in a single conda environment, you don't need to create multiple environments.
Step 1
Checkout to this branch. Enter your conda environment, do all the basic setups as usual, e.g.,
PYTHONPATH=$EXECUTORCH_ROOT/..,git submodule sync,git submodule update --init,python install_executorch.py, etc.Step 2
Next, create an empty folder and inside do the following.
git clone the hugging face repo to your local machine: https://github.com/huggingface/transformers
Step 2
Checkout to this PR: huggingface/transformers#47747
Step 3
Apply the PoC patch to HF repo, under
./hf-transformers/transformersStep 4
After you apply the patch, do:
pip uninstall -y transformers# Probably optional buy highly recommendedpip install -e . --no-deps# --no-deps in case it overrides some executorch dependencies.Step 5
Execute
python examples/qualcomm/oss_scripts/hf_exporter.py --prompt "Simply put, the theory of relativity states that" --soc_model SM8750 --device $DEVICE --build_folder build-android/ --max_seq_len 1024Performance Check
This is a quick to ensure that the model lowered through HF-Exporter API is similar as ExecuTorch directly lowering HF model, we have checked the final performance and compared the number of Executorch nodes. After checking both, the node number and performance does match.
Original Flow
HF-Exporter Flow
However, this is only for quick validation and does not guarantee the final QNN graph is identical.
Test plan
NA