setup: Unsloth's files keep every expert in RAM where they fit with 16 GiB more (the RAM budget below that); UD-Q5_K_XL, UD-Q6_K_XL and Q8_0 in the unsloth family; UD-Q4_K_XL no longer experimental or NVIDIA-only

- unsloth_budget / UNSLOTH_RESIDENT_BESIDE_GB 16, ported from sergqwer's fork (sergqwer/strata-nvfp4 3f3546f6, MIT):
  no --resident-budget-gib where the experts and 16 GiB fit the RAM (UD-IQ4_XS 71.4, UD-Q4_K_XL 87.7, UD-Q5_K_XL 107.6,
  UD-Q6_K_XL 117.7, Q8_0 135.5 GiB), the budget below that, when asked for, and on a unified-memory APU (#1715).
  The menu, --check and the install say which; the menu's default for the family is the largest file whose experts
  all fit (UD-IQ4_XS where none does).
- UD-Q5_K_XL / UD-Q6_K_XL / Q8_0: six shards each, sizes and SHA-256 pinned at 38bb39ee; "ram_gb" is the all-in-RAM
  need, below it setup asks first (default no) and says how many GiB are read from the SSD. Q5/Q6 need engine 0.1.44
  (the Q6_K expert kernels in every build); Q8_0 0.1.38.
- UD-Q4_K_XL: ran on an R9700 (docs/QUANTS.md), so #429's AMD question is gone, and it is not experimental.
- tools/strata_mcp.py mirrors the table and the verdicts. Golden configs re-recorded: only UD-Q4_K_XL on 96 GB
  (65536, --kv-resident) and 128 GB (131072) changed, as in the fork.

Tests: test_setup_unsloth Resident and BigFiles (the budget tests force the budget mode where their PC now fits every
expert), test_strata_mcp, every tools/test_setup_*.py.

Co-authored-by: sergiywith <sergiywith@gmail.com>
This commit is contained in:
Niko1221andsergiywith committed 2026-10-12 22:57:14 +02:00
1 parent b63e38b1ae
commit 23250b5da6
7 files changed
+448 -89

No files matched your search

+138 -40
View File
@@ -212,15 +212,6 @@ MODELS = {
# the Coder release: 256 of the 512 experts kept (the ones code, tools and vision use), IQ2_S-IQ4_XS like IQ3_S
"IQ1_M": {"about": "the Coder's only size: half the experts, stored like IQ3_S (3.5 bits)", "download_gb": 58.4,
"ram_gb": 32, "arena_gb": 23.4, "families": ("coder",)},
# EXPERIMENTAL (docs/UNSLOTH_Q4.md): Unsloth's 4-bit file; its 77 GB of experts do not fit a 64 GB PC, so the engine
# 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, "nvidia_only": True,
"experimental": True,
# #967: images are allowed (the same base model and image encoder as UD-IQ4_XS), with a warning:
# reported working by hand (#967, #971), not tested by us on this file
"vision": True, "vision_untested": True},
# #621: 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. A regular choice from 0.1.39 (no longer experimental). 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 and none from ~80 GB of RAM.
@@ -230,6 +221,32 @@ MODELS = {
"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),
"vision": True},
# Unsloth's 4-bit file (docs/UNSLOTH_Q4.md); experimental until MODEL-UPDATE Phase 2. Its 77 GB of experts stay in
# RAM from ~94 GB of RAM (unsloth_budget); on a 64 GB PC the engine keeps a RAM budget of them
# (--resident-budget-gib, chosen below) and reads the rest from the GGUF on the SSD. It runs on AMD too (R9700:
# the quality yardstick and the decode/prompt numbers in docs/QUANTS.md), so it is no longer NVIDIA-only (#429).
"UD-Q4_K_XL": {"about": "4-bit (Unsloth Dynamic): K-quant experts, between UD-IQ4_XS and UD-Q5_K_XL in quality",
"download_gb": 111.3, "ram_gb": 48, "arena_gb": 77.0, "families": ("unsloth",), "budget": True,
# #967: images are allowed (the same base model and image encoder as UD-IQ4_XS), with a warning:
# reported working by hand (#967, #971), not tested by us on this file
"vision": True, "vision_untested": True},
# MODEL-UPDATE: Unsloth's larger files (docs/QUANTS.md). The same GGUF-in-place mode: every expert in RAM where it
# fits with UNSLOTH_RESIDENT_BESIDE_GB more (unsloth_budget), else a RAM budget of them and the rest read from the
# SSD while it answers - so "ram_gb" is the all-in-RAM need, and below it setup asks first (default no). Their
# shards 2 (the head) and 3 (the 54 GB Q8_0 PLE table) are the same bytes in all three files. UD-Q5_K_XL and
# UD-Q6_K_XL need the Q6_K expert kernels every engine has from MODEL-UPDATE Phase 1 on (Q5: layer 2's gate/up).
"UD-Q5_K_XL": {"about": "5-bit (Unsloth Dynamic): Q5_K experts with Q8_0 downs, close to Q8_0 in quality",
"download_gb": 158.3, "ram_gb": 108, "arena_gb": 98.4, "families": ("unsloth",), "budget": True,
"shards": 6, "file": "Qwen3.8-Flash-Next-{q}-0000{i}-of-00006.gguf", "engine": (0, 1, 44),
"vision": True},
"UD-Q6_K_XL": {"about": "6-bit (Unsloth Dynamic): Q6_K experts with Q8_0 downs",
"download_gb": 169.2, "ram_gb": 118, "arena_gb": 109.2, "families": ("unsloth",), "budget": True,
"shards": 6, "file": "Qwen3.8-Flash-Next-{q}-0000{i}-of-00006.gguf", "engine": (0, 1, 44),
"vision": True},
"Q8_0": {"about": "8-bit, the reference quality (every expert Q8_0); for a 192 GB PC",
"download_gb": 188.2, "ram_gb": 136, "arena_gb": 128.3, "families": ("unsloth",), "budget": True,
"shards": 6, "file": "Qwen3.8-Flash-Next-{q}-0000{i}-of-00006.gguf", "engine": (0, 1, 38),
"vision": True},
}
# 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).
@@ -252,8 +269,49 @@ UNSLOTH_IQ4_XS_SHARDS = {
"Qwen3.8-Flash-Next-UD-IQ4_XS-00003-of-00003.gguf":
(43836407744, "d4634e6d84f0ebb0940be15c90d3790bf6464e3dea3a1cddc567dc0e83ad8833"),
}
# MODEL-UPDATE: UD-Q5_K_XL, UD-Q6_K_XL and Q8_0 at the same revision (sizes and SHA-256: the Hub's LFS pointers; shards
# 2 and 3 are byte-identical across the three)
UNSLOTH_BIG_SHARDS = {
"Qwen3.8-Flash-Next-UD-Q5_K_XL-00001-of-00006.gguf":
(10946618, "610922cdb1afe1094e95d7a3e86b12ee33317ebbf7320ac9344e21b6ae4bb69f"),
"Qwen3.8-Flash-Next-UD-Q5_K_XL-00002-of-00006.gguf":
(682434912, "494ca4ed3dbf97bc28da88af3890b8877b9032f909812d00c0526a9ca5e91d2e"),
"Qwen3.8-Flash-Next-UD-Q5_K_XL-00003-of-00006.gguf":
(54400261312, "34efd79a80a1ce540a517a5d56171924b66ce1c38b04c904f17ad6d8ef17cf20"),
"Qwen3.8-Flash-Next-UD-Q5_K_XL-00004-of-00006.gguf":
(49990245824, "9ee6bbe462e6830864382d629101490625b1c95afa15492b7ad550c7bed2dd13"),
"Qwen3.8-Flash-Next-UD-Q5_K_XL-00005-of-00006.gguf":
(49882416192, "0b2437f661f584030cb5aeb8fb1bb70f6422518a6746bfcc0304167c7b6b8beb"),
"Qwen3.8-Flash-Next-UD-Q5_K_XL-00006-of-00006.gguf":
(3320101792, "55dd96c5ad0863b06b6393151b9ad0ac727b8d58a62e02a296ca5d5ddbfee4a3"),
"Qwen3.8-Flash-Next-UD-Q6_K_XL-00001-of-00006.gguf":
(10946624, "8bdc6bad55b6699f46f60708829932ff4018d7ac9bd309c388534fa31753bdb7"),
"Qwen3.8-Flash-Next-UD-Q6_K_XL-00002-of-00006.gguf":
(682434912, "494ca4ed3dbf97bc28da88af3890b8877b9032f909812d00c0526a9ca5e91d2e"),
"Qwen3.8-Flash-Next-UD-Q6_K_XL-00003-of-00006.gguf":
(54400261312, "34efd79a80a1ce540a517a5d56171924b66ce1c38b04c904f17ad6d8ef17cf20"),
"Qwen3.8-Flash-Next-UD-Q6_K_XL-00004-of-00006.gguf":
(49814108512, "0ea4b599880a5a52fcd9c188ba1443f646c69c96571904ddbd6a79246a01a997"),
"Qwen3.8-Flash-Next-UD-Q6_K_XL-00005-of-00006.gguf":
(49419317344, "9948e81ae8368144b135a7403d8c0f2cf9a6c2f9f692313865855b2832e696c9"),
"Qwen3.8-Flash-Next-UD-Q6_K_XL-00006-of-00006.gguf":
(14838313984, "e4ae255234f42b18012f6d6eec5bf615b57479b7e0a0233c47436a321ffeec3f"),
"Qwen3.8-Flash-Next-Q8_0-00001-of-00006.gguf":
(10946624, "2dabcbb53ca537a7947bc7d20414fd464eeaf4d66d43021b5b2556cc87544ad2"),
"Qwen3.8-Flash-Next-Q8_0-00002-of-00006.gguf":
(682434912, "494ca4ed3dbf97bc28da88af3890b8877b9032f909812d00c0526a9ca5e91d2e"),
"Qwen3.8-Flash-Next-Q8_0-00003-of-00006.gguf":
(54400261312, "34efd79a80a1ce540a517a5d56171924b66ce1c38b04c904f17ad6d8ef17cf20"),
"Qwen3.8-Flash-Next-Q8_0-00004-of-00006.gguf":
(49446841216, "bfa634025fabbd2658bf7694bc80b90e571699c768723f844c934c7ef06c691a"),
"Qwen3.8-Flash-Next-Q8_0-00005-of-00006.gguf":
(49668930400, "232a8f14cc0fa4262e7efe8593774b136fe40909e39c7a020342ddaa27259a97"),
"Qwen3.8-Flash-Next-Q8_0-00006-of-00006.gguf":
(34015618784, "538a93bca918064983409a41187ad4c68640f9aced6f29564da8f551bf86d7a5"),
}
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
UNSLOTH_MIN_RAM_GB = 48 # the RAM-budget mode below which setup says an Unsloth file does not fit (UD-Q4_K_XL's floor)
# Contexts past 262144 (the model's trained length) extend it by rope scaling: for the context it will
# serve the setup resolves the method (yarn, or one question when interactive) and derives the factor
# from the final context (final / 262144, at least 1) itself (below), keeps an explicit
@@ -288,15 +346,15 @@ FAMILIES = {
"profile": "expert-profile-coder.bin"},
# Unsloth's UD-IQ4_XS (three shards, #621; a regular choice from 0.1.39) and the EXPERIMENTAL UD-Q4_K_XL (four)
# of the original model (docs/UNSLOTH_Q4.md); "experimental" and "vision" are per model (MODELS)
"unsloth": {"title": "Qwen3.8-Flash-Next (Unsloth)", "by": "Unsloth's ~4-bit quantizations",
"about": "UD-IQ4_XS: a 94 GB download; with less than ~80 GB of RAM part of its experts are read from "
"the SSD (UD-Q4_K_XL, 111 GB: experimental)",
"unsloth": {"title": "Qwen3.8-Flash-Next (Unsloth)", "by": "Unsloth's 4- to 8-bit quantizations",
"about": "UD-IQ4_XS (94 GB download) to Q8_0 (188 GB): every expert in RAM from ~80 GB (UD-IQ4_XS) "
"to ~136 GB (Q8_0) of RAM, else part of them read from the SSD",
"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",
"vision": False, "pack_args": ["--compat-bf16"],
"sha256": {**UNSLOTH_SHARDS, **UNSLOTH_IQ4_XS_SHARDS}},
"sha256": {**UNSLOTH_SHARDS, **UNSLOTH_IQ4_XS_SHARDS, **UNSLOTH_BIG_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
@@ -1580,9 +1638,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 and UD-IQ4_XS only: other GGUFs (Unsloth's "
"UD-IQ3_XXS or "
"UD-Q2_K_XL, K-quants) cannot be used")
"1.5's; the Coder's IQ1_M) and Unsloth's UD-IQ4_XS, UD-Q4_K_XL, UD-Q5_K_XL, UD-Q6_K_XL and Q8_0 "
"only: other GGUFs (Unsloth's UD-IQ3_XXS or UD-Q2_K_XL, other K-quant files) cannot be used")
def gguf_unsupported(name: str) -> str | None:
@@ -1659,6 +1716,23 @@ def resident_budget_gib(model, ram, kv_ram_gb=0.0) -> int:
return max(8, min(gib, int(MODELS[model]["arena_gb"] / 1.073741824)))
# MODEL-UPDATE Phase 2: Unsloth's files keep every expert in RAM (a pinned arena, as ISTA's files do) where the experts
# and this much more fit the PC's RAM; the RAM budget (--resident-budget-gib: the hottest experts in RAM, the rest read
# from the GGUF in place) only below that. The rule and the 16 GiB are sergqwer's fork (sergqwer/strata-nvfp4,
# 0.1.42-nvfp4.2, MIT): there, on 128 GB with an RTX 5090, UD-Q4_K_XL decoded at 169 tokens/s and read a 32K prompt in
# 4.9 s with every expert in RAM, against 118 tokens/s and 30 s in the budget mode.
UNSLOTH_RESIDENT_BESIDE_GB = 16
def unsloth_budget(model, ram, gpu=None, asked=None) -> bool:
"""Does setup write the RAM-budget mode (--resident-budget-gib) for this Unsloth file: asked for (--resident-budget-gib
N), a unified-memory APU (#1715: there the budget and the GPU's cache are the same RAM, and the all-in-RAM mode was
measured on discrete cards only), or its experts with UNSLOTH_RESIDENT_BESIDE_GB beside them do not fit this PC's RAM
(GiB, ram_gb()). Else every expert is kept in RAM, as for ISTA's files."""
return asked is not None or bool((gpu or {}).get("uma")) or \
ram < MODELS[model]["arena_gb"] / 1.073741824 + UNSLOTH_RESIDENT_BESIDE_GB
UMA_EXPERTS = 24576 # the Flash-Next model's experts (48 layers x 512): the most an expert cache can hold
@@ -5200,16 +5274,21 @@ def main() -> int:
any_fits = False
for m, d in MODELS.items():
verdict = "fits" if ram >= d["ram_gb"] else "tight" if ram >= d["ram_gb"] - 8 else "does not fit"
if d.get("budget"):
if d.get("budget") and not unsloth_budget(m, ram, gpu): # Phase 2: all of them in RAM
verdict = ("EXPERIMENTAL, " if d.get("experimental") else "") + "fits (all of its experts in RAM)"
elif d.get("budget"):
verdict = (("EXPERIMENTAL, " if d.get("experimental") else "") +
f"fits with {resident_budget_gib(m, ram)} GiB of its experts in RAM, the rest "
"read from the SSD" if ram >= d["ram_gb"] else "does not fit")
if hip: # #429: not run on AMD yet (its prompt kernels are CUDA-only)
verdict += " - NVIDIA only so far, untested on AMD"
"read from the SSD" if ram >= d["ram_gb"] else
f"slow here: {resident_budget_gib(m, ram)} GiB of its "
f"{int(d['arena_gb'] / 1.073741824)} GiB of experts in RAM, the rest read from the SSD "
"(setup asks first)" if ram >= UNSLOTH_MIN_RAM_GB else "does not fit")
elif low_ram_needed(m, ram) and low_ram_fits(m, ram, low_ram_vram(gpu)) and a.low_ram != "off":
verdict = (f"fits in the low-RAM mode (the GPU holds ~{100 * low_ram_gpu_share(m, low_ram_vram(gpu)):.0f}% "
"of its experts, " + ("the rest stays in RAM)" if low_ram_resident(m, ram, low_ram_vram(gpu))
else "the rest is read from the SSD as needed)"))
if d.get("budget") and hip and d.get("nvidia_only"): # #429: not run on AMD yet
verdict += " - NVIDIA only so far, untested on AMD"
any_fits = any_fits or not verdict.startswith("does not fit")
say(f" {m:8s} needs ~{d['ram_gb']} GB RAM: {verdict}")
if not any_fits:
@@ -5252,24 +5331,35 @@ def main() -> int:
d = MODELS[m]
fit = "" if ram >= d["ram_gb"] else f" <- needs {d['ram_gb']} GB RAM, you have {ram:.0f}"
if d.get("budget"):
say(f" {i}) {m} {d['about']}; download {d['download_gb']:.0f} GB, keeps ~"
f"{resident_budget_gib(m, ram)} GB of its {d['arena_gb']:.0f} GB of experts in RAM{fit}")
keeps = (f"~{resident_budget_gib(m, ram)} GB" if unsloth_budget(m, ram, gpu, a.resident_budget_gib)
else "all")
say(f" {i}) {m} {d['about']}; download {d['download_gb']:.0f} GB, keeps {keeps} of its "
f"{d['arena_gb']:.0f} GB of experts in RAM{fit}")
continue
if low_ram_needed(m, ram) and low_ram_fits(m, ram, low_ram_vram(gpu)) and a.low_ram != "off":
fit = (f" <- fits in the low-RAM mode (the GPU holds ~{100 * low_ram_gpu_share(m, low_ram_vram(gpu)):.0f}%, "
+ ("the rest in RAM)" if low_ram_resident(m, ram, low_ram_vram(gpu)) else "the rest from the SSD)"))
say(f" {i}) {m:8s} {d['about']}; download {d['download_gb']:.0f} GB, uses ~{d['arena_gb']:.0f} GB of RAM{fit}")
rec = str(names.index("IQ3_XXS") + 1) if ram >= 60 and "IQ3_XXS" in names else "1"
if family == "unsloth": # MODEL-UPDATE: the largest file whose experts all fit in RAM
in_ram = [m for m in names if MODELS[m].get("budget") and not MODELS[m].get("experimental")
and not unsloth_budget(m, ram, gpu, a.resident_budget_gib)]
best = max(in_ram, key=lambda m: MODELS[m]["arena_gb"]) if in_ram else \
("UD-IQ4_XS" if "UD-IQ4_XS" in names else names[0])
rec = str(names.index(best) + 1)
model = a.model or names[int(ask("Which size?", [str(i) for i in range(1, len(names) + 1)], rec, a.yes)) - 1]
budget, q4_split = None, False
in_budget = bool(MODELS[model].get("budget")) and unsloth_budget(model, ram, gpu, a.resident_budget_gib)
if MODELS[model].get("budget"):
# Unsloth's UD-Q4_K_XL: a RAM budget of experts, the rest from the GGUF on the SSD - not the low-RAM mode (no
# experts.bin: it would be another 77 GB on the disk), and one GPU (the budget mode had no layer split) unless
# the RAM holds the GGUFs and 24 GB more: then several, without the budget, if asked for (#498). #642: from
# RESIDENT_SPLIT_ENGINE several GPUs, when asked for, keep the budget (unsloth_together)
# Unsloth's files: every expert in RAM where they fit with UNSLOTH_RESIDENT_BESIDE_GB beside them (Phase 2,
# unsloth_budget), as ISTA's. Else a RAM budget of experts, the rest from the GGUF on the SSD - not the low-RAM
# mode (no experts.bin: it would be another 77 GB on the disk), and one GPU (the budget mode had no layer split)
# unless the RAM holds the GGUFs and 24 GB more: then several, without the budget, if asked for (#498). #642:
# from RESIDENT_SPLIT_ENGINE several GPUs, when asked for, keep the budget (unsloth_together)
if MODELS[model].get("experimental"):
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")
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" if in_budget else "") + "; quality checked against llama.cpp")
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 refused
@@ -5279,19 +5369,26 @@ def main() -> int:
f"or --model {model} --yes to try it on AMD anyway", " Try it anyway?")
warn(f"installing {model} on an AMD card, as you chose (please report how it runs)")
if ram < MODELS[model]["ram_gb"]:
have = resident_budget_gib(model, ram)
total = int(MODELS[model]["arena_gb"] / 1.073741824)
confirm_risk(f"{model} needs {MODELS[model]['ram_gb']} GB of RAM or more; this PC has {ram:.0f} GB: "
f"its RAM budget would be {resident_budget_gib(model, ram)} GiB, so nearly every expert is "
"read from the SSD while it answers (very slow), and it may run out of RAM",
bool(a.model), a.yes, f"{model} needs {MODELS[model]['ram_gb']} GB of RAM or more; this PC "
f"has {ram:.0f} GB", f"choose one of the 2-3-bit models, or --model {model} --yes to "
"install it anyway", " Install it anyway?")
f"it would keep {have} GiB of its {total} GiB of experts in RAM and read the other "
f"{total - have} GiB from the SSD while it answers (single-digit tokens/s on most SSDs), and "
"it may run out of RAM", bool(a.model), a.yes,
f"{model} needs {MODELS[model]['ram_gb']} GB of RAM or more; this PC has {ram:.0f} GB",
f"choose a smaller size, or --model {model} --yes to install it anyway", " Install it anyway?")
warn(f"installing {model} with {ram:.0f} GB of RAM, as you chose")
budget = budget_choice(model, ram, a.resident_budget_gib)
if multi and not unsloth_together(a, model, ram, gpu, chosen):
multi, sel, chosen = [], [gpu["index"]], [gpu]
q4_split = bool(multi) and not resident_split() # #498: on several GPUs without the RAM budget (#642: kept)
if not q4_split:
ok(f"RAM budget: {budget:g} GiB of {model}'s experts in RAM, the rest read from the model files on the SSD")
if in_budget:
budget = budget_choice(model, ram, a.resident_budget_gib)
if multi and not unsloth_together(a, model, ram, gpu, chosen):
multi, sel, chosen = [], [gpu["index"]], [gpu]
q4_split = bool(multi) and not resident_split() # #498: on several GPUs without the RAM budget (#642: kept)
if not q4_split:
ok(f"RAM budget: {budget:g} GiB of {model}'s experts in RAM, the rest read from the model files on the SSD")
else:
ok(f"all {MODELS[model]['arena_gb']:.0f} GB of {model}'s experts in RAM (they and "
f"{UNSLOTH_RESIDENT_BESIDE_GB} GiB more fit this PC's {ram:.0f} GB; --resident-budget-gib N keeps only "
"N GiB of them)")
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:
@@ -5516,7 +5613,8 @@ def main() -> int:
lib_dirs = meta.get("lib_dirs") or meta.get("cuda_dirs") or cuda_lib_dirs(cuda_tk)
engine_ver = tuple(int(x) for x in str(meta.get("version", "0")).split(".")[:4] if x.isdigit())
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
# checked before the 94-188 GB download
if MODELS[model].get("budget") and engine_ver < need_engine:
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}")
+107 -1
View File
@@ -170,6 +170,100 @@ def cmd_run(a) -> int:
return 0
# ------------------------------------------------------------------------------------------------ prompt path
PROMPT_LENS = (256, 512, 768, 1000)
def cmd_prompt(a) -> int:
"""The batched prompt path's answer: every segment's first 256 / 512 / 768 / 1000 tokens as a prompt (one request
each, no prompt cache), and the logits after it (STRATA_DUMP_FIRST_LOGITS: float32, the whole vocabulary)."""
cfg = json.load(open(a.config, encoding="utf-8-sig"))
st = json.load(open(a.ids))
out = pathlib.Path(a.out).resolve()
out.mkdir(parents=True, exist_ok=True)
for f in out.glob("first.*"):
f.unlink()
env = dict(os.environ)
env.update(cfg.get("env", {}))
if cfg.get("lib_dirs"):
env["LD_LIBRARY_PATH"] = ":".join(cfg["lib_dirs"] + [env.get("LD_LIBRARY_PATH", "")])
env.update(FIXED_ENV)
for kv in a.env or []:
k, _, v = kv.partition("=")
env[k] = v
env["STRATA_DUMP_FIRST_LOGITS"] = str(out / "first")
if mem_available_gb() < a.min_free_gb:
raise SystemExit(f"only {mem_available_gb():.0f} GB available (< {a.min_free_gb}): not starting an engine")
args = engine_args(cfg, a.gpu_experts, max(PROMPT_LENS))
k = args.index("--short-read")
del args[k:k + 2] # the default (64): these prompts take the batched prompt path
k = args.index("--prefill")
args[k + 1] = "auto"
if a.wrap:
args = a.wrap.split() + args
errf = open(out / "stderr.txt", "w")
print("engine:", " ".join(args), flush=True)
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=errf, text=True,
cwd=cfg.get("cwd"), env=env, bufsize=1)
for line in p.stdout:
if line.startswith("READY"):
break
else:
raise SystemExit(f"the engine ended before READY (exit {p.wait()}); see {out}/stderr.txt")
index = []
for s in st["segments"]:
for n in PROMPT_LENS:
p.stdin.write("GEN 1 " + ",".join(map(str, s["ids"][:n])) + "\n")
p.stdin.flush()
done = None
for line in p.stdout:
if line.startswith(("DONE", "ERR")):
done = line.strip()
break
if done is None or not done.startswith("DONE") or "nonfinite" in done:
p.kill()
raise SystemExit(f"{s['name']} {n}: the engine answered {done!r}")
index.append({"segment": s["name"], "tokens": n})
p.stdin.write("QUIT\n")
p.stdin.flush()
try:
p.wait(timeout=600)
except subprocess.TimeoutExpired:
p.kill()
errf.close()
(out / "index.json").write_text(json.dumps({"requests": index, "args": args, "env": a.env or []}, indent=1))
print(f"{len(index)} prompts")
return 0
def cmd_pcompare(a) -> int:
import numpy as np
ref = pathlib.Path(a.ref)
idx = json.loads((ref / "index.json").read_text())["requests"]
def logp(d, i):
x = np.fromfile(d / f"first.{i}", dtype=np.float32).astype(np.float64)
x -= x.max()
return x - np.log(np.exp(x).sum())
print(f"reference: {ref}")
for run in a.runs:
r = pathlib.Path(run)
kls, agree = [], 0
for i in range(len(idx)):
if not (r / f"first.{i}").exists():
continue
lr, la = logp(ref, i), logp(r, i)
pr = np.exp(lr)
kls.append(float((pr * (lr - la)).sum()))
agree += int(lr.argmax() == la.argmax())
kls.sort()
n = len(kls)
print(f"{r.name:40s} prompts {n:3d} top-1 {100 * agree / max(n, 1):6.2f}% KL mean {sum(kls) / max(n, 1):.5f} "
f"median {kls[n // 2] if n else float('nan'):.5f} max {kls[-1] if n else float('nan'):.5f}")
return 0
# ------------------------------------------------------------------------------------------------ compare
def read_run(path: str) -> dict:
rows = open(path).read().splitlines()
@@ -260,13 +354,25 @@ def main() -> int:
p.add_argument("--gpu-experts", action="store_true", help="--expert-cache 1500 instead of one slot (the experts on the GPU kernels)")
p.add_argument("--min-free-gb", type=float, default=16)
p.add_argument("--wrap", help="a command prefix for the engine, e.g. 'systemd-run --user --scope -p MemoryMax=200G'")
p = sub.add_parser("prompt", help="the batched prompt path's next-token logits after 20 prompts (a directory)")
p.add_argument("--config", required=True)
p.add_argument("--out", required=True)
p.add_argument("--ids", default=str(SET_DIR / "set.ids.json"))
p.add_argument("--env", action="append")
p.add_argument("--gpu-experts", action="store_true")
p.add_argument("--min-free-gb", type=float, default=16)
p.add_argument("--wrap")
p = sub.add_parser("compare")
p.add_argument("ref")
p.add_argument("runs", nargs="+")
p.add_argument("--segments", action="store_true")
p.add_argument("--json")
p = sub.add_parser("pcompare", help="full-vocabulary KL and top-1 of `prompt` directories against a reference one")
p.add_argument("ref")
p.add_argument("runs", nargs="+")
a = ap.parse_args()
return {"ids": cmd_ids, "run": cmd_run, "compare": cmd_compare}[a.cmd](a)
return {"ids": cmd_ids, "run": cmd_run, "prompt": cmd_prompt, "compare": cmd_compare,
"pcompare": cmd_pcompare}[a.cmd](a)
if __name__ == "__main__":
+26 -12
View File
@@ -58,14 +58,22 @@ FALLBACK_MODELS = {
"with little else running", "download_gb": 83.6, "ram_gb": 62, "arena_gb": 50.3},
"IQ1_M": {"about": "the Coder's only size: half the experts, stored like IQ3_S (3.5 bits)", "download_gb": 58.4,
"ram_gb": 32, "arena_gb": 23.4, "families": ("coder",)},
"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, "experimental": True,
"vision": True}, # #967: images allowed (setup warns: untested with this file)
"UD-IQ4_XS": {"about": "~4-bit i-quant (Unsloth Dynamic), between IQ3_S and UD-Q4_K_XL in quality; on a PC with "
"less than ~80 GB of RAM part of its experts are read from the SSD",
"download_gb": 93.7, "ram_gb": 48, "arena_gb": 59.5, "families": ("unsloth",), "budget": True,
"vision": True},
"UD-Q4_K_XL": {"about": "4-bit (Unsloth Dynamic): K-quant experts, between UD-IQ4_XS and UD-Q5_K_XL in quality",
"download_gb": 111.3, "ram_gb": 48, "arena_gb": 77.0, "families": ("unsloth",), "budget": True,
"vision": True}, # #967: images allowed (setup warns: untested with this file)
"UD-Q5_K_XL": {"about": "5-bit (Unsloth Dynamic): Q5_K experts with Q8_0 downs, close to Q8_0 in quality",
"download_gb": 158.3, "ram_gb": 108, "arena_gb": 98.4, "families": ("unsloth",), "budget": True,
"vision": True},
"UD-Q6_K_XL": {"about": "6-bit (Unsloth Dynamic): Q6_K experts with Q8_0 downs",
"download_gb": 169.2, "ram_gb": 118, "arena_gb": 109.2, "families": ("unsloth",), "budget": True,
"vision": True},
"Q8_0": {"about": "8-bit, the reference quality (every expert Q8_0); for a 192 GB PC",
"download_gb": 188.2, "ram_gb": 136, "arena_gb": 128.3, "families": ("unsloth",), "budget": True,
"vision": True},
}
FALLBACK_FAMILIES = {
"qwen": {"title": "Qwen3.8-Flash-Next", "about": "the original model", "tag": ""},
@@ -73,9 +81,9 @@ FALLBACK_FAMILIES = {
"authors' numbers)", "tag": "swift-"},
"coder": {"title": "Qwen3.8-Flash-Next Coder", "about": "half the experts (code, tools, images kept): needs ~32 GB "
"of RAM, faster; weaker outside coding", "tag": "coder-"},
"unsloth": {"title": "Qwen3.8-Flash-Next (Unsloth)", "about": "UD-IQ4_XS: a 94 GB download; with less than ~80 GB "
"of RAM part of its experts are read from the SSD "
"(UD-Q4_K_XL, 111 GB: experimental)",
"unsloth": {"title": "Qwen3.8-Flash-Next (Unsloth)", "about": "UD-IQ4_XS (94 GB download) to Q8_0 (188 GB): every "
"expert in RAM from ~80 GB (UD-IQ4_XS) to ~136 GB "
"(Q8_0) of RAM, else part of them read from the SSD",
"tag": "unsloth-", "vision": False},
}
FALLBACK_CONTEXTS = [8192, 32768, 65536, 131072, 204800, 262144, 393216, 524288]
@@ -712,10 +720,14 @@ class Strata:
if ram is not None:
verdict = "fits" if ram >= d["ram_gb"] else "tight" if ram >= d["ram_gb"] - 8 else "does not fit"
try:
if d.get("budget"):
if d.get("budget") and S and hasattr(S, "unsloth_budget") and not S.unsloth_budget(m, ram):
verdict = ("experimental: " if d.get("experimental") else "") + "fits (all of its experts in RAM)"
elif d.get("budget"):
verdict = (("experimental: " if d.get("experimental") else "")
+ "part of its experts in RAM, the rest read from the SSD"
if ram >= d["ram_gb"] else "does not fit")
if ram >= d["ram_gb"] else
"slow here: part of its experts in RAM, the rest read from the SSD (setup "
"asks first)" if ram >= 48 else "does not fit")
elif S and S.low_ram_needed(m, ram) and S.low_ram_fits(m, ram, vram):
verdict = "fits in the low-RAM mode (slower: the GPU holds part of the experts)"
except Exception: # noqa: BLE001
@@ -960,8 +972,9 @@ def tool_defs(models: dict, families: dict, contexts: list) -> list:
"family": {"type": "string", "enum": list(families),
"description": "qwen = Qwen3.8-Flash-Next (the original), swift = Swift 1.5 (thinks "
"shorter), coder = the Coder (half the experts, ~32 GB RAM, for code), "
"unsloth = Unsloth's ~4-bit (UD-IQ4_XS; UD-Q4_K_XL is "
"experimental), part of the experts read from the SSD"},
"unsloth = Unsloth's 4- to 8-bit files (UD-IQ4_XS, UD-Q4_K_XL, UD-Q5_K_XL, "
"UD-Q6_K_XL, Q8_0): every expert in RAM where they fit, else part of them read "
"from the SSD"},
"model": {"type": "string", "enum": list(models),
"description": "the size (quantization): see strata_models"},
"context": {"type": "integer", "enum": contexts,
@@ -1231,7 +1244,8 @@ class Tools:
usable = [g for g in hw.get("gpus", []) if g.get("usable")]
vram = max((g["vram_gb"] for g in usable), default=12)
context = 32768 if vram < 14 else 65536 if vram < 20 else 131072
if models[model].get("budget"):
if models[model].get("budget") and (not hasattr(s.setup_module(), "unsloth_budget") or
s.setup_module().unsloth_budget(model, hw.get("ram_gb") or 0.0)):
context = 8192 if vram < 14 else 32768
if vision in ("yes", "gpu", "cpu") and models[model].get("vision", families[family].get("vision")) is False:
raise ToolError(f"images are not available with {families[family]['title']} {model} yet: use vision=no")
+2 -2
View File
@@ -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 and UD-IQ4_XS only", hint)
self.assertIn("Unsloth's UD-IQ4_XS, UD-Q4_K_XL, UD-Q5_K_XL, UD-Q6_K_XL and Q8_0 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-IQ4_XS, UD-Q4_K_XL (or IQ3_XXS: --family qwen --model IQ3_XXS, --family swift --model "
self.assertIn("choose one of: UD-IQ4_XS, UD-Q4_K_XL, UD-Q5_K_XL, UD-Q6_K_XL, Q8_0 (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)
+6 -6
View File
@@ -188,11 +188,11 @@
"--mtp",
"<T>/data/mtp/rt",
"--max-context",
"32768",
"131072",
"--kv",
"int8",
"--resident-budget-gib",
"71"
"--kv-resident",
"32768"
],
"cwd": "<T>",
"exe": "<T>/engine/<EXE>",
@@ -1040,11 +1040,11 @@
"--mtp",
"<T>/data/mtp/rt",
"--max-context",
"32768",
"65536",
"--kv",
"int8",
"--resident-budget-gib",
"71"
"--kv-resident",
"32768"
],
"cwd": "<T>",
"exe": "<T>/engine/<EXE>",
+159 -23
View File
@@ -26,6 +26,12 @@ M = "UD-Q4_K_XL"
REV = "38bb39ee97821de2c9009abb7e93950eec396e66"
def budget_mode():
"""The RAM-budget mode whatever the RAM (MODEL-UPDATE Phase 2 writes it only where the experts do not fit): for the
tests of the budget's own paths on PCs that would now keep every expert in RAM (as in sergqwer's fork)."""
return mock.patch.object(setup, "unsloth_budget", lambda *a, **k: True)
class Pins(unittest.TestCase):
def test_the_four_shards(self):
fam = setup.FAMILIES["unsloth"]
@@ -37,7 +43,7 @@ class Pins(unittest.TestCase):
self.assertEqual(fam["hf"].format(q=M),
f"https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/{REV}/UD-Q4_K_XL/")
self.assertEqual(setup.MODELS[M]["families"], ("unsloth",)) # no other family lists it
self.assertTrue(setup.MODELS[M]["experimental"]) # 0.1.39: per model, not the family
self.assertFalse(setup.MODELS[M].get("experimental")) # MODEL-UPDATE Phase 2: official
self.assertFalse(fam.get("experimental"))
self.assertEqual(list(setup.FAMILIES)[0], "qwen") # not the default choice
@@ -213,7 +219,7 @@ class Main(Base):
def test_install(self):
code, out, cfg = self.main(["--context", "8192"])
self.assertEqual(code, 0, out)
self.assertIn("EXPERIMENTAL", out)
self.assertNotIn("EXPERIMENTAL", out)
base = f"https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/{REV}/UD-Q4_K_XL/"
self.assertEqual(self.downloads, [base + n for n in setup.UNSLOTH_SHARDS]) # no image encoder
self.assertEqual([v[0] for v in self.verified], list(setup.UNSLOTH_SHARDS))
@@ -238,6 +244,7 @@ class Main(Base):
self.assertEqual(code, 0, out)
self.assertEqual(cfg["args"][cfg["args"].index("--max-context") + 1], "8192")
@budget_mode()
def test_more_ram_bigger_budget(self):
code, out, cfg = self.main(["--context", "8192"], ram=95.8)
self.assertEqual(code, 0, out)
@@ -265,18 +272,15 @@ class Main(Base):
self.assertIn("--model UD-IQ4_XS --yes", out) # the way to insist (0.1.39: the family's default size)
self.assertEqual(self.downloads, [])
def test_amd_is_asked_before_the_download(self):
"""#429: UD-Q4_K_XL has not run on AMD (CUDA-only prompt kernels): --yes alone stops before the 111 GB
download, saying why; it is not refused outright (the owner's rule: --model with --yes goes on)."""
def test_amd_is_not_asked(self):
"""#429 is closed by MODEL-UPDATE Phase 2: UD-Q4_K_XL ran on an R9700 (quality yardstick, decode and prompt
numbers in docs/QUANTS.md), so AMD is no longer asked before the download."""
r9700 = [{"index": 0, "name": "AMD Radeon AI PRO R9700", "vram_gb": 31.9, "arch": "gfx1201",
"driver": "amdgpu"}]
# chosen in the menu (2 = UD-Q4_K_XL, after the regular UD-IQ4_XS), not by --model: the answer is no
code, out, cfg = self.main(["--context", "8192", "--backend", "hip", "--vision", "no"], model=False,
amd=r9700, answers={"Which size": "2", "Try it anyway": "n"})
self.assertEqual(code, 1, out)
self.assertIn("has not been run on AMD cards yet", out)
self.assertIn("--model UD-Q4_K_XL --yes", out)
self.assertEqual(self.downloads, [])
with mock.patch.object(setup, "get_prebuilt_hip", lambda *a, **k: self.t / "engine"), mock.patch.object(setup, "build_engine_hip", lambda *a, **k: self.t / "engine"):
code, out, cfg = self.main(["--context", "8192", "--backend", "hip", "--vision", "no"], amd=r9700)
self.assertNotIn("has not been run on AMD cards yet", out)
self.assertIn("RAM budget: 40 GiB of UD-Q4_K_XL's experts", out)
def test_resumed_download_needs_room_for_the_rest_only(self):
"""#425: the disk check counts the finished shards and .part files already there (sizes scaled down: a
@@ -346,6 +350,7 @@ class Main(Base):
self.assertNotIn("--mmap-experts", cfg["args"])
self.assertFalse(any("--experts-bin" in r for r in self.runs))
@budget_mode()
@mock.patch.object(setup, "MIN_ENGINE", (0, 1, 39)) # before RESIDENT_SPLIT_ENGINE: no budget on a split
def test_split_when_the_ram_holds_it(self):
# #498: 165 GiB and --gpus 0,1: the split without the RAM budget (the engine refuses the pair)
@@ -359,6 +364,7 @@ class Main(Base):
self.assertIn("OS file cache", out)
self.assertNotIn("RAM budget: ", out)
@budget_mode()
@mock.patch.object(setup, "MIN_ENGINE", (0, 1, 39)) # before RESIDENT_SPLIT_ENGINE: no budget on a split
def test_split_without_the_ram_is_a_warning_not_a_wall(self):
# #737: below the worst-case estimate (a 128 GB PC ran it) the split is still the user's call
@@ -376,6 +382,7 @@ class Main(Base):
self.assertEqual(cfg["gpu"], [0, 1])
self.assertNotIn("--resident-budget-gib", cfg["args"])
@budget_mode()
@mock.patch.object(setup, "MIN_ENGINE", (0, 1, 39)) # before RESIDENT_SPLIT_ENGINE: no budget on a split
def test_an_explicit_budget_keeps_one_gpu(self):
code, out, cfg = self.main(["--context", "8192", "--gpus", "0,1", "--resident-budget-gib", "60"], n_gpus=2,
@@ -417,6 +424,7 @@ class Main(Base):
self.assertEqual(cfg["gpu"], [0, 1])
self.assertIn("--resident-budget-gib", cfg["args"])
@budget_mode()
def test_yes_alone_keeps_one_gpu(self):
code, out, cfg = self.main(["--context", "8192"], n_gpus=2, ram=165.0)
self.assertEqual(code, 0, out)
@@ -446,7 +454,8 @@ class IQ4XS(Base):
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.assertEqual([m for m in setup.MODELS if "unsloth" in setup.MODELS[m].get("families", ())],
[X, M, "UD-Q5_K_XL", "UD-Q6_K_XL", "Q8_0"])
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)
@@ -488,21 +497,21 @@ class IQ4XS(Base):
self.assertEqual((ch["family"], ch["model"]), ("unsloth", X))
def test_family_default_and_menus(self):
"""The first menu lists the Unsloth family without [experimental]; its size menu puts UD-IQ4_XS first (the
default, Enter) and UD-Q4_K_XL second, still marked EXPERIMENTAL; --model names are unchanged."""
"""The first menu lists the Unsloth family without [experimental]; its size menu lists the five files by size,
UD-IQ4_XS first (the default on 64 GB, Enter), none marked EXPERIMENTAL; --model names are unchanged."""
code, out, cfg = self.main(["--context", "8192", "--vision", "no"], version="0.1.38", model=False,
family=False, answers={"Which model": "4"}, m=X)
self.assertEqual(code, 0, out)
fam_line = next(ln for ln in out.splitlines() if ln.startswith(" 4) "))
self.assertIn("Qwen3.8-Flash-Next (Unsloth)", fam_line)
self.assertIn("UD-IQ4_XS: a 94 GB download", fam_line)
self.assertIn("UD-IQ4_XS (94 GB download) to Q8_0", fam_line)
self.assertNotIn("[experimental]", out)
size_lines = [ln for ln in out.splitlines() if ln.startswith((" 1) UD-", " 2) UD-"))]
self.assertEqual(len(size_lines), 2, out)
self.assertTrue(size_lines[0].startswith(" 1) UD-IQ4_XS ~4-bit"), size_lines[0])
self.assertNotIn("EXPERIMENTAL", size_lines[0])
self.assertTrue(size_lines[1].startswith(" 2) UD-Q4_K_XL 4-bit"), size_lines[1])
self.assertIn("EXPERIMENTAL", size_lines[1])
size_lines = [ln for ln in out.splitlines()
if any(ln.startswith(f" {i}) {m} ") for i in range(1, 6) for m in setup.MODELS)]
self.assertEqual(len(size_lines), 5, out)
for i, (line, m) in enumerate(zip(size_lines, (X, M, "UD-Q5_K_XL", "UD-Q6_K_XL", "Q8_0")), 1):
self.assertTrue(line.startswith(f" {i}) {m} "), line)
self.assertNotIn("EXPERIMENTAL", line)
self.assertTrue(any("Which size" in q and "[1]" in q for q in self.asked), self.asked)
self.assertEqual(cfg["model_name"], "qwen3.8-flash-next-unsloth-ud-iq4_xs")
code, out, cfg = self.main(["--context", "8192"], version="0.1.38", model=False, m=X) # --yes: same default
@@ -530,7 +539,7 @@ class IQ4XS(Base):
line = next(ln for ln in out.splitlines() if ln.strip().startswith(X))
self.assertIn("fits with 40 GiB of its experts in RAM", line)
self.assertNotIn("EXPERIMENTAL", line)
self.assertIn("EXPERIMENTAL", next(ln for ln in out.splitlines() if ln.strip().startswith(M)))
self.assertNotIn("EXPERIMENTAL", next(ln for ln in out.splitlines() if ln.strip().startswith(M)))
def test_check_below_every_floor(self):
# #977: 16 GB fits no size; the RAM line is not [ok] and the verdict says so
@@ -614,6 +623,7 @@ class LayerSplit(unittest.TestCase):
from test_setup_golden import card
self.found = [card(i, "NVIDIA GeForce RTX 3090", 24.0, "86") for i in range(2)]
@budget_mode()
def test_asked_one_gpu_by_default(self):
from test_setup_golden import install
argv = ["--family", "unsloth", "--model", M, "--context", "32768", "--no-start"]
@@ -706,5 +716,131 @@ class LayerSplit(unittest.TestCase):
self.assertIn("--resident-budget-gib", cfg["args"])
Q5, Q6, Q8 = "UD-Q5_K_XL", "UD-Q6_K_XL", "Q8_0"
class Resident(Base):
"""MODEL-UPDATE Phase 2 (sergqwer's fork, 0.1.42-nvfp4.2): every expert of an Unsloth file in RAM (a pinned arena, no
--resident-budget-gib) where they fit with UNSLOTH_RESIDENT_BESIDE_GB more; the budget below that, when asked for,
and on a unified-memory APU."""
def test_the_rule(self):
self.assertEqual(setup.UNSLOTH_RESIDENT_BESIDE_GB, 16)
need = {m: setup.MODELS[m]["arena_gb"] / 1.073741824 + 16 for m in (X, M, Q5, Q6, Q8)}
self.assertEqual({m: round(v, 1) for m, v in need.items()},
{X: 71.4, M: 87.7, Q5: 107.6, Q6: 117.7, Q8: 135.5})
for m in (X, M, Q5, Q6, Q8): # "ram_gb" of the bigger files is that need, so below it setup asks
if m in (Q5, Q6, Q8):
self.assertEqual(setup.MODELS[m]["ram_gb"], int(-(-need[m] // 1)))
for ram, budget in ((63.7, {X, M, Q5, Q6, Q8}), (80.0, {M, Q5, Q6, Q8}), (95.8, {Q5, Q6, Q8}),
(127.8, {Q8}), (191.0, set())):
for m in (X, M, Q5, Q6, Q8):
self.assertEqual(setup.unsloth_budget(m, ram), m in budget, (m, ram))
self.assertTrue(setup.unsloth_budget(X, 124.0, {"uma": True})) # #1715: measured on discrete cards only
self.assertTrue(setup.unsloth_budget(M, 127.2, None, 40)) # --resident-budget-gib: asked for
self.assertFalse(setup.unsloth_budget(M, 127.2, {"uma": False}))
def test_install_at_128_gb(self):
for m, ver in ((M, "0.1.32"), (X, "0.1.38"), (Q5, "0.1.44")):
with self.subTest(m):
code, out, cfg = self.main(["--context", "131072"], ram=127.8, version=ver, m=m)
self.assertEqual(code, 0, out)
args = cfg["args"]
for flag in ("--resident-budget-gib", "--mmap-experts", "--resident-experts", "--low-ram"):
self.assertNotIn(flag, args)
self.assertIn(f"of {m}'s experts in RAM (they and 16 GiB more fit", out)
self.assertNotIn("RAM budget:", out)
self.assertEqual(args[args.index("--max-context") + 1], "131072")
def test_64_gb_keeps_the_budget(self):
for m, ver in ((M, "0.1.32"), (X, "0.1.38")):
with self.subTest(m):
code, out, cfg = self.main(["--context", "8192"], ram=63.7, version=ver, m=m)
self.assertEqual(code, 0, out)
self.assertEqual(cfg["args"][cfg["args"].index("--resident-budget-gib") + 1], "40")
self.assertIn(f"RAM budget: 40 GiB of {m}'s experts in RAM", out)
def test_an_asked_budget_is_kept(self):
code, out, cfg = self.main(["--context", "8192", "--resident-budget-gib", "40"], ram=127.8)
self.assertEqual(code, 0, out)
self.assertEqual(cfg["args"][cfg["args"].index("--resident-budget-gib") + 1], "40")
self.assertNotIn(f"of {M}'s experts in RAM (they and", out)
def test_the_menu_and_check_say_so(self):
code, out, _ = self.main(["--check"], ram=127.8)
for m, verdict in ((X, "fits (all of its experts in RAM)"), (M, "fits (all of its experts in RAM)"),
(Q5, "fits (all of its experts in RAM)"), (Q8, "slow here: 104 GiB of its 119 GiB")):
line = next(ln for ln in out.splitlines() if ln.strip().startswith(m + " "))
self.assertIn(verdict, line)
def test_default_is_the_largest_that_fits(self):
for ram, best in ((63.7, X), (95.8, M), (127.8, Q6), (191.0, Q8)):
with self.subTest(ram):
code, out, cfg = self.main(["--context", "8192"], ram=ram, version="0.1.44", model=False, m=best)
self.assertEqual(code, 0, out)
self.assertEqual(cfg["model_name"], f"qwen3.8-flash-next-unsloth-{best.lower()}")
def test_two_gpus_split_with_every_expert_in_ram(self):
"""Where the experts fit, two cards are the GGUF models' layer split (no budget question, no #498 note)."""
code, out, cfg = self.main(["--context", "8192"], n_gpus=2, ram=127.8)
self.assertEqual(code, 0, out)
self.assertEqual(cfg["gpu"], [0, 1])
self.assertEqual(cfg["layer_split"], "auto")
self.assertNotIn("--resident-budget-gib", cfg["args"])
self.assertNotIn("which GPUs?", out)
class BigFiles(Base):
"""MODEL-UPDATE: UD-Q5_K_XL, UD-Q6_K_XL and Q8_0 - six pinned shards each (sizes and SHA-256 from the Hub), the same
GGUF-in-place setup as UD-Q4_K_XL (--compat-bf16 pack, every expert in RAM where it fits); below the all-in-RAM need
setup asks first (default no) and says how much is read from the SSD."""
def test_pins(self):
fam = setup.FAMILIES["unsloth"]
for m, total in ((Q5, 158286406650), (Q6, 169165382688), (Q8, 188225033248)):
names = [setup.model_file(fam, m, i) for i in range(1, setup.model_shards(fam, m) + 1)]
self.assertEqual(len(names), 6)
self.assertEqual(sum(setup.UNSLOTH_BIG_SHARDS[n][0] for n in names), total)
for n in names:
self.assertRegex(fam["sha256"][n][1], r"^[0-9a-f]{64}$")
self.assertIsNone(setup.gguf_unsupported(names[0]))
self.assertEqual(setup.gguf_choice(names[0]), ("unsloth", m))
self.assertEqual(setup.budget_model({"args": ["--native", "/m/" + names[0]]}), m)
self.assertAlmostEqual(setup.MODELS[m]["download_gb"], total / 1e9, places=1)
for i in (2, 3): # the head and the PLE table: the same bytes in all three
self.assertEqual(len({setup.UNSLOTH_BIG_SHARDS[setup.model_file(fam, m, i)] for m in (Q5, Q6, Q8)}), 1)
def test_install_q8_at_192_gb(self):
code, out, cfg = self.main(["--context", "32768"], ram=191.0, version="0.1.44", m=Q8)
self.assertEqual(code, 0, out)
base = f"https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/{REV}/Q8_0/"
names = [setup.model_file(setup.FAMILIES["unsloth"], Q8, i) for i in range(1, 7)]
self.assertEqual(self.downloads, [base + n for n in names])
self.assertEqual([v[0] for v in self.verified], names)
packs = [r for r in self.runs if r[1].endswith("iq_pack.py")]
self.assertIn("--compat-bf16", packs[0])
args = cfg["args"]
self.assertNotIn("--resident-budget-gib", args)
self.assertTrue(args[args.index("--native") + 1].endswith("Q8_0-00001-of-00006.gguf"))
self.assertEqual(cfg["model_name"], "qwen3.8-flash-next-unsloth-q8_0")
def test_q8_below_its_ram_is_asked(self):
code, out, cfg = self.main(["--context", "8192"], ram=127.8, version="0.1.44", m=Q8,
answers={"Install it anyway": "n"})
self.assertEqual(code, 1, out)
self.assertIn("Q8_0 needs 136 GB of RAM or more; this PC has 128 GB", out)
self.assertEqual(self.downloads, [])
code, out, cfg = self.main(["--context", "8192"], ram=127.8, version="0.1.44", m=Q8) # --model + --yes
self.assertEqual(code, 0, out)
self.assertEqual(cfg["args"][cfg["args"].index("--resident-budget-gib") + 1], "104")
def test_q5_q6_need_the_q6k_engine(self):
for m in (Q5, Q6):
code, out, cfg = self.main(["--context", "8192"], ram=191.0, version="0.1.43", m=m)
self.assertEqual(code, 1)
self.assertIn(f"{m} needs engine 0.1.44 or newer; this one is 0.1.43", out)
self.assertEqual(self.downloads, [])
if __name__ == "__main__":
unittest.main()
+10 -5
View File
@@ -573,21 +573,26 @@ class Helpers(unittest.TestCase):
self.assertEqual(list(S.CONTEXTS), M.FALLBACK_CONTEXTS)
def test_unsloth_sizes(self):
"""0.1.39: UD-IQ4_XS is a regular size, listed first (the family's default); UD-Q4_K_XL stays experimental."""
"""0.1.39: UD-IQ4_XS is a regular size, listed first; MODEL-UPDATE Phase 2: UD-Q4_K_XL is no longer experimental,
and UD-Q5_K_XL, UD-Q6_K_XL and Q8_0 follow by size."""
s = M.Strata(HERE.parent)
for models in (s.tables()[0], M.FALLBACK_MODELS):
self.assertEqual(s.sizes_of(models, "unsloth"), ["UD-IQ4_XS", "UD-Q4_K_XL"])
self.assertEqual(s.sizes_of(models, "unsloth"), ["UD-IQ4_XS", "UD-Q4_K_XL", "UD-Q5_K_XL", "UD-Q6_K_XL", "Q8_0"])
self.assertFalse(models["UD-IQ4_XS"].get("experimental"))
self.assertTrue(models["UD-Q4_K_XL"].get("experimental"))
self.assertFalse(models["UD-Q4_K_XL"].get("experimental"))
self.assertEqual(s.sizes_of(M.FALLBACK_MODELS, "qwen"), ["Q2_0", "IQ2_XS", "IQ3_XXS", "IQ3_S"])
fam = next(f for f in s.model_table({"ram_gb": 63.7, "gpus": []}) if f["family"] == "unsloth")
self.assertFalse(fam["experimental"])
self.assertTrue(fam["images"])
by = {x["model"]: x for x in fam["sizes"]}
self.assertEqual((by["UD-IQ4_XS"]["experimental"], by["UD-IQ4_XS"]["images"]), (False, True))
self.assertEqual((by["UD-Q4_K_XL"]["experimental"], by["UD-Q4_K_XL"]["images"]), (True, True)) # #967
self.assertEqual((by["UD-Q4_K_XL"]["experimental"], by["UD-Q4_K_XL"]["images"]), (False, True)) # #967
self.assertFalse(by["UD-IQ4_XS"]["on_this_pc"].startswith("experimental"))
self.assertTrue(by["UD-Q4_K_XL"]["on_this_pc"].startswith("experimental"))
self.assertIn("read from the SSD", by["UD-Q4_K_XL"]["on_this_pc"]) # 64 GB: the RAM budget
fam = next(f for f in s.model_table({"ram_gb": 127.8, "gpus": []}) if f["family"] == "unsloth")
by = {x["model"]: x for x in fam["sizes"]}
self.assertEqual(by["UD-Q4_K_XL"]["on_this_pc"], "fits (all of its experts in RAM)")
self.assertIn("read from the SSD", by["Q8_0"]["on_this_pc"])
def test_recommendation_follows_ram(self):
s = M.Strata(HERE.parent)