MCPcopy Index your code
hub / github.com/microsoft/BitNet / write_all

Method write_all

utils/convert.py:1245–1272  ·  view source on GitHub ↗
(
        fname_out: Path, ftype: GGMLFileType, params: Params, model: LazyModel, vocab: BaseVocab, svocab: gguf.SpecialVocab,
        concurrency: int = DEFAULT_CONCURRENCY, endianess: gguf.GGUFEndian = gguf.GGUFEndian.LITTLE,
        pad_vocab: bool = False,
    )

Source from the content-addressed store, hash-verified

1243
1244 @staticmethod
1245 def write_all(
1246 fname_out: Path, ftype: GGMLFileType, params: Params, model: LazyModel, vocab: BaseVocab, svocab: gguf.SpecialVocab,
1247 concurrency: int = DEFAULT_CONCURRENCY, endianess: gguf.GGUFEndian = gguf.GGUFEndian.LITTLE,
1248 pad_vocab: bool = False,
1249 ) -> None:
1250 check_vocab_size(params, vocab, pad_vocab=pad_vocab)
1251
1252 of = OutputFile(fname_out, endianess=endianess)
1253
1254 # meta data
1255 of.add_meta_arch(params)
1256 if isinstance(vocab, Vocab):
1257 of.add_meta_vocab(vocab)
1258 of.add_meta_special_vocab(svocab)
1259 else: # NoVocab
1260 of.gguf.add_tokenizer_model(vocab.tokenizer_model)
1261
1262 # tensor info
1263 for name, lazy_tensor in model.items():
1264 of.add_tensor_info(name, lazy_tensor)
1265
1266 of.write_meta()
1267 of.write_tensor_info()
1268
1269 # tensor data
1270 of.write_tensor_data(ftype, model, concurrency)
1271
1272 of.close()
1273
1274
1275def pick_output_type(model: LazyModel, output_type_str: str | None) -> GGMLFileType:

Callers 1

mainFunction · 0.45

Calls 10

add_meta_archMethod · 0.95
add_meta_vocabMethod · 0.95
add_tensor_infoMethod · 0.95
write_metaMethod · 0.95
write_tensor_infoMethod · 0.95
write_tensor_dataMethod · 0.95
closeMethod · 0.95
check_vocab_sizeFunction · 0.70
OutputFileClass · 0.70

Tested by

no test coverage detected