Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.
Merged
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
22 changes: 13 additions & 9 deletions torchchat/cli/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from torchtune.training import set_default_dtype

from torchchat.model import Model, ModelType
from torchchat.model import Model, ModelArgs, ModelType

from torchchat.model_config.model_config import resolve_model_config
from torchchat.utils.build_utils import (
Expand Down Expand Up @@ -527,18 +527,22 @@ def _initialize_model(
)
builder_args.device = "cpu"

# assert (
# quantize is None or quantize == "{ }"
# ), "quantize not valid for exported PTE model. Specify quantization during export."

with measure_time("Time to load model: {time:.02f} seconds"):
model = _load_model(builder_args)
device_sync(device=builder_args.device)
# Resolve ModelArgs for constructing the PTEModel
# If a manual params_path is provided, use that
if builder_args.params_path:
config: ModelArgs = ModelArgs.from_params(builder_args.params_path)
else:
# TODO: Instead of loading the whole model, refactor to call a
# helper that generate just model.config
with measure_time("Time to load model: {time:.02f} seconds"):
model = _load_model(builder_args)
device_sync(device=builder_args.device)
config = model.config

try:
from torchchat.model import PTEModel

model = PTEModel(model.config, builder_args.pte_path)
model = PTEModel(config, builder_args.pte_path)
except Exception:
raise RuntimeError(f"Failed to load ET compiled {builder_args.pte_path}")
else:
Expand Down
Loading