Skip to content

Commit 62c0762

Browse files
Fix GGUF quant label parsing for Unsloth Dynamic (UD) prefixed filenames (#1975)
## Summary - GGUF filenames with the [Unsloth Dynamic "UD-" prefix ](https://unsloth.ai/docs/basics/unsloth-dynamic-2.0-ggufs)(e.g. `Qwen3-4B-UD-Q2_K_XL.gguf`) have their quant labels parsed, but the "UD-" prefix gets dropped — so `parseGGUFQuantLabel` returns `"Q2_K_XL"` instead of `"UD-Q2_K_XL"`. This means the "Hardware compatibility" section on model pages like https://huggingface.co/unsloth/Qwen3-4B-GGUF doesn't distinguish UD quants from regular ones. - Updates `GGUF_QUANT_RE` to capture an optional `(?<prefix>UD-)?` named group before the quant type, so `parseGGUFQuantLabel` now returns `"UD-Q2_K_XL"` preserving the full label. - Adds a test case in `gguf.spec.ts` for the UD-prefixed filename pattern. <img width="484" height="346" alt="image" src="https://github.com/user-attachments/assets/30e922ff-7000-49a0-acb8-a7cf69ef2d3e" /> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1b2db54 commit 62c0762

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/gguf/src/gguf.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ describe("gguf", () => {
289289
expect(parseGGUFQuantLabel("Codestral-22B-v0.1-F32-Q2_K.gguf")).toEqual("Q2_K"); // gguf name with two quant labels [F32, Q2_K]
290290
expect(parseGGUFQuantLabel("Codestral-22B-v0.1-IQ3_XS.gguf")).toEqual("IQ3_XS");
291291
expect(parseGGUFQuantLabel("Codestral-22B-v0.1-Q4_0_4_4.gguf")).toEqual("Q4_0"); // TODO: investigate Q4_0_4_4
292+
expect(parseGGUFQuantLabel("Qwen3-4B-UD-Q2_K_XL.gguf")).toEqual("UD-Q2_K_XL"); // unsloth UD (Unsloth Dynamic) prefix
292293
});
293294

294295
it("calculate tensor data offset", async () => {

packages/tasks/src/gguf.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ export enum GGMLFileQuantizationType {
5353
}
5454

5555
const ggufQuants = Object.values(GGMLFileQuantizationType).filter((v): v is string => typeof v === "string");
56-
export const GGUF_QUANT_RE = new RegExp(`(?<quant>${ggufQuants.join("|")})` + "(_(?<sizeVariation>[A-Z]+))?");
56+
export const GGUF_QUANT_RE = new RegExp(
57+
"(?<prefix>UD-)?" + `(?<quant>${ggufQuants.join("|")})` + "(_(?<sizeVariation>[A-Z]+))?",
58+
);
5759
export const GGUF_QUANT_RE_GLOBAL = new RegExp(GGUF_QUANT_RE, "g");
5860

5961
export function parseGGUFQuantLabel(fname: string): string | undefined {

0 commit comments

Comments
 (0)