feat: checkpoint distributed gguf runtime stories
This commit is contained in:
@@ -323,6 +323,10 @@ class TorchModelShard:
|
||||
)
|
||||
self.is_head = shard_start == 0
|
||||
self.is_tail = shard_end >= self.total_layers - 1
|
||||
self.loaded_shard_start = shard_start
|
||||
self.loaded_shard_end = shard_end
|
||||
self.owns_embedding = self.is_head
|
||||
self.owns_final_head = self.is_tail
|
||||
self.hidden_size = int(
|
||||
getattr(self.model.config, "hidden_size", 0)
|
||||
or getattr(self.model.config, "n_embd", 0)
|
||||
@@ -344,6 +348,17 @@ class TorchModelShard:
|
||||
ttl_seconds=float(os.environ.get("MESHNET_KV_TTL_SECONDS", "600")),
|
||||
)
|
||||
|
||||
@property
|
||||
def loaded_range(self) -> tuple[int, int]:
|
||||
return self.loaded_shard_start, self.loaded_shard_end
|
||||
|
||||
@property
|
||||
def endpoint_ownership(self) -> dict[str, bool]:
|
||||
return {
|
||||
"owns_embedding": self.owns_embedding,
|
||||
"owns_final_head": self.owns_final_head,
|
||||
}
|
||||
|
||||
def encode_prompt(self, prompt: str, session_id: str | None = None) -> TensorPayload:
|
||||
if not self.is_head or self._embed_tokens is None:
|
||||
raise ModelBackendError("text prompts can only be accepted by the head shard")
|
||||
|
||||
Reference in New Issue
Block a user