bigdl-core-cpp 2.5.0b20240725__py3-none-win_amd64.whl → 2.5.0b20240727__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. bigdl/cpp/convert-hf-to-gguf.py +1106 -320
  2. bigdl/cpp/gguf-py/gguf/__init__.py +2 -0
  3. bigdl/cpp/gguf-py/gguf/constants.py +442 -173
  4. bigdl/cpp/gguf-py/gguf/gguf.py +1 -1
  5. bigdl/cpp/gguf-py/gguf/gguf_reader.py +29 -8
  6. bigdl/cpp/gguf-py/gguf/gguf_writer.py +472 -156
  7. bigdl/cpp/gguf-py/gguf/lazy.py +24 -49
  8. bigdl/cpp/gguf-py/gguf/tensor_mapping.py +195 -23
  9. bigdl/cpp/libs/baby-llama.exe +0 -0
  10. bigdl/cpp/libs/batched-bench.exe +0 -0
  11. bigdl/cpp/libs/batched.exe +0 -0
  12. bigdl/cpp/libs/beam-search.exe +0 -0
  13. bigdl/cpp/libs/benchmark.exe +0 -0
  14. bigdl/cpp/libs/common.lib +0 -0
  15. bigdl/cpp/libs/convert-llama2c-to-ggml.exe +0 -0
  16. bigdl/cpp/libs/dist/windows-amd64/ollama_runners/cpu/ollama_llama_server.exe +0 -0
  17. bigdl/cpp/libs/dist/windows-amd64/ollama_runners/cpu_avx/ollama_llama_server.exe +0 -0
  18. bigdl/cpp/libs/dist/windows-amd64/ollama_runners/cpu_avx2/ollama_llama_server.exe +0 -0
  19. bigdl/cpp/libs/embedding.exe +0 -0
  20. bigdl/cpp/libs/export-lora.exe +0 -0
  21. bigdl/cpp/libs/finetune.exe +0 -0
  22. bigdl/cpp/libs/ggml_shared.dll +0 -0
  23. bigdl/cpp/libs/gguf.exe +0 -0
  24. bigdl/cpp/libs/gritlm.exe +0 -0
  25. bigdl/cpp/libs/imatrix.exe +0 -0
  26. bigdl/cpp/libs/infill.exe +0 -0
  27. bigdl/cpp/libs/llama-bench.exe +0 -0
  28. bigdl/cpp/libs/llama.dll +0 -0
  29. bigdl/cpp/libs/llava-cli.exe +0 -0
  30. bigdl/cpp/libs/llava_shared.dll +0 -0
  31. bigdl/cpp/libs/lookahead.exe +0 -0
  32. bigdl/cpp/libs/lookup.exe +0 -0
  33. bigdl/cpp/libs/ls-sycl-device.exe +0 -0
  34. bigdl/cpp/libs/main.exe +0 -0
  35. bigdl/cpp/libs/ollama.exe +0 -0
  36. bigdl/cpp/libs/parallel.exe +0 -0
  37. bigdl/cpp/libs/passkey.exe +0 -0
  38. bigdl/cpp/libs/perplexity.exe +0 -0
  39. bigdl/cpp/libs/q8dot.exe +0 -0
  40. bigdl/cpp/libs/quantize-stats.exe +0 -0
  41. bigdl/cpp/libs/quantize.exe +0 -0
  42. bigdl/cpp/libs/save-load-state.exe +0 -0
  43. bigdl/cpp/libs/server.exe +0 -0
  44. bigdl/cpp/libs/simple.exe +0 -0
  45. bigdl/cpp/libs/speculative.exe +0 -0
  46. bigdl/cpp/libs/tokenize.exe +0 -0
  47. bigdl/cpp/libs/train-text-from-scratch.exe +0 -0
  48. bigdl/cpp/libs/vdot.exe +0 -0
  49. {bigdl_core_cpp-2.5.0b20240725.dist-info → bigdl_core_cpp-2.5.0b20240727.dist-info}/METADATA +1 -1
  50. bigdl_core_cpp-2.5.0b20240727.dist-info/RECORD +61 -0
  51. bigdl_core_cpp-2.5.0b20240725.dist-info/RECORD +0 -61
  52. {bigdl_core_cpp-2.5.0b20240725.data → bigdl_core_cpp-2.5.0b20240727.data}/scripts/init-llama-cpp.bat +0 -0
  53. {bigdl_core_cpp-2.5.0b20240725.data → bigdl_core_cpp-2.5.0b20240727.data}/scripts/init-llama-cpp.ps1 +0 -0
  54. {bigdl_core_cpp-2.5.0b20240725.data → bigdl_core_cpp-2.5.0b20240727.data}/scripts/init-ollama.bat +0 -0
  55. {bigdl_core_cpp-2.5.0b20240725.dist-info → bigdl_core_cpp-2.5.0b20240727.dist-info}/WHEEL +0 -0
  56. {bigdl_core_cpp-2.5.0b20240725.dist-info → bigdl_core_cpp-2.5.0b20240727.dist-info}/top_level.txt +0 -0
