Skip to content

Commit e841a53

Browse files
CISCngxson
andauthored
Add MXFP4 GGUF QuantizationType (#1677)
Added in GPT-OSS PR ggml-org/llama.cpp#15091 --------- Co-authored-by: Xuan-Son Nguyen <[email protected]>
1 parent 96f1bc5 commit e841a53

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

packages/gguf/src/gguf.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ describe("gguf", () => {
294294

295295
// Quantization handler
296296

297-
it("should have GGUF_QUANT_ORDER in sync with GGMLQuantizationType enum", () => {
298-
const enumValues = Object.values(GGMLQuantizationType).filter((value) => typeof value === "number") as number[];
297+
it("should have GGUF_QUANT_ORDER in sync with GGMLFileQuantizationType enum", () => {
298+
const enumValues = Object.values(GGMLFileQuantizationType).filter((value) => typeof value === "number") as number[];
299299
const checkValues = new Set(GGUF_QUANT_ORDER);
300300
for (const value of enumValues) {
301301
expect(checkValues).toContain(value);

packages/gguf/src/quant-descriptions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ export const GGUF_QUANT_DESCRIPTIONS: Record<GGMLQuantizationType, { txt: string
132132
txt: "Ternary quantization.",
133133
src_url: "https://github.com/ggml-org/llama.cpp/pull/8151",
134134
},
135+
[GGMLQuantizationType.MXFP4]: {
136+
txt: "4-bit Microscaling Block Floating Point.",
137+
src_url: "https://github.com/ggml-org/llama.cpp/pull/15091",
138+
},
135139
};
136140

137141
const QK_K = 256;
@@ -173,4 +177,5 @@ export const GGML_QUANT_SIZES = {
173177
[GGMLQuantizationType.BF16]: calcBPW(1, 2),
174178
[GGMLQuantizationType.TQ1_0]: calcBPW(256, 2 + 4 * 13),
175179
[GGMLQuantizationType.TQ2_0]: calcBPW(256, 2 + 64),
180+
[GGMLQuantizationType.MXFP4]: calcBPW(32, 1 + 16),
176181
};

packages/tasks/src/gguf.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export enum GGMLFileQuantizationType {
4040
Q4_0_8_8 = 35,
4141
TQ1_0 = 36,
4242
TQ2_0 = 37,
43+
MXFP4_MOE = 38,
4344

4445
// custom quants used by unsloth
4546
// they are not officially a scheme enum value in GGUF, but only here for naming
@@ -95,6 +96,7 @@ export const GGUF_QUANT_ORDER: GGMLFileQuantizationType[] = [
9596
GGMLFileQuantizationType.Q4_1,
9697
GGMLFileQuantizationType.Q4_2,
9798
GGMLFileQuantizationType.Q4_3,
99+
GGMLFileQuantizationType.MXFP4_MOE,
98100

99101
// 3-bit quantizations
100102
GGMLFileQuantizationType.Q3_K_XL,
@@ -197,4 +199,5 @@ export enum GGMLQuantizationType {
197199
BF16 = 30,
198200
TQ1_0 = 34,
199201
TQ2_0 = 35,
202+
MXFP4 = 39,
200203
}

0 commit comments

Comments
 (0)