Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions torchchat/cli/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,8 @@ def do_nothing(max_batch_size, max_seq_length):
# attributes will NOT be seen on by AOTI-compiled forward
# function, e.g. calling model.setup_cache will NOT touch
# AOTI compiled and maintained model buffers such as kv_cache.
from torch._inductor.package import load_package

aoti_compiled_model = load_package(
aoti_compiled_model = torch._inductor.aoti_load_package(
str(builder_args.aoti_package_path.absolute())
)

Expand Down
13 changes: 8 additions & 5 deletions torchchat/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,20 @@ def export_for_server(
if not package:
options = {"aot_inductor.output_path": output_path}

path = torch._export.aot_compile(
ep = torch.export.export(
model,
example_inputs,
dynamic_shapes=dynamic_shapes,
options=options,
)

if package:
from torch._inductor.package import package_aoti

path = package_aoti(output_path, path)
path = torch._inductor.aoti_compile_and_package(
ep, package_path=output_path, inductor_configs=options
)
else:
path = torch._inductor.aot_compile(
ep.module(), example_inputs, options=options
)

print(f"The generated packaged model can be found at: {path}")
return path
Expand Down
Loading