Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Fix false ONNX rejection for models with native weights (#11695)

Wasim Yousef Said89ed32d6ee5d
diff --git a/studio/frontend/src/features/hub/hooks/use-hub-model-search.ts b/studio/frontend/src/features/hub/hooks/use-hub-model-search.ts
index d9015685193..319b31c1273 100644
--- a/studio/frontend/src/features/hub/hooks/use-hub-model-search.ts
+++ b/studio/frontend/src/features/hub/hooks/use-hub-model-search.ts
@@ -26,7 +26,6 @@ import {
type UnslothSupport,
type UnslothSupportStatus,
classifyUnslothSupport,
- excludedFormatTagsForDevice,
} from "../lib/unsloth-support";
import { pullBatch, useHubPaginatedSearch } from "./use-hub-paginated-search";
@@ -164,7 +163,6 @@ function makeSortFetch(
function makeMapModel(
excludeGguf: boolean,
- excludedTags: ReadonlySet<string>,
keepUnsupportedTags: boolean,
idSuffix: string,
deviceType: string | null,
@@ -192,13 +190,6 @@ function makeMapModel(
return null;
}
const isEmbedding = m.tags?.some((t) => EMBEDDING_TAGS.has(t));
- if (
- !keepUnsupportedTags &&
- !isEmbedding &&
- m.tags?.some((t) => excludedTags.has(t))
- ) {
- return null;
- }
// A repo cross-tagged "gguf" that is actually a diffusers pipeline (e.g. an unsloth *-bnb-4bit image model) ships no .gguf files, so the variant
// expander would dead-end at "No GGUF variants found." Trust the bare tag only when the repo is not a pipeline; "-GGUF" and real metadata still win.
const isDiffusersPipeline =
@@ -569,7 +560,6 @@ export async function fetchChannelFirstPage(
} = options;
const mapModel = makeMapModel(
excludeGguf,
- excludedFormatTagsForDevice(deviceType),
keepUnsupportedTags,
channel.idSuffix ?? "",
deviceType,
@@ -779,19 +769,16 @@ export function useHubModelSearch(
);
const deviceType = usePlatformStore((s) => s.deviceType);
- const excludedTags = excludedFormatTagsForDevice(deviceType);
const mapModel = useMemo(
() =>
makeMapModel(
excludeGguf,
- excludedTags,
keepUnsupportedTags,
channelIdSuffix,
deviceType,
),
[
excludeGguf,
- excludedTags,
keepUnsupportedTags,
channelIdSuffix,
deviceType,
diff --git a/studio/frontend/src/features/hub/lib/unsloth-support.ts b/studio/frontend/src/features/hub/lib/unsloth-support.ts
index ca471cd74e0..46cfae6c6d4 100644
--- a/studio/frontend/src/features/hub/lib/unsloth-support.ts
+++ b/studio/frontend/src/features/hub/lib/unsloth-support.ts
@@ -96,13 +96,6 @@ const FORMAT_NAME_PATTERNS: ReadonlyArray<{ key: string; pattern: RegExp }> = [
{ key: "ctranslate2", pattern: /(?:^|[-_./])ctranslate2(?:$|[-_./])/i },
];
-const SUPPORTED_QUANT_METHODS: ReadonlySet<string> = new Set([
- "bitsandbytes",
- "bnb",
- "bnb_4bit",
- "bnb_8bit",
-]);
-
const UNSUPPORTED_QUANT_METHODS: Record<string, string> = {
awq: "AWQ quantization",
gptq: "GPTQ quantization",
@@ -178,22 +171,39 @@ function repoLeaf(modelId: string): string {
return parts.at(-1) ?? modelId;
}
-function detectFormatKey(
+// A hub repo's format tags describe every artifact it ships, and native checkpoints
+// routinely coexist with optional ONNX/OpenVINO/TF Lite/Core ML exports
+// (openai-community/gpt2 carries both pytorch and tflite). Those export tags alone must not
+// hide the repo, while quantization, runtime formats and export-only repos stay rejected.
+const EXPORT_FORMAT_TAGS: ReadonlySet<string> = new Set([
+ "onnx",
+ "openvino",
+ "tflite",
+ "coreml",
+]);
+
+function detectUnsupportedFormatKey(
modelId: string | null | undefined,
lowerTags: ReadonlySet<string>,
+ excludedFormats: ReadonlySet<string>,
): string | null {
+ const hasNativeWeights = lowerTags.has("pytorch") || lowerTags.has("safetensors");
for (const tag of lowerTags) {
- if (FORMAT_TAG_LABEL[tag]) return tag;
+ if (hasNativeWeights && EXPORT_FORMAT_TAGS.has(tag)) continue;
+ if (FORMAT_TAG_LABEL[tag]) {
+ if (excludedFormats.has(tag)) return tag;
+ continue;
+ }
const alias = FORMAT_ALIAS_TAGS[tag];
- if (alias) return alias;
+ if (alias && excludedFormats.has(alias)) return alias;
}
if (modelId) {
// Owner implies format even when local metadata lacks tags; mirrors the
// backend's _looks_like_mlx_repo heuristic.
- if (modelId.trim().toLowerCase().startsWith("mlx-community/")) return "mlx";
+ if (excludedFormats.has("mlx") && modelId.trim().toLowerCase().startsWith("mlx-community/")) return "mlx";
const name = repoLeaf(modelId);
for (const { key, pattern } of FORMAT_NAME_PATTERNS) {
- if (pattern.test(name)) return key;
+ if (excludedFormats.has(key) && pattern.test(name)) return key;
}
}
return null;
@@ -230,9 +240,6 @@ export function classifyUnslothSupport({
(modelId ? /(?:^|[-_.])gguf$/i.test(repoLeaf(modelId)) : false);
if (normalizedQuant && !isGguf) {
- if (SUPPORTED_QUANT_METHODS.has(normalizedQuant)) {
- return { status: "supported", reason: null };
- }
if (Object.hasOwn(UNSUPPORTED_QUANT_METHODS, normalizedQuant)) {
return {
status: "unsupported",
@@ -263,8 +270,8 @@ export function classifyUnslothSupport({
reason: `Library: ${library}.`,
};
}
- const formatKey = detectFormatKey(modelId, lowerTags);
- if (formatKey && formatTags.has(formatKey)) {
+ const formatKey = detectUnsupportedFormatKey(modelId, lowerTags, formatTags);
+ if (formatKey) {
const label = FORMAT_TAG_LABEL[formatKey] ?? `${formatKey.toUpperCase()} weights`;
return {
status: "unsupported",
diff --git a/studio/frontend/tests/hub-search-mixed-formats.test.ts b/studio/frontend/tests/hub-search-mixed-formats.test.ts
new file mode 100644
index 00000000000..b4a49588dad
--- /dev/null
+++ b/studio/frontend/tests/hub-search-mixed-formats.test.ts
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import test from "node:test";
+import ts from "typescript";
+import { classifyUnslothSupport } from "../src/features/hub/lib/unsloth-support.ts";
+
+// Execute the production mapper without loading React, the Hub client or the network hooks.
+const source = readFileSync(
+ new URL("../src/features/hub/hooks/use-hub-model-search.ts", import.meta.url),
+ "utf8",
+);
+const start = source.indexOf("function makeMapModel(");
+assert.notEqual(start, -1);
+const end = source.indexOf("\n}\n", start) + 2;
+const makeMapModel = new Function(
+ "classifyUnslothSupport", "EMBEDDING_TAGS", "isGgufLike", "estimateSizeFromDtypes", "detectBaseModel",
+ ts.transpileModule(source.slice(start, end), { compilerOptions: { target: ts.ScriptTarget.ES2022 } }).outputText +
+ "; return makeMapModel;",
+)(
+ classifyUnslothSupport,
+ new Set(["feature-extraction", "sentence-transformers", "sentence-similarity", "text-embeddings-inference", "embeddings"]),
+ (id: string) => id.endsWith("-GGUF"),
+ () => undefined,
+ () => null,
+);
+
+// Tag sets as the Hub API returns them for these repositories.
+const GPT2 = ["pytorch", "tf", "jax", "tflite", "onnx", "safetensors"];
+const MINILM = ["pytorch", "tf", "rust", "onnx", "safetensors", "openvino"];
+
+for (const device of ["mac", "cuda"]) {
+ const map = makeMapModel(false, false, "", device);
+
+ test(`${device}: search keeps native models with optional exports`, () => {
+ for (const raw of [
+ { name: "openai-community/gpt2", tags: GPT2 },
+ { name: "sentence-transformers/all-MiniLM-L6-v2", tags: MINILM },
+ { name: "owner/model", tags: ["onnx", "openvino", "tflite", "coreml", "safetensors"] },
+ ]) {
+ assert.equal(map(raw)?.id, raw.name);
+ }
+ });
+
+ test(`${device}: search still rejects export-only and quantized models`, () => {
+ for (const format of ["onnx", "openvino", "tflite", "coreml", "gptq", "awq"]) {
+ assert.equal(map({ name: "owner/model", tags: [format] }), null);
+ assert.equal(map({ name: `owner/model-${format}`, tags: [format, "tf"] }), null);
+ }
+ assert.equal(
+ map({ name: "owner/model", tags: ["onnx", "safetensors"], config: { quantization_config: { quant_method: "gptq" } } }),
+ null,
+ );
+ });
+
+ test(`${device}: discover and embeddings keep their existing exceptions`, () => {
+ const discover = makeMapModel(false, true, "", device);
+ assert.ok(discover({ name: "owner/model", tags: ["onnx"] }));
+ assert.ok(map({ name: "owner/embedding", tags: ["sentence-transformers", "onnx"] }));
+ });
+}
+
+for (const device of ["mac", "cuda"]) {
+ test(`${device}: supported quantization does not bypass export rejection`, () => {
+ const map = makeMapModel(false, false, "", device);
+ for (const quant_method of ["bitsandbytes", "bnb", "bnb_4bit", "bnb_8bit"]) {
+ for (const format of ["onnx", "openvino", "tflite", "coreml"]) {
+ const config = { quantization_config: { quant_method } };
+ assert.equal(map({ name: "owner/model", tags: [format], config }), null);
+ assert.ok(map({ name: "openai-community/gpt2", tags: [...GPT2, format], config }));
+ }
+ }
+ });
+}
diff --git a/studio/frontend/tests/unsloth-support-mixed-formats.test.ts b/studio/frontend/tests/unsloth-support-mixed-formats.test.ts
new file mode 100644
index 00000000000..2f9996feeec
--- /dev/null
+++ b/studio/frontend/tests/unsloth-support-mixed-formats.test.ts
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import assert from "node:assert/strict";
+import test from "node:test";
+import { classifyUnslothSupport } from "../src/features/hub/lib/unsloth-support.ts";
+
+// Tag sets as the Hub API returns them for these repositories.
+const GPT2 = ["pytorch", "tf", "jax", "tflite", "onnx", "safetensors"];
+const MINILM = ["pytorch", "tf", "rust", "onnx", "safetensors", "openvino"];
+
+for (const deviceType of ["mac", "cuda"]) {
+ for (const native of ["pytorch", "safetensors"]) {
+ test(`${deviceType}: native ${native} weights coexist with export tags`, () => {
+ for (const exportTag of ["onnx", "openvino", "tflite", "coreml"]) {
+ const tags = [...GPT2, native, exportTag];
+ assert.deepEqual(
+ classifyUnslothSupport({ modelId: "openai-community/gpt2", tags, deviceType }),
+ { status: "supported", reason: null },
+ );
+ assert.deepEqual(
+ classifyUnslothSupport({
+ modelId: "sentence-transformers/all-MiniLM-L6-v2",
+ pipelineTag: "sentence-similarity",
+ tags: [...MINILM, exportTag],
+ deviceType,
+ }),
+ { status: "supported", reason: null },
+ );
+ }
+ });
+ }
+
+ for (const format of ["onnx", "openvino", "tflite", "coreml"]) {
+ test(`${deviceType}: export-only ${format} stays rejected`, () => {
+ assert.equal(classifyUnslothSupport({ tags: [format], deviceType }).status, "unsupported");
+ assert.equal(
+ classifyUnslothSupport({ modelId: `owner/model-${format}`, tags: [format], deviceType }).status,
+ "unsupported",
+ );
+ // A name alone must not excuse a repo with no native weights.
+ assert.equal(
+ classifyUnslothSupport({ modelId: "owner/model-onnx", tags: ["onnx", "openvino"], deviceType }).status,
+ "unsupported",
+ );
+ });
+ }
+
+ for (const format of ["gptq", "awq", "exl2"]) {
+ test(`${deviceType}: native tags do not bypass ${format}`, () => {
+ const result = classifyUnslothSupport({
+ tags: [...GPT2, format],
+ deviceType,
+ });
+ assert.equal(result.status, "unsupported");
+ assert.doesNotMatch(result.reason!, /ONNX/);
+ });
+ }
+
+ test(`${deviceType}: quantization config still takes precedence`, () => {
+ assert.deepEqual(
+ classifyUnslothSupport({ tags: ["onnx", "pytorch", "safetensors"], quantMethod: "gptq", deviceType }),
+ { status: "unsupported", reason: "Detected GPTQ quantization." },
+ );
+ });
+
+ test(`${deviceType}: supported quantization does not excuse export-only repos`, () => {
+ for (const quantMethod of ["bitsandbytes", "bnb", "bnb_4bit", "bnb_8bit"]) {
+ assert.equal(
+ classifyUnslothSupport({ modelId: "owner/model-onnx", tags: ["onnx"], quantMethod, deviceType }).status,
+ "unsupported",
+ );
+ assert.equal(
+ classifyUnslothSupport({ tags: ["onnx", "safetensors"], quantMethod, deviceType }).status,
+ "supported",
+ );
+ }
+ });
+}
+
+test("native storage tags do not make MLX weights GPU compatible", () => {
+ assert.equal(
+ classifyUnslothSupport({
+ modelId: "mlx-community/model", tags: ["onnx", "safetensors"], deviceType: "cuda",
+ }).status,
+ "unsupported",
+ );
+});
+
+for (const format of ["gptq", "awq", "exl2"]) {
+ test(`Mac-compatible MLX tags do not hide ${format}`, () => {
+ for (const tags of [["safetensors", "onnx", "mlx", format], [format, "mlx", "safetensors", "onnx"]]) {
+ assert.equal(classifyUnslothSupport({ tags, deviceType: "mac" }).status, "unsupported");
+ }
+ assert.equal(
+ classifyUnslothSupport({ modelId: `owner/model-${format}`, tags: ["safetensors", "onnx", "mlx"], deviceType: "mac" }).status,
+ "unsupported",
+ );
+ });
+}
+
+test("MLX remains compatible with Mac for a repo with native weights and exports", () => {
+ for (const tags of [
+ ["safetensors", "onnx", "mlx"],
+ ["safetensors", "onnx", "mlx", "coreml", "tflite"],
+ ]) {
+ assert.equal(classifyUnslothSupport({ tags, deviceType: "mac" }).status, "supported");
+ }
+});
+test("MLX remains compatible with Mac without an unsupported format", () => {
+ assert.equal(classifyUnslothSupport({ tags: ["safetensors", "onnx", "mlx"], deviceType: "mac" }).status, "supported");
+});