feat: checkpoint distributed gguf runtime stories
This commit is contained in:
@@ -22,6 +22,7 @@ import pytest
|
||||
|
||||
from meshnet_node.admission import (
|
||||
REASON_BACKEND_MISMATCH,
|
||||
REASON_COMPATIBILITY_MISMATCH,
|
||||
REASON_MODEL_MISMATCH,
|
||||
REASON_NO_REPORT,
|
||||
REASON_NOT_PASSED,
|
||||
@@ -68,11 +69,26 @@ class _FakeBackend:
|
||||
total_layers = 24
|
||||
hidden_size = 8
|
||||
|
||||
def __init__(self, *, shard_start=0, shard_end=23, device="cpu", forward_error=None):
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
shard_start=0,
|
||||
shard_end=23,
|
||||
device="cpu",
|
||||
forward_error=None,
|
||||
loaded_shard_start=None,
|
||||
loaded_shard_end=None,
|
||||
owns_embedding=None,
|
||||
owns_final_head=None,
|
||||
):
|
||||
self.shard_start = shard_start
|
||||
self.shard_end = shard_end
|
||||
self.is_head = shard_start == 0
|
||||
self.is_tail = shard_end == self.total_layers - 1
|
||||
self.loaded_shard_start = shard_start if loaded_shard_start is None else loaded_shard_start
|
||||
self.loaded_shard_end = shard_end if loaded_shard_end is None else loaded_shard_end
|
||||
self.owns_embedding = self.is_head if owns_embedding is None else owns_embedding
|
||||
self.owns_final_head = self.is_tail if owns_final_head is None else owns_final_head
|
||||
self.device = _FakeDevice(device)
|
||||
self.model_id = MODEL
|
||||
self._forward_error = forward_error
|
||||
@@ -192,6 +208,17 @@ def test_a_passing_report_from_another_backend_or_device_is_refused():
|
||||
assert exc.value.reason == REASON_BACKEND_MISMATCH
|
||||
|
||||
|
||||
def test_a_passing_report_with_the_wrong_cache_layout_is_refused():
|
||||
"The compatibility fingerprint fails closed when cache layout changes.\n\nTags: node, admission"
|
||||
ctx = _context()
|
||||
report = capability_report_for(ctx, cache_layout="local-hot-kv")
|
||||
|
||||
with pytest.raises(CapabilityAdmissionError) as exc:
|
||||
admit(AdmissionRequirement.for_context(ctx), report)
|
||||
|
||||
assert exc.value.reason == REASON_COMPATIBILITY_MISMATCH
|
||||
|
||||
|
||||
def test_a_report_older_than_the_freshness_window_is_refused():
|
||||
"Hardware, drivers and weights move; an old proof is not a current one.\n\nTags: node, admission"
|
||||
ctx = _context()
|
||||
@@ -371,10 +398,31 @@ def test_a_matching_passing_report_registers_and_travels_with_the_payload(startu
|
||||
assert report["status"] == "passed"
|
||||
assert report["model"]["model_id"] == MODEL
|
||||
assert (report["shard"]["start"], report["shard"]["end"]) == (0, 23)
|
||||
assert report["shard"]["owns_embedding"] is True
|
||||
assert report["shard"]["owns_final_head"] is True
|
||||
assert report["recipe"]["recipe_id"] == DEFAULT_RECIPE_ID
|
||||
assert report["backend"]["device"] == "cpu"
|
||||
|
||||
|
||||
def test_capability_report_prefers_backend_loaded_range_over_cli_claims():
|
||||
"The proof reports the model's loaded range, not the CLI's requested range.\n\nTags: node, admission"
|
||||
backend = _FakeBackend(
|
||||
shard_start=0,
|
||||
shard_end=23,
|
||||
loaded_shard_start=8,
|
||||
loaded_shard_end=15,
|
||||
owns_embedding=False,
|
||||
owns_final_head=True,
|
||||
)
|
||||
report = capability_report_for(
|
||||
_context(backend=backend, shard_start=0, shard_end=23),
|
||||
)
|
||||
|
||||
assert (report.shard.start, report.shard.end) == (8, 15)
|
||||
assert report.shard.owns_embedding is False
|
||||
assert report.shard.owns_final_head is True
|
||||
|
||||
|
||||
def test_the_served_backend_is_loaded_with_the_recipe_that_was_validated(startup_env):
|
||||
"The recipe named in the report is the one the serving backend actually ran.\n\nTags: node, admission, startup"
|
||||
node = _start(recipe_id="eager-attention")
|
||||
|
||||
Reference in New Issue
Block a user