@@ -12,4 +12,4 @@ sys.path.insert(0, str(Path(__file__).parent.parent))
12
12
  importlib.invalidate_caches()
13
13
  import gguf # noqa: E402
14
14
 
15
- importlib.reload(gguf)
15
+ importlib.reload(gguf)
@@ -67,8 +67,9 @@ class ReaderTensor(NamedTuple):
67
67
 
68
68
  class GGUFReader:
69
69
  # I - same as host, S - swapped
70
- byte_order: Literal['I'] | Literal['S'] = 'I'
70
+ byte_order: Literal['I', 'S'] = 'I'
71
71
  alignment: int = GGUF_DEFAULT_ALIGNMENT
72
+ data_offset: int
72
73
 
73
74
  # Note: Internal helper, API may change.
74
75
  gguf_scalar_to_np: dict[GGUFValueType, type[np.generic]] = {
@@ -85,12 +86,16 @@ class GGUFReader:
85
86
  GGUFValueType.BOOL: np.bool_,
86
87
  }
87
88
 
88
- def __init__(self, path: os.PathLike[str] | str, mode: Literal['r'] | Literal['r+'] | Literal['c'] = 'r'):
89
+ def __init__(self, path: os.PathLike[str] | str, mode: Literal['r', 'r+', 'c'] = 'r'):
89
90
  self.data = np.memmap(path, mode = mode)
90
91
  offs = 0
92
+
93
+ # Check for GGUF magic
91
94
  if self._get(offs, np.uint32, override_order = '<')[0] != GGUF_MAGIC:
92
95
  raise ValueError('GGUF magic invalid')
93
96
  offs += 4
97
+
98
+ # Check GGUF version
94
99
  temp_version = self._get(offs, np.uint32)
95
100
  if temp_version[0] & 65535 == 0:
96
101
  # If we get 0 here that means it's (probably) a GGUF file created for
@@ -103,12 +108,16 @@ class GGUFReader:
103
108
  self.fields: OrderedDict[str, ReaderField] = OrderedDict()
104
109
  self.tensors: list[ReaderTensor] = []
105
110
  offs += self._push_field(ReaderField(offs, 'GGUF.version', [temp_version], [0], [GGUFValueType.UINT32]))
111
+
112
+ # Check tensor count and kv count
106
113
  temp_counts = self._get(offs, np.uint64, 2)
107
114
  offs += self._push_field(ReaderField(offs, 'GGUF.tensor_count', [temp_counts[:1]], [0], [GGUFValueType.UINT64]))
108
115
  offs += self._push_field(ReaderField(offs, 'GGUF.kv_count', [temp_counts[1:]], [0], [GGUFValueType.UINT64]))
