-
Notifications
You must be signed in to change notification settings - Fork 223
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
add et export with gguf with test #245
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
import torch | ||
|
||
from build.builder import _initialize_model, BuilderArgs | ||
from build.builder import _initialize_model, BuilderArgs, _set_gguf_kwargs, _unset_gguf_kwargs | ||
from cli import add_arguments_for_export, arg_init, check_args | ||
from export_aoti import export_model as export_model_aoti | ||
|
||
|
@@ -42,24 +42,48 @@ def main(args): | |
print(f"Using device={builder_args.device}") | ||
set_precision(builder_args.precision) | ||
|
||
|
||
builder_args.dso_path = None | ||
builder_args.pte_path = None | ||
builder_args.setup_caches = True | ||
model = _initialize_model( | ||
builder_args, | ||
quantize, | ||
) | ||
|
||
output_pte_path = args.output_pte_path | ||
output_dso_path = args.output_dso_path | ||
|
||
# TODO: clean this up | ||
# This mess is because ET does not support _weight_int4pack_mm right now | ||
if not builder_args.gguf_path: | ||
model = _initialize_model( | ||
builder_args, | ||
quantize, | ||
) | ||
model_to_pte = model | ||
model_to_dso = model | ||
else: | ||
if output_pte_path: | ||
_set_gguf_kwargs(builder_args, is_et=True, context="export") | ||
model_to_pte = _initialize_model( | ||
builder_args, | ||
quantize, | ||
) | ||
_unset_gguf_kwargs(builder_args) | ||
|
||
if output_dso_path: | ||
_set_gguf_kwargs(builder_args, is_et=False, context="export") | ||
model_to_dso = _initialize_model( | ||
builder_args, | ||
quantize, | ||
) | ||
_unset_gguf_kwargs(builder_args) | ||
|
||
|
||
with torch.no_grad(): | ||
if output_pte_path: | ||
output_pte_path = str(os.path.abspath(output_pte_path)) | ||
print(f">{output_pte_path}<") | ||
if executorch_export_available: | ||
print(f"Exporting model using Executorch to {output_pte_path}") | ||
export_model_et(model, builder_args.device, args.output_pte_path, args) | ||
export_model_et(model_to_pte, builder_args.device, args.output_pte_path, args) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like this at all :( But we're out of runway, so I will approve for now. |
||
else: | ||
print( | ||
"Export with executorch requested but Executorch could not be loaded" | ||
|
@@ -68,7 +92,7 @@ def main(args): | |
if output_dso_path: | ||
output_dso_path = str(os.path.abspath(output_dso_path)) | ||
print(f"Exporting model using AOT Inductor to {output_dso_path}") | ||
export_model_aoti(model, builder_args.device, output_dso_path, args) | ||
export_model_aoti(model_to_dso, builder_args.device, output_dso_path, args) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
|
||
|
||
if __name__ == "__main__": | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is very kludgy and I would prefer to export to int4 and then handle it from there. Basing front end decisions on backend is a very bad practice because we're going to end up in a world of hurt.
Kimish and I had discussed doing a transform from int4 ->a8w4dq. Right now we just get a de-quantized model.
Please plan to land that asap, Kimish?
cc: @kimishpatel