MCPcopy Create free account
hub / github.com/microsoft/BitNet / GGMLFileType

Class GGMLFileType

utils/convert.py:177–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175
176
177class GGMLFileType(enum.IntEnum):
178 AllF32 = 0
179 MostlyF16 = 1 # except 1d tensors
180 MostlyI2 = 2 # except 1d tensors
181 MostlyQ8_0 = 7 # except 1d tensors
182
183 def type_for_tensor(self, name: str, tensor: LazyTensor) -> DataType:
184 dt = GGML_FILE_TYPE_TO_DATA_TYPE.get(self)
185 if dt is None:
186 raise ValueError(self)
187 # Convert all 1D tensors to F32. Most of the codebase that takes in 1D tensors only handles F32 tensors, and most of the outputs tensors are F32.
188 # Also The 1d tensors aren't much of a performance/size issue. So instead of having to have separate F32 and F16 implementations of both, just convert everything to F32 for now.
189 dt = dt if len(tensor.shape) > 1 else DT_F32
190 if name == "token_embd.weight" or name == "output.weight":
191 dt = DT_F32
192 return dt
193
194
195GGML_FILE_TYPE_TO_DATA_TYPE: dict[GGMLFileType, DataType] = {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected