From 2f5347cb4de313811e732acfbb3135c5e1b77d2a Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sun, 15 Mar 2026 05:43:46 +0000 Subject: [PATCH] studio: sort GGUF quant variants -- recommended first, then UD by size, then standard by size The variants list was returned in HuggingFace file listing order (alphabetical), making the dropdown confusing (e.g. BF16 before Q4_0). Now sorted as: 1. Recommended variant (from _pick_best_gguf) pinned at top 2. Other UD (Unsloth Dynamic) variants sorted by disk size ascending 3. Non-UD variants sorted by disk size ascending --- studio/backend/utils/models/model_config.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/studio/backend/utils/models/model_config.py b/studio/backend/utils/models/model_config.py index cd0eb106b8..f5b8dfc823 100644 --- a/studio/backend/utils/models/model_config.py +++ b/studio/backend/utils/models/model_config.py @@ -962,6 +962,18 @@ def list_gguf_variants( ) ) + # Sort: recommended first, then UD variants by size, then non-UD by size. + best_file = _pick_best_gguf([v.filename for v in variants]) + best_quant = _extract_quant_label(best_file) if best_file else None + + def _sort_key(v: GgufVariantInfo) -> tuple: + is_recommended = v.quant == best_quant + is_ud = v.quant.startswith("UD-") + # (0, ...) recommended | (1, 0, size) other UD | (1, 1, size) non-UD + return (0 if is_recommended else 1, 0 if is_ud else 1, v.size_bytes) + + variants.sort(key=_sort_key) + return variants, has_vision