Skip to content

Commit 6c01d2b

Browse files
committed
Add option to export phi-3-mini model via buck2
Pull Request resolved: #4189 as title ghstack-source-id: 233306024 @exported-using-ghexport Differential Revision: [D59500806](https://our.internmc.facebook.com/intern/diff/D59500806/)
1 parent 8aad7d3 commit 6c01d2b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

examples/models/phi-3-mini/export_model.py renamed to examples/models/phi-3-mini/export_phi-3-mini.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
get_symmetric_quantization_config,
2020
XNNPACKQuantizer,
2121
)
22-
from torch.export import export
2322

24-
from transformers import Phi3ForCausalLM
23+
from transformers import ( # @manual=fbsource//third-party/pypi/transformers:transformers
24+
Phi3ForCausalLM,
25+
)
2526

2627

2728
def main() -> None:
@@ -48,8 +49,14 @@ def main() -> None:
4849
model(*example_inputs)
4950
model = convert_pt2e(model, fold_quantize=False)
5051
DuplicateDynamicQuantChainPass()(model)
51-
model = export(
52-
model, example_inputs, dynamic_shapes=dynamic_shape, strict=False
52+
# TODO(lunwenh): update it to use export once
53+
# https://github.com/pytorch/pytorch/issues/128394 is resolved.
54+
model = torch.export._trace._export(
55+
model,
56+
example_inputs,
57+
dynamic_shapes=dynamic_shape,
58+
strict=False,
59+
pre_dispatch=False,
5360
)
5461

5562
edge_config = get_xnnpack_edge_compile_config()

0 commit comments

Comments
 (0)