Views
No views yet
mmproj-BF16.gguf), Apache 2.0.| Tensor type | Quantization | Count |
|---|---|---|
attn_out.weight, attn_qkv.weight, ffn_up.weight, mm.0.weight, mm.2.weight | Q8_0 | 83 |
ffn_down.weight | F16 | 27 |
| Biases, norms, embeddings, positional | F32 | 224 |
| Total | 334 |
clip.vision.image_size = 768
clip.vision.patch_size = 16
clip.vision.embedding_length = 1152
clip.vision.feed_forward_length = 4304
clip.vision.block_count = 27
clip.vision.head_count = 16
clip.vision.projection_dim = 5120
clip.projector_type = qwen3vl_merger1llama-server \
2 --model Qwen3.6-27B-UD-Q4_K_XL.gguf \
3 --mmproj Qwen3.6-27B-mmproj-hybrid-Q8_0-F16.gguf \
4 --ctx-size 131072 \
5 --n-gpu-layers 65 \
6 --cache-type-k q4_0 \
7 --jinja \
8 --skip-chat-parsing1"""
2Convert mmproj-BF16.gguf to hybrid Q8_0/F16 quantization.
3Source: unsloth/Qwen3.6-27B-GGUF
4"""
5import sys, numpy as np
6from pathlib import Path
7sys.path.insert(0, '/path/to/llama.cpp/gguf-py')
8from gguf import GGUFReader, GGUFWriter, GGMLQuantizationType
9from gguf.quants import quantize
10from gguf.constants import GGUFValueType
11
12SRC = 'mmproj-BF16.gguf'
13DST = 'Qwen3.6-27B-mmproj-hybrid-Q8_0-F16.gguf'
14Q8_BLOCK_ELEMS, Q8_BLOCK_BYTES = 32, 34
15
16def target_type(name):
17 if name.endswith('ffn_down.weight'): return GGMLQuantizationType.F16
18 if any(name.endswith(s) for s in (
19 'attn_out.weight','attn_qkv.weight','ffn_up.weight','mm.0.weight','mm.2.weight')):
20 return GGMLQuantizationType.Q8_0
21 return GGMLQuantizationType.F32
22
23def get_f32(tensor):
24 if tensor.tensor_type == GGMLQuantizationType.F32: return tensor.data
25 raw = tensor.data.view(np.uint16)
26 return (raw.astype(np.uint32) << 16).view(np.float32)
27
28def to_q8_0(data_f32):
29 orig_shape = data_f32.shape
30 flat = data_f32.flatten()
31 quantized = quantize(flat, GGMLQuantizationType.Q8_0)
32 if len(orig_shape) == 1: return quantized.reshape(1, -1)
33 H = int(np.prod(orig_shape[:-1]))
34 W_bytes = orig_shape[-1] // Q8_BLOCK_ELEMS * Q8_BLOCK_BYTES
35 return quantized.reshape(H, W_bytes)
36
37reader = GGUFReader(SRC)
38writer = GGUFWriter(DST, arch='clip')
39
40# Copy scalar metadata
41for key, field in reader.fields.items():
42 if key.startswith('GGUF.'): continue
43 # ... (see full script in convert_mmproj_hybrid.py)
44
45# Arrays — must be added explicitly
46writer.add_array('clip.vision.image_mean', [0.5, 0.5, 0.5])
47writer.add_array('clip.vision.image_std', [0.5, 0.5, 0.5])
48writer.add_array('clip.vision.is_deepstack_layers', [False] * 27)
49writer.add_string('general.name', 'Qwen3.6 27B mmproj hybrid Q8_0-F16')
50
51for tensor in reader.tensors:
52 ttype = target_type(tensor.name)
53 data_f32 = get_f32(tensor)
54 if ttype == GGMLQuantizationType.F32:
55 writer.add_tensor(tensor.name, np.ascontiguousarray(data_f32), raw_dtype=ttype)
56 elif ttype == GGMLQuantizationType.F16:
57 writer.add_tensor(tensor.name, np.ascontiguousarray(data_f32.astype(np.float16)), raw_dtype=ttype)
58 elif ttype == GGMLQuantizationType.Q8_0:
59 writer.add_tensor(tensor.name, to_q8_0(data_f32), raw_dtype=ttype)
60
61writer.write_header_to_file()
62writer.write_kv_data_to_file()
63writer.write_tensors_to_file()
64writer.close()