Skip to content

Commit 73739bd

Browse files
committed
Update aoti APIs
1 parent 654bb03 commit 73739bd

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

torchchat/cli/builder.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,8 @@ def do_nothing(max_batch_size, max_seq_length):
571571
# attributes will NOT be seen on by AOTI-compiled forward
572572
# function, e.g. calling model.setup_cache will NOT touch
573573
# AOTI compiled and maintained model buffers such as kv_cache.
574-
from torch._inductor.package import load_package
575574

576-
aoti_compiled_model = load_package(
575+
aoti_compiled_model = torch._inductor.aoti_load_package(
577576
str(builder_args.aoti_package_path.absolute())
578577
)
579578

torchchat/export.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
from typing import Optional
99

1010
import torch
11+
import torch._inductor
1112
import torch.nn as nn
1213

1314
from torch.export import Dim
14-
import torch._inductor
1515

1616
from torchchat.cli.builder import (
1717
_initialize_model,
@@ -68,20 +68,24 @@ def export_for_server(
6868

6969
with torch.nn.attention.sdpa_kernel([torch.nn.attention.SDPBackend.MATH]):
7070
metadata = {} # TODO: put more metadata here
71-
options = {"aot_inductor.package": package, "aot_inductor.metadata": metadata}
71+
options = {"aot_inductor.metadata": metadata}
7272
if not package:
7373
options = {"aot_inductor.output_path": output_path}
7474

75-
path = torch._export.aot_compile(
75+
ep = torch.export.export(
7676
model,
7777
example_inputs,
7878
dynamic_shapes=dynamic_shapes,
79-
options=options,
8079
)
8180

8281
if package:
83-
from torch._inductor.package import package_aoti
84-
path = package_aoti(output_path, path)
82+
path = torch._inductor.aoti_compile_and_package(
83+
ep, package_path=output_path, inductor_configs=options
84+
)
85+
else:
86+
path = torch._inductor.aot_compile(
87+
ep.module(), example_inputs, options=options
88+
)
8589

8690
print(f"The generated packaged model can be found at: {path}")
8791
return path

0 commit comments

Comments
 (0)