The recommended answers stay the defaults, and --yes / Enter write the same config as before (tools/test_setup_golden.py, five PCs x five sizes). What a user asks for beyond the recommendation is kept and its risk said: - #406: the RAM rule for IQ3_XXS / IQ3_S (experts + KV + 24 GB) is part of the recommended context (the smaller of it and the GPU's rule), no longer a cap: an explicit --context, a pick in the list or the earlier install's context is kept with a note ("256K with IQ3_S needs ~78 GB of RAM by setup's estimate; this PC has 64. Kept as you chose ..."), and the list marks the sizes past it. The low-RAM mode keeps its KV cache in VRAM, so there the context does not count against RAM. - #364 #384: the low-RAM mode recommends one GPU (the resident variant has no layer split) and asks: 2 = all the chosen GPUs with the experts read through the OS file cache (--mmap-experts, layer_split auto; faster in both reports, RAM can fill up during long prompts). An explicit --gpus (or the earlier install's cards) is kept; --yes keeps one GPU. The GPUs' share counts every card. The one-GPU text no longer sends users to --low-ram off. At start, --gpus on a --resident-experts config (and offer_together's "y", whose default is now n for such a config) switches it to --mmap-experts with a note instead of an engine refusal. - S4: --resident-budget-gib N for UD-Q4_K_XL (default: the RAM less 24 GB, as before); more is kept with a note, and a given N is not lowered for KV streaming. - confirm_risk(msg, explicit, yes): one helper for the stops a user may take on - asked with default n, and with --yes an explicit flag is the consent (--yes alone keeps the stop): UD-Q4_K_XL under 48 GB (--model), the RAM floor (--model), the paging question (--model, besides --low-ram off), a card under 8 GB named with --gpus. - --kv-streaming on|off|auto (auto: the RAM test, as before); on past the RAM test with a note, never with k8v4 or under WSL. The refusals that stay are the impossible ones: rope none past 262144, disk space, engine version, driver < 580, no AVX2, a size outside the family.
85 lines
3.4 KiB
Python
85 lines
3.4 KiB
Python
"""Tests for setup.py's low-RAM messages and the paging question (#250): the one-GPU warning says why and shows the
|
|
RAM math, and an explicit --low-ram off installs with --yes instead of stopping at "Install it anyway?" (default
|
|
n). Mocked input - no GPU, no downloads.
|
|
|
|
python -m unittest tools.test_setup_lowram
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import contextlib
|
|
import io
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest import mock
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT))
|
|
import setup # noqa: E402
|
|
|
|
|
|
def run(fn, *args, stdin=None):
|
|
"""-> (exit code or None, printed text); `stdin` answers input() (None: never asked)."""
|
|
out = io.StringIO()
|
|
asked = []
|
|
|
|
def fake_input(prompt=""):
|
|
asked.append(prompt)
|
|
if stdin is None:
|
|
raise AssertionError(f"asked {prompt!r} with --yes")
|
|
return stdin
|
|
|
|
code = None
|
|
with contextlib.redirect_stdout(out), mock.patch("builtins.input", fake_input):
|
|
try:
|
|
fn(*args)
|
|
except SystemExit as e:
|
|
code = e.code
|
|
return code, out.getvalue(), asked
|
|
|
|
|
|
class OneGpuWhy(unittest.TestCase):
|
|
def test_auto_shows_the_ram_math(self):
|
|
lines = setup.low_ram_one_gpu_why("IQ3_XXS", 46, "auto") # the #250 report: 46 GB, IQ3_XXS
|
|
text = "\n".join(lines)
|
|
arena = setup.MODELS["IQ3_XXS"]["arena_gb"]
|
|
need = arena + setup.LOW_RAM_HEADROOM_GB
|
|
self.assertIn(f"{arena:.0f} + {setup.LOW_RAM_HEADROOM_GB} = {need:.0f} GB", text)
|
|
self.assertIn("this PC has 46 GB", text)
|
|
self.assertIn("layer split", text) # why one GPU is recommended
|
|
self.assertIn("--gpus 0,1", text) # #364 #384: and the way to use them all
|
|
self.assertIn("OS file cache", text)
|
|
self.assertNotIn("--low-ram off", text) # (that pages the experts: not the way)
|
|
|
|
def test_an_explicit_choice_says_so(self):
|
|
text = "\n".join(setup.low_ram_one_gpu_why("Q2_0", 64, "resident"))
|
|
self.assertIn("you chose the low-RAM mode (--low-ram resident)", text)
|
|
|
|
|
|
class PagingQuestion(unittest.TestCase):
|
|
MODEL, RAM = "IQ3_XXS", 46 # 60 GB wanted, 46 here
|
|
|
|
def test_yes_with_low_ram_off_installs(self):
|
|
code, out, asked = run(setup.confirm_paging, self.MODEL, self.RAM, "off", True)
|
|
self.assertIsNone(code, out)
|
|
self.assertEqual(asked, [])
|
|
self.assertIn("installing IQ3_XXS with 46 GB of RAM, as you chose (--low-ram off)", out)
|
|
|
|
def test_yes_with_auto_still_stops(self):
|
|
code, out, asked = run(setup.confirm_paging, self.MODEL, self.RAM, "auto", True)
|
|
self.assertEqual(code, 1)
|
|
self.assertIn("IQ3_XXS needs about 60 GB of RAM; this PC has 46 GB", out)
|
|
self.assertIn("--low-ram off --yes", out) # the way to insist
|
|
|
|
def test_interactive(self):
|
|
for choice, answer, want in (("off", "", None), ("auto", "", 1), ("auto", "y", None), ("off", "n", 1)):
|
|
with self.subTest(choice=choice, answer=answer):
|
|
code, out, asked = run(setup.confirm_paging, self.MODEL, self.RAM, choice, False, stdin=answer)
|
|
self.assertEqual(code, want, out)
|
|
self.assertEqual(len(asked), 1)
|
|
self.assertIn("[y]" if choice == "off" else "[n]", asked[0])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|