Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

gguf: add the q2_0 tensor and file types (#18967)

Jeffrey Morgancc3cacf2a381
diff --git a/fs/gguf/file_type.go b/fs/gguf/file_type.go
index 0fe14c718..a372c363b 100644
--- a/fs/gguf/file_type.go
+++ b/fs/gguf/file_type.go
@@ -45,6 +45,7 @@ const (
fileTypeMXFP4MOE
fileTypeNVFP4
fileTypeQ1_0
+ fileTypeQ2_0
FileTypeUnknown FileType = 1024
)
@@ -121,6 +122,8 @@ func (t FileType) String() string {
return "NVFP4"
case fileTypeQ1_0:
return "Q1_0"
+ case fileTypeQ2_0:
+ return "Q2_0"
default:
return "unknown"
}
diff --git a/fs/gguf/gguf_internal_test.go b/fs/gguf/gguf_internal_test.go
index 6bc6c0527..799a4f2b7 100644
--- a/fs/gguf/gguf_internal_test.go
+++ b/fs/gguf/gguf_internal_test.go
@@ -136,6 +136,7 @@ func TestCurrentTensorTypes(t *testing.T) {
{value: TensorTypeMXFP4, number: 39, name: "mxfp4", blockSize: 32, typeSize: 17},
{value: TensorTypeNVFP4, number: 40, name: "nvfp4", blockSize: 64, typeSize: 36},
{value: TensorTypeQ1_0, number: 41, name: "q1_0", blockSize: 128, typeSize: 18},
+ {value: TensorTypeQ2_0, number: 42, name: "q2_0", blockSize: 64, typeSize: 18},
} {
t.Run(tt.name, func(t *testing.T) {
if got := uint32(tt.value); got != tt.number {
diff --git a/fs/gguf/tensor.go b/fs/gguf/tensor.go
index d1304e16e..51fae4662 100644
--- a/fs/gguf/tensor.go
+++ b/fs/gguf/tensor.go
@@ -151,6 +151,7 @@ const (
TensorTypeMXFP4
TensorTypeNVFP4
TensorTypeQ1_0
+ TensorTypeQ2_0
)
func (tt TensorType) NumBytes() float64 {
@@ -223,6 +224,8 @@ func (tt TensorType) typeSize() int64 {
return 4 + tt.blockSize()/2
case TensorTypeQ1_0:
return 2 + tt.blockSize()/8
+ case TensorTypeQ2_0:
+ return 2 + tt.blockSize()/4
default:
return 0
}
@@ -239,7 +242,7 @@ func (tt TensorType) blockSize() int64 {
TensorTypeF64,
TensorTypeBF16:
return 1
- case TensorTypeNVFP4:
+ case TensorTypeNVFP4, TensorTypeQ2_0:
return 64
case TensorTypeQ1_0:
return 128
@@ -343,6 +346,8 @@ func (tt TensorType) String() string {
return "nvfp4"
case TensorTypeQ1_0:
return "q1_0"
+ case TensorTypeQ2_0:
+ return "q2_0"
default:
return "unknown"
}