chore: import upstream snapshot with attribution
Lint / lint (push) Has been cancelled
Build Docs / Deploy Docs (push) Has been cancelled
Windows CI / Windows (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:23:58 +08:00
commit 770d92cb1f
694 changed files with 114634 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
from pathlib import Path
from typing import Union
import pytest
import tvm
from mlc_llm.loader import HuggingFaceLoader
from mlc_llm.model import MODEL_PRESETS, MODELS
from mlc_llm.quantization import QUANTIZATION
from mlc_llm.support import logging, tqdm
logging.enable_logging()
@pytest.mark.parametrize(
"param_path",
[
"./dist/models/llama-2-7b-w4-g128-awq.pt",
"./dist/models/Llama-2-7B-AWQ/model.safetensors",
],
)
def test_load_llama(param_path: Union[str, Path]):
path_params = Path(param_path)
model = MODELS["llama"]
quantization = QUANTIZATION["q4f16_awq"]
config = model.config.from_dict(MODEL_PRESETS["llama2_7b"])
loader = HuggingFaceLoader(
path=path_params,
extern_param_map=model.source["awq"](config, quantization),
)
with tqdm.redirect():
for _name, _param in loader.load(tvm.device("cpu")):
...
if __name__ == "__main__":
test_load_llama(param_path="./dist/models/llama-2-7b-w4-g128-awq.pt")
test_load_llama(param_path="./dist/models/Llama-2-7B-AWQ/model.safetensors")
+68
View File
@@ -0,0 +1,68 @@
from pathlib import Path
from typing import Union
import pytest
import tvm
from mlc_llm.loader import HuggingFaceLoader
from mlc_llm.model import MODELS
from mlc_llm.support import logging, tqdm
logging.enable_logging()
@pytest.mark.parametrize(
"base_path",
[
"./dist/models/Llama-2-7b-hf",
"./dist/models/Llama-2-13b-hf",
"./dist/models/Llama-2-70b-hf",
],
)
def test_load_torch_llama(base_path: Union[str, Path]):
base_path = Path(base_path)
path_config = base_path / "config.json"
path_params = base_path / "pytorch_model.bin.index.json"
model = MODELS["llama"]
config = model.config.from_file(path_config)
loader = HuggingFaceLoader(
path=path_params,
extern_param_map=model.source["huggingface-torch"](config, None),
)
with tqdm.redirect():
for _name, _param in loader.load(device=tvm.device("cpu")):
return # To reduce the time of the test
@pytest.mark.parametrize(
"base_path",
[
"./dist/models/Llama-2-7b-hf",
"./dist/models/Llama-2-13b-hf",
"./dist/models/Llama-2-70b-hf",
],
)
def test_load_safetensor_llama(base_path: Union[str, Path]):
base_path = Path(base_path)
path_config = base_path / "config.json"
path_params = base_path / "model.safetensors.index.json"
model = MODELS["llama"]
config = model.config.from_file(path_config)
loader = HuggingFaceLoader(
path=path_params,
extern_param_map=model.source["huggingface-safetensor"](config, None),
)
with tqdm.redirect():
for _name, _param in loader.load(device=tvm.device("cpu")):
return # To reduce the time of the test
if __name__ == "__main__":
test_load_torch_llama(base_path="./dist/models/Llama-2-7b-hf")
test_load_torch_llama(base_path="./dist/models/Llama-2-13b-hf")
test_load_torch_llama(base_path="./dist/models/Llama-2-70b-hf")
test_load_safetensor_llama(base_path="./dist/models/Llama-2-7b-hf")
test_load_safetensor_llama(base_path="./dist/models/Llama-2-13b-hf")
test_load_safetensor_llama(base_path="./dist/models/Llama-2-70b-hf")