Enhance GPU probing and performance tuning in provisioning

- Introduced GPU probing functionality to gather and store GPU specifications in `/mnt/swarm_data/.gpu-rent-gpu.json`, aiding in performance tuning.
- Updated `install_ollama.sh` and `install_llamacpp.sh` to utilize GPU information for configuring optimal runtime parameters.
- Enhanced `provision.py` to include GPU probing and performance tuning logic, ensuring better resource allocation for LLM operations.
- Improved documentation in `decisions.md`, `llm.md`, and `swarmui.md` to reflect changes in GPU handling and performance tuning processes.
- Added new tests to validate the GPU probing and model resolution logic, ensuring robustness in handling various GPU configurations.
This commit is contained in:
Leonid Pershin
2026-08-21 06:10:24 +03:00
parent 603165a4ba
commit 2ccb03f7d2
16 changed files with 1270 additions and 138 deletions
+50
View File
@@ -35,6 +35,50 @@ def _pkg_text(name: str) -> str:
return files("gpu_rent.remote").joinpath(name).read_text(encoding="utf-8")
def probe_gpu(cfg: Config, host: str, log: Log) -> dict:
"""Write /mnt/swarm_data/.gpu-rent-gpu.json; return parsed dict."""
out = run_python(
cfg,
host,
_pkg_text("gpu_probe.py"),
remote_path="/tmp/gpu-rent-gpu_probe.py",
timeout=60,
log=log,
)
# Last JSON line from script stdout
data: dict = {}
for line in reversed(out.splitlines()):
line = line.strip()
if line.startswith("{"):
try:
data = json.loads(line)
break
except json.JSONDecodeError:
continue
if data.get("ok"):
log(
f"GPU: {data.get('name')} "
f"{data.get('vram_mib')} MiB cap={data.get('compute_cap')} "
f"tier={data.get('tier')}"
)
else:
log(f"GPU probe: {data.get('error') or 'нет данных'}")
return data
def tune_swarm_perf(cfg: Config, host: str, log: Log) -> bool:
"""Install sage/triton into Comfy venv + ExtraArgs. Returns True if SwarmUI restart needed."""
out = run_python(
cfg,
host,
_pkg_text("tune_swarm_perf.py"),
remote_path="/tmp/gpu-rent-tune_swarm_perf.py",
timeout=900,
log=log,
)
return "RESTART_SWARMUI=1" in out
def seed_extensions(cfg: Config, host: str, log: Log, *, update: bool = True) -> bool:
from gpu_rent.llm_runtime import normalize_runtime
@@ -372,6 +416,12 @@ def provision_vm(
push_tree(cfg, host, cfg.local_workflows_dir, f"{DATA}/CustomWorkflows", log, models=False)
if cfg.pull_output:
pull_tree(cfg, host, f"{DATA}/Output", cfg.local_output_dir, log)
try:
probe_gpu(cfg, host, log)
except Exception as exc:
log(f"GPU probe: {exc}")
ensure_swarmui_running(cfg, host, log, restart=restart)
from gpu_rent.state import load_state, save_state