new tasks, model pricing, auto quantisation, etc...

This commit is contained in:
Dobromir Popov
2026-07-06 17:11:53 +03:00
parent 7f67e29d76
commit ccb69c41e3
14 changed files with 466 additions and 34 deletions

View File

@@ -1449,3 +1449,67 @@ def test_cli_loads_local_env_before_config_defaults(tmp_path, monkeypatch):
assert config_mod.DEFAULTS["download_dir"] == "/run/media/popov/DATA/llm/safetensor/models"
assert os.environ["HF_TOKEN"] == "hf_test_token"
def test_default_quantization_is_auto(monkeypatch):
import importlib
from meshnet_node import config as config_mod
from meshnet_node.model_backend import validate_quantization
monkeypatch.delenv("MESHNET_DOWNLOAD_DIR", raising=False)
importlib.reload(config_mod)
assert config_mod.DEFAULTS["quantization"] == "auto"
assert validate_quantization("auto") == "auto"
def test_auto_quantization_uses_native_model_dtype_for_unquantized_config():
from meshnet_node.model_backend import _model_load_plan
class AutoConfigStub:
@staticmethod
def from_pretrained(model_id, cache_dir=None):
assert model_id == "repo/model"
assert cache_dir is None
return types.SimpleNamespace(
text_config=types.SimpleNamespace(dtype="torch.bfloat16"),
)
torch_stub = types.SimpleNamespace(bfloat16="bf16", float16="fp16")
quant_config, dtype, uses_quantized_weights = _model_load_plan(
AutoConfigStub,
"repo/model",
"auto",
torch_stub,
)
assert quant_config is None
assert dtype == "bf16"
assert uses_quantized_weights is False
def test_auto_quantization_preserves_native_quantized_config():
from meshnet_node.model_backend import _model_load_plan
class AutoConfigStub:
@staticmethod
def from_pretrained(model_id, cache_dir=None):
return types.SimpleNamespace(
quantization_config={"quant_method": "gptq"},
torch_dtype="float16",
)
torch_stub = types.SimpleNamespace(bfloat16="bf16", float16="fp16")
quant_config, dtype, uses_quantized_weights = _model_load_plan(
AutoConfigStub,
"repo/model",
"auto",
torch_stub,
)
assert quant_config is None
assert dtype == "fp16"
assert uses_quantized_weights is True