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: Flash-Next images 'yes' gets the CPU encoder on an NVIDIA card under 24 GB, --vision gpu kept with a note (#2406: the GPU encoder cost 3-5% of text speed on 16 GB cards, 35-60% on an RTX 4080 SUPER under Windows as reported); goldens re-recorded for the two 16 GB Unsloth configs
Niko122145752724d9f6
diff --git a/setup.py b/setup.pyindex 22df72434..889144648 100644--- a/setup.py+++ b/setup.py@@ -1911,6 +1911,26 @@ def unsloth_images_default(model, family, ram, gpu=None) -> bool:return g.get("vram_gb", 0.0) >= UNSLOTH_IMAGES_MIN_VRAM_GB+IMAGES_GPU_ENCODER_MIN_VRAM_GB = 23.5 # #2406: below this the images answer "yes" gets the CPU encoder (a card of 12-16 GB: the GPU+ # encoder's ~1.1-1.4 GB is ~850 expert slots lost, 3-5% of decode and prompt on P100 / A4000+ # 16 GB (Linux, IQ3_S / IQ3_XXS), and 35-60% on an RTX 4080 SUPER under Windows as reported)+++def flash_vision_encoder(asked: str, gpu: dict) -> str:+ """#2406: which encoder a Flash-Next images answer gets on NVIDIA. "yes" (the question's y, or --vision yes) means the+ GPU encoder on a card of 24 GB and more and the CPU encoder below that: a picture then takes a few seconds, the text+ keeps the ~1 GB of VRAM for experts. --vision gpu is always kept (with a note on a small card); --vision cpu is kept."""+ vram = float((gpu or {}).get("vram_gb") or 0.0)+ small = 0 < vram < IMAGES_GPU_ENCODER_MIN_VRAM_GB+ if asked == "gpu" and small:+ warn(f"the GPU image encoder keeps ~1.4 GB of VRAM that a {vram:.0f} GB card would use for experts (measured 3-5% "+ "of decode on 16 GB cards, more on some Windows PCs, #2406): kept as you chose; --vision cpu reads pictures "+ "on the CPU instead (a few seconds each)")+ if asked == "yes":+ return "cpu" if small else "gpu"+ return asked++UMA_EXPERTS = 24576 # the Flash-Next model's experts (48 layers x 512): the most an expert cache can hold@@ -6495,14 +6515,22 @@ def main() -> int:vision = hip_vision(a.vision if a.vision is not None or not unsloth_images_default(model, family, ram, gpu)else "cpu")elif a.vision:- vision = {"yes": "gpu", "no": "none"}.get(a.vision, a.vision)+ vision = flash_vision_encoder(a.vision, gpu) if a.vision != "no" else "none"+ vision = "none" if vision in ("no", "none") else visionelse:+ small = 0 < float(gpu.get("vram_gb") or 0.0) < IMAGES_GPU_ENCODER_MIN_VRAM_GBsay()say(" Images: the model can also read pictures (screenshots, photos, scanned pages). This adds a 0.9 GB")- say(" download and keeps ~1.4 GB of VRAM free for the image encoder, so text is a few % slower.")+ if small:+ say(" download. On a card under 24 GB the encoder runs on the CPU (a few seconds per picture, nothing taken")+ say(" from the GPU, pictures read at up to 300 tokens; --vision-tokens 1024 for more detail): the GPU")+ say(" encoder keeps ~1.4 GB of VRAM free, which costs 3-5% of text speed on 16 GB cards (measured) and")+ say(" more on some PCs. --vision gpu if you want pictures in under a second.")+ else:+ say(" download and keeps ~1.4 GB of VRAM free for the image encoder, so text is a few % slower.")# MODEL-UPDATE: on by default for Unsloth's files on a card with room for the encoder (16 GB and more)default = "y" if unsloth_images_default(model, family, ram, gpu) else "n"- vision = "gpu" if ask("Do you want images?", ["y", "n"], default, a.yes) == "y" else "none"+ vision = flash_vision_encoder("yes", gpu) if ask("Do you want images?", ["y", "n"], default, a.yes) == "y" else "none"ok("images: " + {"none": "off", "gpu": "on", "cpu": "on (encoder on the CPU)"}[vision])if vision != "none" and MODELS[model].get("vision_untested"):warn(f"images with {model} are untested: users report them working, but we have not run this file with "diff --git a/tools/test_setup_golden.json b/tools/test_setup_golden.jsonindex 81fd9fa48..ad762c162 100644--- a/tools/test_setup_golden.json+++ b/tools/test_setup_golden.json@@ -678,10 +678,11 @@"tokenizer": "<T>/data/packs/unsloth-ud-q4_k_xl/tokenizer","vision": {"exe": "<T>/engine/strata-vision.exe",- "gpu": true,- "max_tokens": 1024,+ "gpu": false,+ "max_tokens": 300,"mmproj": "<T>/models/mmproj-Qwen3.8-Flash-Next-BF16.gguf",- "model": "<T>/models/unsloth-UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf"+ "model": "<T>/models/unsloth-UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf",+ "threads": 6}}},@@ -1117,10 +1118,11 @@"tokenizer": "<T>/data/packs/unsloth-ud-q4_k_xl/tokenizer","vision": {"exe": "<T>/engine/strata-vision.exe",- "gpu": true,- "max_tokens": 1024,+ "gpu": false,+ "max_tokens": 300,"mmproj": "<T>/models/mmproj-Qwen3.8-Flash-Next-BF16.gguf",- "model": "<T>/models/unsloth-UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf"+ "model": "<T>/models/unsloth-UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf",+ "threads": 6}}}diff --git a/tools/test_setup_menu.py b/tools/test_setup_menu.pyindex 0af405ca7..59ed91a95 100644--- a/tools/test_setup_menu.py+++ b/tools/test_setup_menu.py@@ -180,5 +180,29 @@ class KqLibrary(unittest.TestCase):self.assertEqual((eng / setup.KQ_LIB).read_bytes(), b"new kq")+class ImageEncoderDefault(unittest.TestCase):+ """#2406: "images: yes" gets the CPU encoder on an NVIDIA card under 24 GB (the GPU encoder cost 3-5% of text speed on+ 16 GB cards, 35-60% on an RTX 4080 SUPER under Windows); --vision gpu is kept with a note."""++ def test_yes_follows_the_card(self):+ f = setup.flash_vision_encoder+ self.assertEqual(f("yes", {"vram_gb": 12.0}), "cpu")+ self.assertEqual(f("yes", {"vram_gb": 15.9}), "cpu")+ self.assertEqual(f("yes", {"vram_gb": 24.0}), "gpu")+ self.assertEqual(f("yes", {"vram_gb": 32.0}), "gpu")+ self.assertEqual(f("yes", {}), "gpu") # unknown VRAM: the old default+ self.assertEqual(f("cpu", {"vram_gb": 32.0}), "cpu")+ self.assertEqual(f("none", {"vram_gb": 16.0}), "none")++ def test_gpu_asked_is_kept_with_a_note(self):+ import contextlib, io+ out = io.StringIO()+ with contextlib.redirect_stdout(out):+ self.assertEqual(setup.flash_vision_encoder("gpu", {"vram_gb": 16.0}), "gpu")+ self.assertEqual(setup.flash_vision_encoder("gpu", {"vram_gb": 32.0}), "gpu")+ self.assertEqual(out.getvalue().count("kept as you chose"), 1)+ self.assertIn("#2406", out.getvalue())++if __name__ == "__main__":unittest.main()