109
116
  tensor_count, kv_count = temp_counts
110
117
  offs = self._build_fields(offs, kv_count)
111
- offs, tensors_fields = self._build_tensors_fields(offs, tensor_count)
118
+
119
+ # Build Tensor Info Fields
120
+ offs, tensors_fields = self._build_tensor_info(offs, tensor_count)
112
121
  new_align = self.fields.get('general.alignment')
113
122
  if new_align is not None:
114
123
  if new_align.types != [GGUFValueType.UINT32]:
@@ -117,6 +126,7 @@ class GGUFReader:
117
126
  padding = offs % self.alignment
118
127
  if padding != 0:
119
128
  offs += self.alignment - padding
129
+ self.data_offset = offs
120
130
  self._build_tensors(offs, tensors_fields)
121
131
 
122
132
  _DT = TypeVar('_DT', bound = npt.DTypeLike)
@@ -130,7 +140,7 @@ class GGUFReader:
130
140
  return self.tensors[idx]
131
141
 
132
142
  def _get(
133
- self, offset: int, dtype: npt.DTypeLike, count: int = 1, override_order: None | Literal['I'] | Literal['S'] | Literal['<'] = None,
143
+ self, offset: int, dtype: npt.DTypeLike, count: int = 1, override_order: None | Literal['I', 'S', '<'] = None,
134
144
  ) -> npt.NDArray[Any]:
135
145
  count = int(count)
136
146
  itemsize = int(np.empty([], dtype = dtype).itemsize)
@@ -193,18 +203,29 @@ class GGUFReader:
193
203
  # We can't deal with this one.
194
204
  raise ValueError('Unknown/unhandled field type {gtype}')
195
205
 
196
- def _get_tensor(self, orig_offs: int) -> ReaderField:
206
+ def _get_tensor_info_field(self, orig_offs: int) -> ReaderField:
197
207
  offs = orig_offs
208
+
209
+ # Get Tensor Name
198
210
  name_len, name_data = self._get_str(offs)
199
211
  offs += int(name_len.nbytes + name_data.nbytes)
212
+
213
+ # Get Tensor Dimensions Count
200
214
  n_dims = self._get(offs, np.uint32)
201
215
  offs += int(n_dims.nbytes)
216
+
217
+ # Get Tensor Dimension Array
202
218
  dims = self._get(offs, np.uint64, n_dims[0])
203
219
  offs += int(dims.nbytes)
220
+
221
+ # Get Tensor Encoding Scheme Type
204
222
  raw_dtype = self._get(offs, np.uint32)
205
223
  offs += int(raw_dtype.nbytes)
224
+
225
+ # Get Tensor Offset
206
226
  offset_tensor = self._get(offs, np.uint64)
207
227
  offs += int(offset_tensor.nbytes)
228
+
208
229
  return ReaderField(
209
230
  orig_offs,
210
231
  str(bytes(name_data), encoding = 'utf-8'),
@@ -233,10 +254,10 @@ class GGUFReader:
233
254
  offs += field_size
234
255
  return offs
235
256
 
236
- def _build_tensors_fields(self, offs: int, count: int) -> tuple[int, list[ReaderField]]:
257
+ def _build_tensor_info(self, offs: int, count: int) -> tuple[int, list[ReaderField]]:
237
258
  tensor_fields = []
238
259
  for _ in range(count):
239
- field = self._get_tensor(offs)
260
+ field = self._get_tensor_info_field(offs)
240
261
  offs += sum(int(part.nbytes) for part in field.parts)
241
262
  tensor_fields.append(field)
242
263
  return offs, tensor_fields
@@ -293,4 +314,4 @@ class GGUFReader:
293
314
  data = self._get(data_offs, item_type, item_count).reshape(np_dims),
294
315
  field = field,
295
316
  ))
296
- self.tensors = tensors
317
+ self.tensors = tensors