Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
setup: Unsloth's UD-IQ4_XS as an experimental choice (#621)
Niko12215b735eccb259
diff --git a/docs/MODELS.md b/docs/MODELS.mdindex f6a5284b6..b2e0d00ed 100644--- a/docs/MODELS.md+++ b/docs/MODELS.md@@ -129,6 +129,15 @@ NVIDIA GPU (no images yet). Details and measurements: [UD-Q4_K_XL](UNSLOTH_Q4.mdSTART-HERE.bat --setup --family unsloth --model UD-Q4_K_XL```+**Unsloth's UD-IQ4_XS** (experimental, 0.1.39, #621) is the smaller choice of the same family: a 94 GB download with+59.5 GB of experts (IQ3_S and IQ4_NL), between IQ3_S and UD-Q4_K_XL. Setup runs it the same way (a RAM budget of your+RAM minus 24 GB, the rest from the SSD), so on a 64 GB PC far fewer experts come from the SSD than with UD-Q4_K_XL, and+on 96 GB all of them stay in RAM. Not measured on NVIDIA yet: [details](UNSLOTH_Q4.md#ud-iq4_xs-experimental-setup-from-0139-621).++```+START-HERE.bat --setup --family unsloth --model UD-IQ4_XS+```+### OrcaRouter Uncensored IQ3_XXSFor **OrcaRouter's Flash-Next Uncensored IQ3_XXS**, see the [manual compatibility setup](ORCA.md). It needs andiff --git a/docs/UNSLOTH_Q4.md b/docs/UNSLOTH_Q4.mdindex 12d4d1997..6bffe67f8 100644--- a/docs/UNSLOTH_Q4.md+++ b/docs/UNSLOTH_Q4.md@@ -221,10 +221,34 @@ engine with `--short-read` covering the positions to compare; llama.cpp's side w| `STRATA_PARTIAL_PIN=1` | Registers the hottest part of the RAM budget (up to `STRATA_PARTIAL_PIN_GIB`, default 24) with the GPU driver, so the GPU computes a share of the misses over PCIe (`--pcie-frac`). Measured no faster on this PC, and it changes the numerics of those experts (GPU kernels instead of the CPU's), so off. || `STRATA_FETCH_THREADS=N` | Threads that read the experts from the GGUF while it answers (default 8; 16 was no faster). The prompt path has its own: `STRATA_STAGER_THREADS` (default 32 here) and `STRATA_STAGER_RING` (128). |+## UD-IQ4_XS (experimental, setup from 0.1.39, #621)++Unsloth's `UD-IQ4_XS` at the same revision is in setup too: `START-HERE.bat --setup --family unsloth --model+UD-IQ4_XS` (engine 0.1.38 or newer). It sits between IQ3_S and UD-Q4_K_XL: its routed experts are IQ3_S gate/up (IQ4_XS+in one layer) with IQ4_NL downs (Q8_0 in five layers), 59.5 GB of them; the dense side (Q8_0 projections, the IQ4_NL+PLE table, a Q6_K head) is UD-Q4_K_XL's. Three shards, 93.7 GB:++| File | Bytes | SHA-256 |+| --- | ---: | --- |+| `Qwen3.8-Flash-Next-UD-IQ4_XS-00001-of-00003.gguf` | 10,946,624 | `5ce89370720f8bf90890f439361282104c1aa1482d4013bb9a50923e758e71a4` |+| `Qwen3.8-Flash-Next-UD-IQ4_XS-00002-of-00003.gguf` | 49,835,229,856 | `577a38a2392b40ca2193cea502e1d92f60b8cd370675d308e0ec21885d9daaa7` |+| `Qwen3.8-Flash-Next-UD-IQ4_XS-00003-of-00003.gguf` | 43,836,407,744 | `d4634e6d84f0ebb0940be15c90d3790bf6464e3dea3a1cddc567dc0e83ad8833` |++Setup treats it like UD-Q4_K_XL (the list above): the same RAM budget (your RAM less 24 GB; at most all 55 GiB of its+experts, so a 96 GB PC holds all of them), the pack with `--compat-bf16`, no `experts.bin`, one GPU by default, no+images. It does not ask on AMD: its experts' formats have prompt kernels there too.++What is known so far: it packs and runs on a Strix Halo (AMD gfx1151, 128 GB unified memory), where prompts read at+~820 tokens/s at 8K and 64K and the answers passed the retrieval checks at 8K and 64K. It has **not** been measured on+NVIDIA yet; please report what you see. One fidelity note that applies to every `--compat-bf16` pack (UD-Q4_K_XL too):+the pack rounds the file's Q8_0 hyper-connection projections to BF16, and on the Strix Halo that rounding put+perplexity 6-9% above llama.cpp's on the same file (teacher-forced, short context). Reading the Q8_0 values instead+closes most of that gap; it is measured on AMD only and not in this release.+## Scope and validation-- Only UD-Q4_K_XL at revision `38bb39e` is targeted. Other Unsloth quantizations use formats this engine may not- have kernels for; the engine checks every layer's formats at start and refuses an unsupported one by name.+- UD-Q4_K_XL and UD-IQ4_XS at revision `38bb39e` are targeted. Other Unsloth quantizations use formats this engine may+ not have kernels for; the engine checks every layer's formats at start and refuses an unsupported one by name.- Tests: the packer's synthetic 4-shard and conversion tests (`.venv/bin/python -m unittest discover -s tools -ptest_iq_pack.py`); CTests `gguf_split_test`, `expert_layout_test`, `native_expert_parity_*` (the three real expertformat pairs against ggml-cpu, the Q5_1 min term, Q8_0 rows), `prefill_mmq_kquant_test` (with `-DSTRATA_MMQ_KQUANTS=ON`: thediff --git a/setup.py b/setup.pyindex cb14ac01a..c4c9ce648 100644--- a/setup.py+++ b/setup.py@@ -28,8 +28,8 @@ answers, no questions), --setup (install another model / change settings instead--host 0.0.0.0 --api-key KEY (reach it from other devices on your network), --experimental-speed-projection on|off(EXPERIMENTAL, off by default),--models-dir DIR, --gguf-dir DIR (use GGUF files you already have), --build (compile instead of the ready-made-engine), --check (only check this PC), --resident-budget-gib N (UD-Q4_K_XL's experts in RAM), --kv-streaming-on|off|auto.+engine), --check (only check this PC), --resident-budget-gib N (UD-Q4_K_XL's or UD-IQ4_XS's experts in RAM),+--kv-streaming on|off|auto.Setup recommends, it never forces: the recommended answers are the defaults (--yes, or Enter), and a bigger choicethan it recommends - a longer context, more GPUs, a bigger RAM budget, a size it thinks will not fit - is kept, with@@ -127,7 +127,14 @@ MODELS = {# keeps a RAM budget of them (--resident-budget-gib, chosen below) and reads the rest from the GGUF on the SSD"UD-Q4_K_XL": {"about": "4-bit (Unsloth Dynamic), EXPERIMENTAL: the best quality, but most experts come from the ""SSD on a 64 GB PC (7-8.5 tokens/s measured)", "download_gb": 111.3, "ram_gb": 48,- "arena_gb": 77.0, "families": ("unsloth",), "budget": True},+ "arena_gb": 77.0, "families": ("unsloth",), "budget": True, "nvidia_only": True},+ # #621 EXPERIMENTAL: Unsloth's UD-IQ4_XS - IQ3_S gate/up experts with IQ4_NL (43 layers) or Q8_0 (5) downs, the+ # dense side as UD-Q4_K_XL's; three shards. Packed and run on a Strix Halo (AMD); not measured on NVIDIA yet. Its+ # 59.5 GB of experts: a RAM budget of them, like UD-Q4_K_XL, but far fewer read from the SSD on a 64 GB PC+ "UD-IQ4_XS": {"about": "~4-bit i-quant (Unsloth Dynamic), EXPERIMENTAL: between IQ3_S and UD-Q4_K_XL; part of "+ "its experts come from the SSD on a 64 GB PC (not measured on NVIDIA yet)",+ "download_gb": 93.7, "ram_gb": 48, "arena_gb": 59.5, "families": ("unsloth",), "budget": True,+ "shards": 3, "file": "Qwen3.8-Flash-Next-{q}-0000{i}-of-00003.gguf", "engine": (0, 1, 38)},}# The experimental Unsloth file's four shards at the pinned revision: name -> (bytes, sha256), checked after the# download (setup trusts no other model file by name and size alone either: check_shards reads their directories).@@ -141,6 +148,15 @@ UNSLOTH_SHARDS = {"Qwen3.8-Flash-Next-UD-Q4_K_XL-00004-of-00004.gguf":(12087983520, "753bda48b98ba4f1636134a90a967de1b2d3908a236c026e464777342e53510a"),}+# #621: UD-IQ4_XS's three shards at the same revision (sizes and SHA-256: the Hub's LFS pointers)+UNSLOTH_IQ4_XS_SHARDS = {+ "Qwen3.8-Flash-Next-UD-IQ4_XS-00001-of-00003.gguf":+ (10946624, "5ce89370720f8bf90890f439361282104c1aa1482d4013bb9a50923e758e71a4"),+ "Qwen3.8-Flash-Next-UD-IQ4_XS-00002-of-00003.gguf":+ (49835229856, "577a38a2392b40ca2193cea502e1d92f60b8cd370675d308e0ec21885d9daaa7"),+ "Qwen3.8-Flash-Next-UD-IQ4_XS-00003-of-00003.gguf":+ (43836407744, "d4634e6d84f0ebb0940be15c90d3790bf6464e3dea3a1cddc567dc0e83ad8833"),+}UNSLOTH_ENGINE = (0, 1, 32) # the first engine setup configures for UD-Q4_K_XL (0.1.31 ran it by hand)UNSLOTH_RAM_LEFT_GB = 24 # RAM beside the budget: the OS, the engine, and the file cache the rest is read through# Contexts past 262144 (the model's trained length) extend it by rope scaling: for the context it will@@ -173,14 +189,17 @@ FAMILIES = {"mmproj_hf": hf("ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-Coder-GGUF"),"mmproj": "mmproj-Qwen3.8-Flash-Next-BF16.gguf", "name": "qwen3.8-flash-next-coder","profile": "expert-profile-coder.bin"},- # EXPERIMENTAL: Unsloth's UD-Q4_K_XL of the original model (docs/UNSLOTH_Q4.md): four shards, no images yet- "unsloth": {"title": "Qwen3.8-Flash-Next (Unsloth)", "by": "Unsloth's 4-bit quantization (EXPERIMENTAL)",- "about": "4-bit, 111 GB download, most experts read from the SSD: slow (7-8.5 tokens/s on a 64 GB PC)",+ # EXPERIMENTAL: Unsloth's UD-Q4_K_XL (four shards) and UD-IQ4_XS (three, #621) of the original model+ # (docs/UNSLOTH_Q4.md); no images yet+ "unsloth": {"title": "Qwen3.8-Flash-Next (Unsloth)", "by": "Unsloth's 4-bit quantizations (EXPERIMENTAL)",+ "about": "UD-Q4_K_XL (111 GB download) or UD-IQ4_XS (94 GB); part of the experts read from the SSD: "+ "slower (UD-Q4_K_XL: 7-8.5 tokens/s on a 64 GB PC)","hf": hf("unsloth/Qwen3.8-Flash-Next-GGUF") + "{q}/","file": "Qwen3.8-Flash-Next-{q}-0000{i}-of-00004.gguf", "shards": 4, "tag": "unsloth-","mmproj_hf": hf("ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF"),"mmproj": "mmproj-Qwen3.8-Flash-Next-BF16.gguf", "name": "qwen3.8-flash-next-unsloth",- "experimental": True, "vision": False, "pack_args": ["--compat-bf16"], "sha256": UNSLOTH_SHARDS},+ "experimental": True, "vision": False, "pack_args": ["--compat-bf16"],+ "sha256": {**UNSLOTH_SHARDS, **UNSLOTH_IQ4_XS_SHARDS}},}MMPROJ = "mmproj-Qwen3.8-Flash-Next-BF16.gguf"# EXPERIMENTAL, off by default (setup asks): a control vector shipped with the repository, see its README@@ -608,6 +627,23 @@ def split_mmap(cfg: dict) -> bool:return True+def model_file(fam: dict, model: str, i: int) -> str:+ """Shard i's file name: the family's pattern, or the model's own (#621: UD-IQ4_XS has three shards, not four)."""+ return MODELS.get(model, {}).get("file", fam["file"]).format(q=model, i=i)+++def model_shards(fam: dict, model: str) -> int:+ return MODELS.get(model, {}).get("shards", fam.get("shards", 2))+++def budget_model(cfg: dict) -> str:+ """The Unsloth model a config with a RAM budget runs, from its --native shard's name (UD-Q4_K_XL by default)."""+ a = cfg.get("args", [])+ native = Path(a[a.index("--native") + 1]).name.upper() if "--native" in a and a.index("--native") + 1 < len(a) \+ else ""+ return next((m for m, d in MODELS.items() if d.get("budget") and f"-{m}-" in native), "UD-Q4_K_XL")++def unsloth_split_need_gb(model="UD-Q4_K_XL") -> float:"""#498: the RAM UD-Q4_K_XL needs on several GPUs, where it has no RAM budget (the engine refuses--resident-budget-gib with a layer split): its GGUF files and UNSLOTH_RAM_LEFT_GB more (~135 GB). Measured safe@@ -623,14 +659,15 @@ def split_budget(cfg: dict) -> bool:a = cfg.get("args", [])if "--resident-budget-gib" not in a:return False- need, ram = unsloth_split_need_gb(), ram_gb()+ model = budget_model(cfg)+ need, ram = unsloth_split_need_gb(model), ram_gb()if ram < need:- fail(f"UD-Q4_K_XL cannot share its RAM budget across GPUs (the engine has no layer split with it), and without "+ fail(f"{model} cannot share its RAM budget across GPUs (the engine has no layer split with it), and without "f"the budget it needs ~{need:.0f} GB of RAM (its GGUF files and {UNSLOTH_RAM_LEFT_GB} GB more); this PC "f"has {ram:.0f} GB", "start it on one GPU: START-HERE.bat --gpu N (Linux: ./setup.sh --gpu N)")i = a.index("--resident-budget-gib")del a[i:i + 2]- ok("UD-Q4_K_XL on several GPUs: no RAM budget (the engine has none with a layer split) - all its experts are "+ ok(f"{model} on several GPUs: no RAM budget (the engine has none with a layer split) - all its experts are ""loaded into RAM from the model files at start, and the files pass through the OS file cache (#498)")return True@@ -646,7 +683,7 @@ def offer_together(cfg_path: Path, cfg: dict, yes: bool) -> dict:return cfg# #498: UD-Q4_K_XL's RAM budget has no layer split; without it the RAM must hold the GGUFs and 24 GB morebudget = "--resident-budget-gib" in cfg.get("args", [])- if budget and ram_gb() < unsloth_split_need_gb():+ if budget and ram_gb() < unsloth_split_need_gb(budget_model(cfg)):return cfgpair = can[:2]cfg["gpus_asked"] = True@@ -660,7 +697,7 @@ def offer_together(cfg_path: Path, cfg: dict, yes: bool) -> dict:say(" use). On both, the experts the GPUs do not hold are read through the OS file cache instead: faster in")say(" two reports (#364, #384), but RAM can fill up to 0 free during long prompts.")if budget:- say(" This model (UD-Q4_K_XL) runs on one GPU with a RAM budget of its experts (recommended: the tested")+ say(f" This model ({budget_model(cfg)}) runs on one GPU with a RAM budget of its experts (recommended: the tested")say(" setup). On both it has no budget: all its experts are loaded into RAM at start, which this PC's RAM")say(" holds - about twice as fast in #498 (2x RTX 3090: 31 -> 64-78 tokens/s).")short = split_short(pair) # #448: one card recommended (asked "n" by default), as for --resident@@ -869,7 +906,7 @@ def gguf_dir_shards(folder: Path, fam: dict, model: str) -> list[Path]:engine and tools/iq_pack.py do. The published name first; else the one first shard in the folder whose name hasthe size in it (an upload split or named differently: -00001-of-00003, Unsloth's ...-00001-of-00004.gguf). Amissing shard is check_shards' error later, as before."""- first = folder / fam["file"].format(q=model, i=1)+ first = folder / model_file(fam, model, 1)if not first.exists():found = sorted(p for p in folder.glob("*-00001-of-*.gguf") if SHARD_NAME.search(p.name))mine = [p for p in found if model.lower() in p.name.lower()]@@ -888,7 +925,8 @@ def gguf_dir_shards(folder: Path, fam: dict, model: str) -> list[Path]:GGUF_QUANT = re.compile(r"(?<![A-Za-z0-9])((?:UD-)?(?:I?Q\d+(?:_[A-Za-z0-9]+)*|BF16|F16|F32))"r"(?=-\d{5}-of-\d{5}\.gguf$|\.gguf$)", re.I)SUPPORTED_GGUFS = ("Strata runs ISTA-DASLab's GSQ-RCO files (Qwen3.8-Flash-Next Q2_0, IQ2_XS, IQ3_XXS, IQ3_S; Swift "- "1.5's; the Coder's IQ1_M) and Unsloth's UD-Q4_K_XL only: other GGUFs (Unsloth's UD-IQ3_XXS or "+ "1.5's; the Coder's IQ1_M) and Unsloth's UD-Q4_K_XL and UD-IQ4_XS only: other GGUFs (Unsloth's "+ "UD-IQ3_XXS or ""UD-Q2_K_XL, K-quants) cannot be used")@@ -903,7 +941,7 @@ def gguf_choice(name: str) -> tuple | None:the original's sizes: the size tells them apart)."""for f, d in FAMILIES.items():for m in MODELS:- if f in MODELS[m].get("families", ("qwen", "swift")) and name == d["file"].format(q=m, i=1):+ if f in MODELS[m].get("families", ("qwen", "swift")) and name == model_file(d, m, 1):return f, mreturn None@@ -3007,7 +3045,7 @@ def main() -> int:"this mode the experts the GPU does not hold are copied into RAM once when they fit (resident), ""else read through the OS file cache (mmap); resident / mmap force one of the two")ap.add_argument("--resident-budget-gib", type=float, metavar="N",- help="UD-Q4_K_XL: the GiB of its experts kept in RAM (default: the RAM less 24 GB, 40 on 64 GB; "+ help="UD-Q4_K_XL, UD-IQ4_XS: the GiB of its experts kept in RAM (default: the RAM less 24 GB, 40 on 64 GB; ""more is kept as you choose, with a note)")ap.add_argument("--vram-reserve-mib", type=int, metavar="N",help="VRAM in MiB the engine leaves free for other programs (a game, another model; the engine's "@@ -3259,7 +3297,7 @@ def main() -> int:# the RAM holds the GGUFs and 24 GB more: then several, without the budget, if asked for (#498)warn(f"{model} is EXPERIMENTAL (docs/UNSLOTH_Q4.md): most of its experts are read from the SSD while it ""answers, so it is several times slower than the 2-3-bit models; quality checked against llama.cpp")- if hip:+ if hip and MODELS[model].get("nvidia_only"):# #429 (jkuepker): checked before the 111 GB download. The HIP engine has no prompt kernels for its# Q4_K / Q5_K experts (STRATA_MMQ_KQUANTS is CUDA-only) and it has not been run on AMD: asked, not refusedconfirm_risk(f"{model} has not been run on AMD cards yet: its prompt kernels are NVIDIA-only, so on "@@ -3284,7 +3322,8 @@ def main() -> int:if a.low_ram not in ("auto", "off"):warn(f"--low-ram {a.low_ram} does not apply to {model}: it always reads part of its experts from the files")elif a.resident_budget_gib is not None:- warn(f"--resident-budget-gib is for UD-Q4_K_XL: {model} keeps all of its experts in RAM or in the low-RAM mode")+ warn(f"--resident-budget-gib is for UD-Q4_K_XL and UD-IQ4_XS: {model} keeps all of its experts in RAM or in "+ "the low-RAM mode")low_ram = budget is None and (a.low_ram in ("on", "resident", "mmap") or(a.low_ram == "auto" and low_ram_needed(model, ram)))if low_ram and multi and not low_ram_together(a, model, ram, gpu, chosen):@@ -3420,7 +3459,7 @@ def main() -> int:if family == "swift" else f"the experimental speed projection is not tested with {model}: left off")models_dir = Path(a.gguf_dir) if a.gguf_dir else Path(a.models_dir) / tagshards = gguf_dir_shards(models_dir, fam, model) if a.gguf_dir else \- [models_dir / fam["file"].format(q=model, i=i) for i in range(1, fam.get("shards", 2) + 1)]+ [models_dir / model_file(fam, model, i) for i in range(1, model_shards(fam, model) + 1)]problem = gguf_dir_problem(models_dir, shards[0], fam, model) if a.gguf_dir else Noneif problem: # #444: files Strata cannot run, or another choice's filesfail(*problem)@@ -3481,8 +3520,9 @@ def main() -> int:else:lib_dirs = meta.get("lib_dirs") or meta.get("cuda_dirs") or cuda_lib_dirs()engine_ver = tuple(int(x) for x in str(meta.get("version", "0")).split(".")[:3] if x.isdigit())- if budget is not None and engine_ver < UNSLOTH_ENGINE: # checked before the 111 GB download- fail(f"{model} needs engine {'.'.join(map(str, UNSLOTH_ENGINE))} or newer; this one is {meta.get('version')}",+ need_engine = MODELS[model].get("engine", UNSLOTH_ENGINE)+ if budget is not None and engine_ver < need_engine: # checked before the 94-111 GB download+ fail(f"{model} needs engine {'.'.join(map(str, need_engine))} or newer; this one is {meta.get('version')}","update Strata (or compile the engine with --build) and run setup again")ok(f"engine: {eng / EXE}")diff --git a/tools/test_setup_choices.py b/tools/test_setup_choices.pyindex c55d1b206..17b5487e5 100644--- a/tools/test_setup_choices.py+++ b/tools/test_setup_choices.py@@ -122,7 +122,7 @@ class GgufDirUnsupported(unittest.TestCase):self.assertEqual(msg, "Qwen3.8-Flash-Next-UD-IQ3_XXS-00001-of-00003.gguf is UD-IQ3_XXS, a GGUF Strata ""cannot run")self.assertIn("ISTA-DASLab's GSQ-RCO files", hint)- self.assertIn("Unsloth's UD-Q4_K_XL only", hint)+ self.assertIn("Unsloth's UD-Q4_K_XL and UD-IQ4_XS only", hint)def test_a_folder_without_the_choice_names_what_is_there(self):gsq = ["Qwen3.8-Flash-Next-GSQ-RCO-IQ1_M-%05d-of-00002.gguf" % i for i in (1, 2)]@@ -145,7 +145,7 @@ class GgufDirUnsupported(unittest.TestCase):code, out, _, _ = install(ram, found, ["--gguf-dir", d, "--family", "unsloth", "--model", "IQ3_XXS"])self.assertEqual(code, 1)self.assertIn("has no IQ3_XXS model file", out)- self.assertIn("choose one of: UD-Q4_K_XL (or IQ3_XXS: --family qwen --model IQ3_XXS, --family swift --model "+ self.assertIn("choose one of: UD-Q4_K_XL, UD-IQ4_XS (or IQ3_XXS: --family qwen --model IQ3_XXS, --family swift --model ""IQ3_XXS)", out)self.assertIn("Strata runs ISTA-DASLab's GSQ-RCO files", out)diff --git a/tools/test_setup_unsloth.py b/tools/test_setup_unsloth.pyindex a010b5e8f..dab1e74c3 100644--- a/tools/test_setup_unsloth.py+++ b/tools/test_setup_unsloth.py@@ -126,7 +126,7 @@ class FakeGGUF:self.tensors = [types.SimpleNamespace(name=n) for n in names]-class Main(unittest.TestCase):+class Base(unittest.TestCase):"""setup.main() for the Unsloth choice, every outside effect mocked."""def setUp(self):@@ -139,7 +139,7 @@ class Main(unittest.TestCase):def tearDown(self):self.tmp.cleanup()- def main(self, argv, ram=63.7, version="0.1.32", n_gpus=1, model=True, amd=(), free=500.0):+ def main(self, argv, ram=63.7, version="0.1.32", n_gpus=1, model=True, amd=(), free=500.0, m=M):eng = self.t / "engine"eng.mkdir(exist_ok=True)(eng / "BUILD.json").write_text(json.dumps({"version": version, "source": "local"}))@@ -166,6 +166,7 @@ class Main(unittest.TestCase):mock.patch.object(setup, "cpu_info", lambda: ("Test CPU", True, True)),mock.patch.object(setup, "page_file_gb", lambda: 16.0),mock.patch.object(setup, "free_gb", lambda p: free),+ mock.patch.object(setup, "rotational_disk", lambda p: None), # #605: not the test PC's diskmock.patch.object(setup, "pip_install", lambda *a, **k: None),mock.patch.object(setup, "get_llama_cpp", lambda: self.t / "llama.cpp"),mock.patch.object(setup, "get_prebuilt", lambda *a, **k: eng),@@ -178,7 +179,7 @@ class Main(unittest.TestCase):mock.patch.object(setup, "saved_calibration", lambda cfg: None),mock.patch.object(setup, "start", mock.Mock(side_effect=AssertionError("started"))),mock.patch.dict(sys.modules, {"gguf_reader": types.SimpleNamespace(GGUFFile=FakeGGUF)}),- mock.patch.object(sys, "argv", ["setup.py", "--family", "unsloth", *(["--model", M] if model else []),+ mock.patch.object(sys, "argv", ["setup.py", "--family", "unsloth", *(["--model", m] if model else []),"--yes", "--no-start","--models-dir", str(self.t / "models"), *argv]),mock.patch("builtins.input", mock.Mock(side_effect=AssertionError("asked"))),@@ -187,9 +188,12 @@ class Main(unittest.TestCase):for p in patches:st.enter_context(p)code, out = quiet(setup.main)- cfg = self.t / "strata-unsloth-ud-q4_k_xl.json"+ cfg = self.t / f"strata-unsloth-{m.lower()}.json"return code, out, (json.loads(cfg.read_text()) if cfg.exists() else None)+class Main(Base):+ """UD-Q4_K_XL."""+def test_install(self):code, out, cfg = self.main(["--context", "8192"])self.assertEqual(code, 0, out)@@ -357,6 +361,76 @@ class Main(unittest.TestCase):self.assertIn("--resident-budget-gib", cfg["args"])+X = "UD-IQ4_XS"+++class IQ4XS(Base):+ """#621 (EXPERIMENTAL): Unsloth's UD-IQ4_XS - three pinned shards, the same RAM-budget setup as UD-Q4_K_XL (the+ pack with --compat-bf16, never experts.bin, one GPU, no images), engine 0.1.38 or newer, no AMD question."""++ def test_pins(self):+ fam = setup.FAMILIES["unsloth"]+ names = [setup.model_file(fam, X, i) for i in range(1, setup.model_shards(fam, X) + 1)]+ self.assertEqual(names, list(setup.UNSLOTH_IQ4_XS_SHARDS))+ self.assertEqual(sum(b for b, _ in setup.UNSLOTH_IQ4_XS_SHARDS.values()), 93682584224)+ for n, (size, sha) in setup.UNSLOTH_IQ4_XS_SHARDS.items():+ self.assertRegex(sha, r"^[0-9a-f]{64}$")+ self.assertEqual(fam["sha256"][n], (size, sha))+ for n in setup.UNSLOTH_SHARDS: # UD-Q4_K_XL's are still there+ self.assertEqual(fam["sha256"][n], setup.UNSLOTH_SHARDS[n])+ self.assertAlmostEqual(setup.MODELS[X]["download_gb"], 93682584224 / 1e9, places=1)+ self.assertEqual(setup.MODELS[X]["families"], ("unsloth",))+ self.assertEqual([m for m in setup.MODELS if "unsloth" in setup.MODELS[m].get("families", ())], [M, X])+ self.assertIsNone(setup.gguf_unsupported(names[0])) # #444: a file setup runs now+ self.assertEqual(setup.gguf_choice(names[0]), ("unsloth", X))+ self.assertEqual(setup.budget_model({"args": ["--native", "/m/" + names[0]]}), X)+ self.assertEqual(setup.budget_model({"args": ["--native", "/m/" + list(setup.UNSLOTH_SHARDS)[0]]}), M)+ self.assertEqual(setup.budget_model({"args": []}), M)++ def test_budget(self):+ self.assertEqual(setup.resident_budget_gib(X, 63.7), 40)+ self.assertEqual(setup.resident_budget_gib(X, 95.8), 55) # at most all of them (59.5 GB)+ self.assertAlmostEqual(setup.unsloth_split_need_gb(X), 93.7 + setup.UNSLOTH_RAM_LEFT_GB)++ def test_install(self):+ code, out, cfg = self.main(["--context", "8192"], version="0.1.38", m=X)+ self.assertEqual(code, 0, out)+ self.assertIn("EXPERIMENTAL", out)+ base = f"https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/{REV}/UD-IQ4_XS/"+ self.assertEqual(self.downloads, [base + n for n in setup.UNSLOTH_IQ4_XS_SHARDS])+ self.assertEqual(self.verified, [(n, *v) for n, v in setup.UNSLOTH_IQ4_XS_SHARDS.items()])+ packs = [r for r in self.runs if r[1].endswith("iq_pack.py")]+ self.assertEqual(len(packs), 1, self.runs)+ self.assertIn("--compat-bf16", packs[0])+ self.assertNotIn("--experts-bin", packs[0])+ self.assertTrue(packs[0][packs[0].index("--gguf") + 1].endswith("UD-IQ4_XS-00001-of-00003.gguf"))+ args = cfg["args"]+ self.assertEqual(args[args.index("--resident-budget-gib") + 1], "40")+ self.assertTrue(args[args.index("--native") + 1].endswith("UD-IQ4_XS-00001-of-00003.gguf"))+ for flag in ("--ple-gguf", "--mmap-experts", "--resident-experts", "--vision"):+ self.assertNotIn(flag, args)+ self.assertEqual(cfg["model_name"], "qwen3.8-flash-next-unsloth-ud-iq4_xs")+ with tempfile.TemporaryDirectory() as t: # a start reads the choice back+ p = Path(t) / "strata-unsloth-ud-iq4_xs.json"+ p.write_text(json.dumps(cfg))+ ch = setup.choices_from_config(p)+ self.assertEqual((ch["family"], ch["model"]), ("unsloth", X))++ def test_engine_0138(self):+ code, out, cfg = self.main(["--context", "8192"], version="0.1.37", m=X)+ self.assertEqual(code, 1)+ self.assertIn("needs engine 0.1.38 or newer; this one is 0.1.37", out)+ self.assertEqual(self.downloads, [])++ def test_amd_is_not_asked(self):+ r9700 = [{"index": 0, "name": "AMD Radeon AI PRO R9700", "vram_gb": 31.9, "arch": "gfx1201",+ "driver": "amdgpu"}]+ with mock.patch.object(setup, "get_prebuilt_hip", lambda *a, **k: self.t / "engine"):+ code, out, cfg = self.main(["--context", "8192", "--backend", "hip"], version="0.1.38", amd=r9700, m=X)+ self.assertNotIn("has not been run on AMD cards yet", out)+ self.assertIn("RAM budget: 40 GiB of UD-IQ4_XS's experts", out)++class LayerSplit(unittest.TestCase):"""#498: UD-Q4_K_XL across GPUs - asked at setup (one GPU by default), and a start with --gpus no longer keepsthe RAM budget the engine refuses with a split (it exited with code 2)."""