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
This commit is contained in:
Daniel Han 2026-03-15 05:43:46 +00:00
commit 2f5347cb4d

View file

@ -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