Files

65 lines
1.7 KiB
Python

from __future__ import annotations
import json
def test_simple_defaults_accept_tensor_split(load_nodes_module, monkeypatch, tmp_path):
module = load_nodes_module()
config_path = tmp_path / "simple_defaults.json"
config_path.write_text(
json.dumps(
{
"schema_version": 1,
"n_gpu_layers": -1,
"tensor_split": [1.0, 0.0],
}
),
encoding="utf-8",
)
defaults = module._load_simple_defaults(str(config_path))
assert defaults["tensor_split"] == [1.0, 0.0]
def test_simple_defaults_ignore_invalid_tensor_split(load_nodes_module, monkeypatch, tmp_path):
module = load_nodes_module()
config_path = tmp_path / "simple_defaults.json"
config_path.write_text(
json.dumps(
{
"schema_version": 1,
"tensor_split": [0.0, 0.0],
}
),
encoding="utf-8",
)
defaults = module._load_simple_defaults(str(config_path))
assert defaults["tensor_split"] is None
def test_model_manager_passes_tensor_split_to_llama(load_nodes_module, monkeypatch):
module = load_nodes_module()
calls = []
class DummyLlama:
def __init__(self, **kwargs):
calls.append(kwargs)
monkeypatch.setattr(module, "LLAMA_CPP_AVAILABLE", True)
monkeypatch.setattr(module, "Llama", DummyLlama)
manager = module.GGUFModelManager()
manager.load_model(
model_path="C:/models/test.gguf",
mmproj_path=module._MMPROJ_NOT_REQUIRED,
n_ctx=1024,
n_gpu_layers=-1,
tensor_split=[1.0, 0.0],
)
assert calls[0]["tensor_split"] == [1.0, 0.0]