Skip to content

Commit

Permalink
move kv keys to constants.py
Browse files Browse the repository at this point in the history
  • Loading branch information
christianazinn committed Jun 6, 2024
1 parent 1cbab22 commit 2037eab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 5 additions & 0 deletions gguf-py/gguf/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ class Rope:
SCALING_FINETUNED = "{arch}.rope.scaling.finetuned"
SCALING_YARN_LOG_MUL = "{arch}.rope.scaling.yarn_log_multiplier"

class Split:
LLM_KV_SPLIT_NO = "split.no"
LLM_KV_SPLIT_COUNT = "split.count"
LLM_KV_SPLIT_TENSORS_COUNT = "split.tensors.count"

class SSM:
CONV_KERNEL = "{arch}.ssm.conv_kernel"
INNER_SIZE = "{arch}.ssm.inner_size"
Expand Down
11 changes: 4 additions & 7 deletions gguf-py/gguf/gguf_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@
GGUFValueType
)
from .gguf_writer import GGUFWriter, WriterState
from .constants import Keys


SHARD_NAME_FORMAT = "{:s}-{:05d}-of-{:05d}.gguf"
METADATA_ONLY_INDICATOR = -1

LLM_KV_SPLIT_NO = "split.no"
LLM_KV_SPLIT_COUNT = "split.count"
LLM_KV_SPLIT_TENSORS_COUNT = "split.tensors.count"

KVTempData: TypeAlias = dict[str, tuple[Any, GGUFValueType]] # {key: (value, type)}
TensorTempData: TypeAlias = tuple[str, np.ndarray[Any, Any], GGMLQuantizationType] # (tensor name, tensor data, tensor dtype)

Expand Down Expand Up @@ -132,9 +129,9 @@ def init_shards(self) -> None:

# add split metadata unless it's one file - small first shard splits even with SplitStyle.NONE
if self.split_arguments.split_style != SplitStyle.NONE or self.split_arguments.small_first_shard:
writer.add_uint16(LLM_KV_SPLIT_NO, i)
writer.add_uint16(LLM_KV_SPLIT_COUNT, len(self.shards))
writer.add_int32(LLM_KV_SPLIT_TENSORS_COUNT, self.total_tensors)
writer.add_uint16(Keys.Split.LLM_KV_SPLIT_NO, i)
writer.add_uint16(Keys.Split.LLM_KV_SPLIT_COUNT, len(self.shards))
writer.add_int32(Keys.Split.LLM_KV_SPLIT_TENSORS_COUNT, self.total_tensors)

# add tensors, deque popleft() ensures references to eager tensors are not kept
while True:
Expand Down

0 comments on commit 2037eab

Please sign in to comment.