feat: checkpoint distributed gguf runtime stories
This commit is contained in:
@@ -16,7 +16,10 @@ import time
|
||||
from typing import Any
|
||||
|
||||
from .admission import CapabilityContext, CapabilityValidator
|
||||
from . import __version__ as _PACKAGE_VERSION
|
||||
from .capability import STATUS_PASSED, CapabilityReport, build_capability_report
|
||||
from .gguf_ownership import authoritative_dense_llama_ownership
|
||||
from .runtime_recipe import build_runtime_recipe_identity
|
||||
|
||||
|
||||
def capability_report_for(
|
||||
@@ -30,6 +33,15 @@ def capability_report_for(
|
||||
recipe_version: str | None = None,
|
||||
backend_id: str | None = None,
|
||||
device: str | None = None,
|
||||
artifact_hash: str | None = None,
|
||||
activation_dtype: str | None = None,
|
||||
compute_dtype: str | None = None,
|
||||
kv_dtype: str | None = None,
|
||||
kv_layout: str | None = None,
|
||||
tokenizer_revision: str | None = None,
|
||||
architecture_adapter: str | None = None,
|
||||
boundary_schema_version: int = 1,
|
||||
cache_layout: str | None = None,
|
||||
validated_at: float | None = None,
|
||||
age_seconds: float = 0.0,
|
||||
diagnostics: Any = None,
|
||||
@@ -37,18 +49,49 @@ def capability_report_for(
|
||||
) -> CapabilityReport:
|
||||
"""A report describing `context`, with any field bent away from the truth."""
|
||||
now = time.time() if validated_at is None else validated_at
|
||||
backend = getattr(context, "backend", None)
|
||||
model_config = getattr(getattr(backend, "model", None), "config", None)
|
||||
model_config_payload = (
|
||||
model_config.to_dict() if hasattr(model_config, "to_dict") else model_config
|
||||
)
|
||||
resolved_cache_layout = (
|
||||
"stateless"
|
||||
if getattr(backend, "supports_kv_cache", False) is False
|
||||
else "local-hot-kv"
|
||||
)
|
||||
ownership = authoritative_dense_llama_ownership(backend, context.selection)
|
||||
runtime_recipe = build_runtime_recipe_identity(
|
||||
model_id=context.selection.model_id,
|
||||
revision=getattr(getattr(backend, "model", None), "revision", None),
|
||||
model_config=model_config_payload,
|
||||
recipe_params=context.recipe.params,
|
||||
weight_quantization=context.selection.quantization,
|
||||
backend_id=context.recipe.backend_id,
|
||||
runtime_version=_PACKAGE_VERSION,
|
||||
activation_dtype=activation_dtype,
|
||||
compute_dtype=compute_dtype,
|
||||
kv_dtype=kv_dtype,
|
||||
kv_layout=kv_layout or _backend_kv_layout(backend),
|
||||
tokenizer_revision=tokenizer_revision,
|
||||
architecture_adapter=architecture_adapter,
|
||||
boundary_schema_version=boundary_schema_version,
|
||||
cache_layout=cache_layout or resolved_cache_layout,
|
||||
)
|
||||
return build_capability_report(
|
||||
model_id=model_id or context.selection.model_id,
|
||||
shard_start=(
|
||||
context.selection.shard_start if shard_start is None else shard_start
|
||||
),
|
||||
shard_end=context.selection.shard_end if shard_end is None else shard_end,
|
||||
shard_start=ownership.start_layer if shard_start is None else shard_start,
|
||||
shard_end=ownership.end_layer if shard_end is None else shard_end,
|
||||
recipe_id=recipe_id or context.recipe.id,
|
||||
recipe_version=recipe_version or context.recipe.version,
|
||||
catalogue_version=context.manifest.catalogue_version,
|
||||
backend_id=backend_id or context.recipe.backend_id,
|
||||
device=device or context.device,
|
||||
quantization=context.selection.quantization,
|
||||
runtime=_runtime_versions(),
|
||||
artifact_hash=artifact_hash,
|
||||
runtime_recipe=runtime_recipe,
|
||||
owns_embedding=ownership.owns_embedding,
|
||||
owns_final_head=ownership.owns_final_head,
|
||||
status=status,
|
||||
duration_ms=duration_ms,
|
||||
diagnostics=diagnostics,
|
||||
@@ -68,3 +111,20 @@ def capability_stub(**overrides: Any) -> CapabilityValidator:
|
||||
return capability_report_for(context, **overrides)
|
||||
|
||||
return validator
|
||||
|
||||
|
||||
def _runtime_versions() -> dict[str, str]:
|
||||
versions: dict[str, str] = {}
|
||||
for name in ("torch", "transformers"):
|
||||
try:
|
||||
module = __import__(name)
|
||||
except Exception:
|
||||
continue
|
||||
version = getattr(module, "__version__", None)
|
||||
if version:
|
||||
versions[name] = str(version)
|
||||
return versions
|
||||
|
||||
|
||||
def _backend_kv_layout(backend: Any) -> str:
|
||||
return "session-cache" if getattr(backend, "supports_kv_cache", False) else "stateless"
|
||||
|
||||
Reference in New Issue
Block a user