From 40a112c8b75753e2d74fe4bc6a89bc00bcaf1e26 Mon Sep 17 00:00:00 2001 From: KingManiya Date: Tue, 21 Apr 2026 00:57:41 +0400 Subject: [PATCH] fix(cli): normalize max seed. v0.3.1 --- llama_cli.py | 14 +++++++++++++- nodes.py | 3 ++- pyproject.toml | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/llama_cli.py b/llama_cli.py index 6dbaad5..d2bae30 100644 --- a/llama_cli.py +++ b/llama_cli.py @@ -22,6 +22,9 @@ MMPROJ_EMBEDDING_MISMATCH_RE = re.compile( ) START_THINKING = "[Start thinking]" END_THINKING = "[End thinking]" +LLAMA_RANDOM_SEED = -1 +LLAMA_SEED_MODULUS = 2**32 +MAX_LLAMA_SEED = LLAMA_SEED_MODULUS - 1 def tensor_to_temp_png(image) -> Path: @@ -59,6 +62,15 @@ def split_extra_args(extra_args: str) -> list[str]: return [part.strip("\"'") for part in parts] +def normalize_llama_seed(seed: int) -> int: + seed = int(seed) + if seed == LLAMA_RANDOM_SEED: + return LLAMA_RANDOM_SEED + if 0 <= seed <= MAX_LLAMA_SEED: + return seed + return seed % LLAMA_SEED_MODULUS + + def build_command( model_path: Path, mmproj_path: Path | None, @@ -99,7 +111,7 @@ def build_command( "--top-k", str(top_k), "--repeat-penalty", str(repeat_penalty), "-c", str(ctx_size), - "--seed", str(seed), + "--seed", str(normalize_llama_seed(seed)), "--single-turn", "--reasoning", reasoning, ] diff --git a/nodes.py b/nodes.py index 8baef8e..1f8a8c4 100644 --- a/nodes.py +++ b/nodes.py @@ -10,6 +10,7 @@ from .folder_registry import ( system_prompt_options, ) from .llama_cli import ( + MAX_LLAMA_SEED, build_command, run_llama_cli, split_extra_args, @@ -104,7 +105,7 @@ class QwenGGUF: "seed": ("INT", { "default": 1, "min": -1, - "max": 2**32 - 1, # MAX_LLAMA_SEED + "max": MAX_LLAMA_SEED, "tooltip": "Random seed. Use -1 for a random seed.", }), "timeout_seconds": ("INT", { diff --git a/pyproject.toml b/pyproject.toml index f39b561..1691a1f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "ComfyUI-Qwen-gguf" description = "Run Qwen3-VL, Qwen3.5, and Qwen3.6 GGUF models in ComfyUI with llama.cpp." -version = "0.3.0" +version = "0.3.1" license = {file = "LICENSE"} dependencies = ["numpy", "Pillow"]