Refactor LLM configuration to remove llamacpp support
- Removed references to llamacpp from configuration files, scripts, and documentation, streamlining the LLM setup process to focus solely on Ollama. - Updated environment variables and paths to eliminate llamacpp-related entries, ensuring clarity in the configuration. - Adjusted CLI commands and help messages to reflect the removal of llamacpp, enhancing user experience and reducing confusion. - Revised documentation to provide clear guidance on using Ollama exclusively, including updates to setup instructions and runtime options.
This commit is contained in:
@@ -5,7 +5,6 @@ class _Cfg:
|
||||
swarmui_local_port = 17801
|
||||
llm_runtime = "ollama"
|
||||
ollama_local_port = 17811
|
||||
llamacpp_local_port = 17812
|
||||
enable_swarmui = True
|
||||
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
from pathlib import Path
|
||||
|
||||
from gpu_rent.llm_runtime import (
|
||||
gguf_filename_from_url,
|
||||
parse_llamacpp_models,
|
||||
write_llamacpp_models_preset,
|
||||
)
|
||||
|
||||
|
||||
def test_gguf_filename_from_url():
|
||||
url = (
|
||||
"https://huggingface.co/org/repo/resolve/main/"
|
||||
"Qwen2.5-3B-Instruct-Q4_K_M.gguf"
|
||||
)
|
||||
assert gguf_filename_from_url(url) == "Qwen2.5-3B-Instruct-Q4_K_M.gguf"
|
||||
|
||||
|
||||
def test_write_and_parse_llamacpp_preset(tmp_path: Path):
|
||||
path = tmp_path / "llamacpp-models.yaml"
|
||||
write_llamacpp_models_preset(path, "light")
|
||||
entries = parse_llamacpp_models(path)
|
||||
assert len(entries) == 1
|
||||
assert entries[0].default is True
|
||||
assert "Qwen2.5-3B" in entries[0].url
|
||||
assert entries[0].url.startswith("https://")
|
||||
|
||||
|
||||
def test_parse_llamacpp_empty(tmp_path: Path):
|
||||
path = tmp_path / "llamacpp-models.yaml"
|
||||
write_llamacpp_models_preset(path, "empty")
|
||||
assert parse_llamacpp_models(path) == []
|
||||
@@ -15,13 +15,12 @@ def test_parse_enable_swarmui_workload(monkeypatch):
|
||||
def test_tunnel_forwards_llm_only(monkeypatch):
|
||||
class Cfg:
|
||||
swarmui_local_port = 17801
|
||||
llm_runtime = "llamacpp"
|
||||
llm_runtime = "ollama"
|
||||
enable_swarmui = False
|
||||
ollama_local_port = 17811
|
||||
llamacpp_local_port = 17812
|
||||
|
||||
monkeypatch.setattr("gpu_rent.tunnel.load_state", lambda: type("S", (), {"notes": {}})())
|
||||
assert tunnel_forwards(Cfg()) == [(17812, 8080)]
|
||||
assert tunnel_forwards(Cfg()) == [(17811, 11434)]
|
||||
|
||||
|
||||
def test_access_links_llm_only(monkeypatch):
|
||||
@@ -29,10 +28,9 @@ def test_access_links_llm_only(monkeypatch):
|
||||
|
||||
class Cfg:
|
||||
swarmui_local_port = 17801
|
||||
llm_runtime = "llamacpp"
|
||||
llm_runtime = "ollama"
|
||||
enable_swarmui = False
|
||||
ollama_local_port = 17811
|
||||
llamacpp_local_port = 17812
|
||||
|
||||
monkeypatch.setattr(
|
||||
"gpu_rent.access_card.load_state",
|
||||
@@ -40,5 +38,5 @@ def test_access_links_llm_only(monkeypatch):
|
||||
)
|
||||
labels = [x.label for x in collect_access_links(Cfg(), tunneled=True)]
|
||||
assert "SwarmUI UI" not in labels
|
||||
assert "llama.cpp" in labels
|
||||
assert "Ollama API" in labels
|
||||
assert mcp_snippet_lines(Cfg())[0].startswith("#")
|
||||
|
||||
@@ -5,10 +5,7 @@ import pytest
|
||||
from gpu_rent.llm_runtime import (
|
||||
decide_runtime,
|
||||
normalize_runtime,
|
||||
parse_llamacpp_models,
|
||||
parse_ollama_models,
|
||||
pick_llamacpp_linux_asset_url,
|
||||
remap_llamacpp_url,
|
||||
write_ollama_models_preset,
|
||||
)
|
||||
|
||||
@@ -16,22 +13,20 @@ from gpu_rent.llm_runtime import (
|
||||
def test_normalize_runtime():
|
||||
assert normalize_runtime(None) == "none"
|
||||
assert normalize_runtime("OLLAMA") == "ollama"
|
||||
assert normalize_runtime("llama-cpp") == "llamacpp"
|
||||
with pytest.raises(ValueError):
|
||||
normalize_runtime("llamacpp")
|
||||
with pytest.raises(ValueError):
|
||||
normalize_runtime("foo")
|
||||
|
||||
|
||||
def test_decide_runtime_flags_win():
|
||||
assert (
|
||||
decide_runtime(flag=None, ollama_flag=True, llamacpp_flag=False, from_config="none")
|
||||
== "ollama"
|
||||
decide_runtime(flag=None, ollama_flag=True, from_config="none") == "ollama"
|
||||
)
|
||||
assert (
|
||||
decide_runtime(flag="llamacpp", ollama_flag=False, llamacpp_flag=False, from_config="ollama")
|
||||
== "llamacpp"
|
||||
decide_runtime(flag="ollama", ollama_flag=False, from_config="none") == "ollama"
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
decide_runtime(flag=None, ollama_flag=True, llamacpp_flag=True, from_config="none")
|
||||
assert decide_runtime(flag=None, ollama_flag=False, from_config="ollama") == "ollama"
|
||||
|
||||
|
||||
def test_parse_ollama_models(tmp_path: Path):
|
||||
@@ -60,66 +55,3 @@ def test_write_preset(tmp_path: Path):
|
||||
write_ollama_models_preset(path, "recommended")
|
||||
entries = parse_ollama_models(path)
|
||||
assert entries[0].name == "huihui_ai/qwen2.5-vl-abliterated:7b"
|
||||
|
||||
|
||||
def test_write_llamacpp_preset_includes_mmproj(tmp_path: Path):
|
||||
from gpu_rent.llm_runtime import write_llamacpp_models_preset
|
||||
|
||||
path = tmp_path / "lc.yaml"
|
||||
write_llamacpp_models_preset(path, "recommended")
|
||||
entries = parse_llamacpp_models(path)
|
||||
assert len(entries) == 1
|
||||
assert "VL" in entries[0].url or "vl" in entries[0].url.lower()
|
||||
assert entries[0].mmproj_url
|
||||
assert "mmproj" in entries[0].mmproj_url
|
||||
|
||||
|
||||
def test_remap_dead_bartowski_abliterate_url(tmp_path: Path):
|
||||
dead = (
|
||||
"https://huggingface.co/bartowski/huihui-ai_Qwen2.5-7B-Instruct-abliterated-GGUF/"
|
||||
"resolve/main/huihui-ai_Qwen2.5-7B-Instruct-abliterated-Q4_K_M.gguf"
|
||||
)
|
||||
fixed = remap_llamacpp_url(dead)
|
||||
assert "RichardErkhov" in fixed
|
||||
assert "Q4_K_M.gguf" in fixed
|
||||
path = tmp_path / "lc.yaml"
|
||||
path.write_text(f"models:\n - url: {dead}\n default: true\n", encoding="utf-8")
|
||||
entries = parse_llamacpp_models(path)
|
||||
assert len(entries) == 1
|
||||
assert entries[0].url == fixed
|
||||
|
||||
|
||||
def test_pick_llamacpp_linux_asset_skips_windows_cuda():
|
||||
assets = [
|
||||
{
|
||||
"name": "cudart-llama-bin-win-cuda-12.4-x64.zip",
|
||||
"browser_download_url": "https://example/cudart-win.zip",
|
||||
},
|
||||
{
|
||||
"name": "llama-b10545-bin-win-cuda-12.4-x64.zip",
|
||||
"browser_download_url": "https://example/win-cuda.zip",
|
||||
},
|
||||
{
|
||||
"name": "llama-b10545-bin-ubuntu-x64.tar.gz",
|
||||
"browser_download_url": "https://example/ubuntu-cpu.tar.gz",
|
||||
},
|
||||
{
|
||||
"name": "llama-b10545-bin-ubuntu-vulkan-x64.tar.gz",
|
||||
"browser_download_url": "https://example/ubuntu-vulkan.tar.gz",
|
||||
},
|
||||
]
|
||||
assert pick_llamacpp_linux_asset_url(assets) == "https://example/ubuntu-vulkan.tar.gz"
|
||||
|
||||
|
||||
def test_pick_llamacpp_linux_asset_prefers_ubuntu_cuda():
|
||||
assets = [
|
||||
{
|
||||
"name": "llama-b1-bin-ubuntu-vulkan-x64.tar.gz",
|
||||
"browser_download_url": "https://example/vulkan.tar.gz",
|
||||
},
|
||||
{
|
||||
"name": "llama-b1-bin-ubuntu-cuda-12.4-x64.tar.gz",
|
||||
"browser_download_url": "https://example/cuda.tar.gz",
|
||||
},
|
||||
]
|
||||
assert pick_llamacpp_linux_asset_url(assets) == "https://example/cuda.tar.gz"
|
||||
|
||||
@@ -53,7 +53,6 @@ def test_extensions_requires_ollama(tmp_path: Path):
|
||||
assert repos[1].requires == "none"
|
||||
assert repo_matches_runtime(repos[0], "ollama")
|
||||
assert not repo_matches_runtime(repos[0], "none")
|
||||
assert not repo_matches_runtime(repos[0], "llamacpp")
|
||||
assert repo_matches_runtime(repos[1], "none")
|
||||
assert repo_matches_runtime(repos[1], "ollama")
|
||||
|
||||
@@ -67,7 +66,6 @@ def test_extensions_requires_any_llm(tmp_path: Path):
|
||||
repo = parse_extensions(path)[0]
|
||||
assert repo.requires == "any-llm"
|
||||
assert repo_matches_runtime(repo, "ollama")
|
||||
assert repo_matches_runtime(repo, "llamacpp")
|
||||
assert not repo_matches_runtime(repo, "none")
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ class _Cfg:
|
||||
notify_ready = True
|
||||
llm_runtime = "none"
|
||||
ollama_local_port = 17811
|
||||
llamacpp_local_port = 17812
|
||||
|
||||
|
||||
def test_ensure_boot_snapshot_skips_existing():
|
||||
|
||||
@@ -1,27 +1,21 @@
|
||||
from types import SimpleNamespace
|
||||
|
||||
from gpu_rent.provision import _LLAMACPP_INSTALL_ENV, _remote_llm_env
|
||||
from gpu_rent.provision import _OLLAMA_INSTALL_ENV, _remote_llm_env
|
||||
|
||||
|
||||
def test_remote_llm_env_forwards_llamacpp_vars(monkeypatch):
|
||||
monkeypatch.setenv("LLAMACPP_TAG", "b10545")
|
||||
monkeypatch.setenv("LLAMACPP_BUILD_CUDA", "1")
|
||||
monkeypatch.setenv("LLAMACPP_NGL", "40")
|
||||
monkeypatch.setenv("LLAMACPP_ASSET_URL", "https://example/a.tar.gz")
|
||||
monkeypatch.delenv("LLAMACPP_SHA256", raising=False)
|
||||
def test_remote_llm_env_forwards_ollama_vars(monkeypatch):
|
||||
monkeypatch.setenv("OLLAMA_VERSION", "0.6.5")
|
||||
monkeypatch.setenv("OLLAMA_SHA256", "abc123")
|
||||
cfg = SimpleNamespace(ssh_user="ubuntu")
|
||||
env = _remote_llm_env(cfg, *_LLAMACPP_INSTALL_ENV)
|
||||
env = _remote_llm_env(cfg, *_OLLAMA_INSTALL_ENV)
|
||||
assert env["SWARM_USER"] == "ubuntu"
|
||||
assert env["LLAMACPP_TAG"] == "b10545"
|
||||
assert env["LLAMACPP_BUILD_CUDA"] == "1"
|
||||
assert env["LLAMACPP_NGL"] == "40"
|
||||
assert env["LLAMACPP_ASSET_URL"] == "https://example/a.tar.gz"
|
||||
assert "LLAMACPP_SHA256" not in env
|
||||
assert env["OLLAMA_VERSION"] == "0.6.5"
|
||||
assert env["OLLAMA_SHA256"] == "abc123"
|
||||
|
||||
|
||||
def test_remote_llm_env_skips_empty(monkeypatch):
|
||||
for key in _LLAMACPP_INSTALL_ENV:
|
||||
for key in _OLLAMA_INSTALL_ENV:
|
||||
monkeypatch.delenv(key, raising=False)
|
||||
cfg = SimpleNamespace(ssh_user="ubuntu")
|
||||
env = _remote_llm_env(cfg, *_LLAMACPP_INSTALL_ENV)
|
||||
env = _remote_llm_env(cfg, *_OLLAMA_INSTALL_ENV)
|
||||
assert env == {"SWARM_USER": "ubuntu"}
|
||||
|
||||
@@ -55,7 +55,7 @@ def test_prompt_server_plan_with_ranked(monkeypatch, tmp_path):
|
||||
def test_upsert_vars(tmp_path):
|
||||
path = tmp_path / "gpu-rent.vars"
|
||||
path.write_text("# c\nLLM_RUNTIME=none\n", encoding="utf-8")
|
||||
upsert_vars(path, {"LLM_RUNTIME": "llamacpp", "DATA_VOLUME_SIZE_GB": "200"})
|
||||
upsert_vars(path, {"LLM_RUNTIME": "ollama", "DATA_VOLUME_SIZE_GB": "200"})
|
||||
data = parse_vars_file(path)
|
||||
assert data["LLM_RUNTIME"] == "llamacpp"
|
||||
assert data["LLM_RUNTIME"] == "ollama"
|
||||
assert data["DATA_VOLUME_SIZE_GB"] == "200"
|
||||
|
||||
@@ -32,7 +32,6 @@ def test_tunnel_forwards_swarm_only(monkeypatch):
|
||||
swarmui_local_port = 17801
|
||||
llm_runtime = "none"
|
||||
ollama_local_port = 17811
|
||||
llamacpp_local_port = 17812
|
||||
|
||||
monkeypatch.setattr("gpu_rent.tunnel.load_state", lambda: type("S", (), {"notes": {}})())
|
||||
assert tunnel_forwards(Cfg()) == [(17801, 7801)]
|
||||
@@ -43,7 +42,6 @@ def test_tunnel_forwards_prefers_cfg_over_stale_notes(monkeypatch):
|
||||
swarmui_local_port = 17801
|
||||
llm_runtime = "none"
|
||||
ollama_local_port = 17811
|
||||
llamacpp_local_port = 17812
|
||||
|
||||
monkeypatch.setattr(
|
||||
"gpu_rent.tunnel.load_state",
|
||||
@@ -65,10 +63,10 @@ def test_resolve_llm_notes_only_when_cfg_none(monkeypatch):
|
||||
assert resolve_llm_runtime(Cfg()) == "ollama"
|
||||
|
||||
class Cfg2:
|
||||
llm_runtime = "llamacpp"
|
||||
llm_runtime = "ollama"
|
||||
|
||||
monkeypatch.setattr(
|
||||
"gpu_rent.access_card.load_state",
|
||||
lambda: type("S", (), {"notes": {"llm_runtime": "ollama"}})(),
|
||||
lambda: type("S", (), {"notes": {"llm_runtime": "none"}})(),
|
||||
)
|
||||
assert resolve_llm_runtime(Cfg2()) == "llamacpp"
|
||||
assert resolve_llm_runtime(Cfg2()) == "ollama"
|
||||
|
||||
@@ -7,19 +7,18 @@ class _Cfg:
|
||||
llm_runtime = "none"
|
||||
swarmui_local_port = 17801
|
||||
ollama_local_port = 17811
|
||||
llamacpp_local_port = 17812
|
||||
|
||||
|
||||
def test_expected_services_swarm_only():
|
||||
assert _expected_services(_Cfg()) == (True, False, False)
|
||||
assert _expected_services(_Cfg()) == (True, False)
|
||||
|
||||
|
||||
def test_expected_services_llm_only():
|
||||
class C:
|
||||
enable_swarmui = False
|
||||
llm_runtime = "llamacpp"
|
||||
llm_runtime = "ollama"
|
||||
|
||||
assert _expected_services(C()) == (False, False, True)
|
||||
assert _expected_services(C()) == (False, True)
|
||||
|
||||
|
||||
def test_verify_stack_local_empty_when_nothing():
|
||||
@@ -28,7 +27,6 @@ def test_verify_stack_local_empty_when_nothing():
|
||||
llm_runtime = "none"
|
||||
swarmui_local_port = 17801
|
||||
ollama_local_port = 17811
|
||||
llamacpp_local_port = 17812
|
||||
|
||||
logs: list[str] = []
|
||||
assert verify_stack_local(C(), logs.append, timeout=0.1) == []
|
||||
@@ -40,7 +38,6 @@ def test_verify_stack_local_fails_closed_port(monkeypatch):
|
||||
llm_runtime = "ollama"
|
||||
swarmui_local_port = 17801
|
||||
ollama_local_port = 17999
|
||||
llamacpp_local_port = 17812
|
||||
|
||||
monkeypatch.setattr(
|
||||
"gpu_rent.ready._tcp_ok", lambda port, host="127.0.0.1", timeout=0.8: False
|
||||
@@ -157,7 +154,7 @@ def test_verify_gpu_env_llm_only_skips_torch_requirement(monkeypatch):
|
||||
|
||||
class C:
|
||||
enable_swarmui = False
|
||||
llm_runtime = "llamacpp"
|
||||
llm_runtime = "ollama"
|
||||
|
||||
payload = {
|
||||
"ok": True,
|
||||
|
||||
Reference in New Issue
Block a user