|
1 | 1 | #!/usr/bin/env python3
|
2 |
| -import sys, struct, math, argparse |
3 |
| -from pathlib import Path |
| 2 | +from __future__ import annotations |
4 | 3 |
|
5 |
| -import numpy as np |
| 4 | +import argparse |
| 5 | +import math |
| 6 | +import struct |
| 7 | +import sys |
| 8 | +from pathlib import Path |
6 | 9 |
|
7 | 10 | import gguf
|
| 11 | +import numpy as np |
8 | 12 |
|
9 | 13 | # Note: Does not support GGML_QKK_64
|
10 | 14 | QK_K = 256
|
@@ -72,7 +76,7 @@ def load(self, data, offset, n_vocab):
|
72 | 76 | class Tensor:
|
73 | 77 | def __init__(self):
|
74 | 78 | self.name = None
|
75 |
| - self.dims = () |
| 79 | + self.dims: tuple[int, ...] = () |
76 | 80 | self.dtype = None
|
77 | 81 | self.start_offset = 0
|
78 | 82 | self.len_bytes = np.int64(0)
|
@@ -119,7 +123,7 @@ def load(self, data, offset):
|
119 | 123 | offset += hp.load(data, offset)
|
120 | 124 | vocab = Vocab()
|
121 | 125 | offset += vocab.load(data, offset, hp.n_vocab)
|
122 |
| - tensors = [] |
| 126 | + tensors: list[Tensor] = [] |
123 | 127 | tensor_map = {}
|
124 | 128 | while offset < len(data):
|
125 | 129 | tensor = Tensor()
|
@@ -305,8 +309,8 @@ def handle_metadata(cfg, hp):
|
305 | 309 |
|
306 | 310 | def handle_args():
|
307 | 311 | parser = argparse.ArgumentParser(description = 'Convert GGMLv3 models to GGUF')
|
308 |
| - parser.add_argument('--input', '-i', type = Path, help = 'Input GGMLv3 filename') |
309 |
| - parser.add_argument('--output', '-o', type = Path, help ='Output GGUF filename') |
| 312 | + parser.add_argument('--input', '-i', type = Path, required = True, help = 'Input GGMLv3 filename') |
| 313 | + parser.add_argument('--output', '-o', type = Path, required = True, help ='Output GGUF filename') |
310 | 314 | parser.add_argument('--name', help = 'Set model name')
|
311 | 315 | parser.add_argument('--desc', help = 'Set model description')
|
312 | 316 | parser.add_argument('--gqa', type = int, default = 1, help = 'grouped-query attention factor (use 8 for LLaMA2 70B)')
|
|
0 commit comments