Skip to content
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
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ follow_imports = "skip"
ignore_errors = false
strict_optional = false
install_types = true
non_interactive = true

[tool.pylint.messages_control]
max-line-length = 100
Expand Down
12 changes: 10 additions & 2 deletions python/mlc_chat/compiler/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CompileArgs: # pylint: disable=too-many-instance-attributes

config: Path
quantization: str
model_type: Model
model: Model
target: Target
opt: OptimizationFlags
build_func: Callable[[IRModule, "CompileArgs"], None]
Expand All @@ -79,7 +79,7 @@ def _echo_args(args: CompileArgs) -> None:
print(f"{bold('Compiling with arguments:')}", file=out)
print(f" {bold('--config'):<25} {args.config}", file=out)
print(f" {bold('--quantization'):<25} {args.quantization}", file=out)
print(f" {bold('--model-type'):<25} {args.model_type.name}", file=out)
print(f" {bold('--model-type'):<25} {args.model.name}", file=out)
print(f" {bold('--target'):<25} {args.target.export()}", file=out)
print(f" {bold('--opt'):<25} {args.opt}", file=out)
print(f" {bold('--output'):<25} {args.output}", file=out)
Expand All @@ -101,6 +101,14 @@ def compile( # pylint: disable=too-many-arguments,redefined-builtin
config, quantization, model_type, target, opt, build_func, prefix_symbols, output
)
_echo_args(args)
model_config = args.model.config.from_file(args.config)
model = args.model.model(model_config)
mod, named_params = model.export_tvm(
spec=model.get_default_spec(), # type: ignore
)
mod.show(black_format=False)
for name, param in named_params:
print(f"{name}: {param.shape} {param.dtype}")


OPT_FLAG_PRESET = {
Expand Down
12 changes: 12 additions & 0 deletions python/mlc_chat/compiler/model/llama_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,26 @@ def get_default_spec(self):
"prefill": {
"inputs": nn.spec.Tensor([batch_size, "seq_len"], "int32"),
"total_seq_len": int,
"$": {
"param_mode": "packed",
"effect_mode": "packed",
},
},
"decode": {
"inputs": nn.spec.Tensor([batch_size, 1], "int32"),
"total_seq_len": int,
"$": {
"param_mode": "packed",
"effect_mode": "packed",
},
},
"softmax_with_temperature": {
"logits": nn.spec.Tensor([1, 1, "vocab_size"], "float32"),
"temperature": nn.spec.Tensor([], "float32"),
"$": {
"param_mode": "none",
"effect_mode": "none",
},
},
}
return nn.spec.ModuleSpec.from_raw(mod_spec, self)