-
Notifications
You must be signed in to change notification settings - Fork 20
Enable prefill for running CausalLM using ET runtime #73
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
Conversation
cc: @kimishpatel |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
5f98c87
to
f735b5f
Compare
a344ba9
to
1908051
Compare
Kernel fixed from |
Some of the failures are due to quality degradation from the |
77f6167
to
e5f8de5
Compare
Updated ET nightly |
…missing cache_position support
Rebased |
Dig into the gemma-3 error (link). Upon checking the complained
in the upstream The export works fine to have the |
shapes = {name: val.shape for name, val in locals().items() if hasattr(val, "shape")} | ||
print(f"Exception: {e}.\n{self.model.method_meta('forward')}\narg shapes: {shapes}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this supposed to do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print the method_meta and all input args on error, making it easier to debug the issue. For example, https://github.com/huggingface/optimum-executorch/actions/runs/15889548273/job/44809292056#step:5:424, you can easily tell what went wrong.
Summary
Add support to utilize ExecuTorch runtime to prefill prompt tokens. This PR is enabling prefill via the HF's python API.
Size comparison:
There is no big impact on PTE file size given the upper bound size of 128 in this test.
Perf comparison:
time_to_first_token
is 20x faster. See details in the tests below:1. Generation with prefill enabled
The PTE is exported with dynamic shapes supported at the
seq_len
dim for bothinput_ids
andcache_position
.Time to first generated token
: 0.658000s2. Generation WITHOUT prefill
This is taking a PTE that is generated statically. The prompt tokens are processed sequentially.
Time to first generated token
: 15.547000s3. Generation WITHOUT prefill (backwards compatbility)
It's important to make sure compatibility. That is, the PTE is exported with dynamic shapes can still be loaded and run with the old code, it will just degrade to sequential processing as case 2.
Time to first generated token
: 15.818000s