story: DGR-043 Expose GGUF compatibility and measured cost inputs to existing routing
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from meshnet_node.capability import ExecutionCapacity
|
||||
from types import SimpleNamespace
|
||||
|
||||
from meshnet_node.capability import ExecutionCapacity, RoutingMeasurements
|
||||
from meshnet_node.native_registration import (
|
||||
NativeCapabilityRegistrar,
|
||||
NativeRegistrationError,
|
||||
@@ -10,8 +12,8 @@ from meshnet_node.native_registration import (
|
||||
)
|
||||
from meshnet_node.native_worker_supervisor import NativeWorkerProbe, NativeWorkerSpec
|
||||
from meshnet_node.runtime_recipe import ShardIdentity
|
||||
from meshnet_tracker.capability import STATE_UNCERTIFIED
|
||||
from meshnet_tracker.server import TrackerServer, _capability_from_registration
|
||||
from meshnet_tracker.capability import CapabilityState, STATE_ADMITTED, STATE_UNCERTIFIED
|
||||
from meshnet_tracker.server import TrackerServer, _capability_from_registration, _select_route
|
||||
|
||||
from test_runtime_recipe_identity import _identity
|
||||
|
||||
@@ -40,6 +42,10 @@ def test_native_registration_carries_exact_identity_range_capacity_and_dark_stat
|
||||
endpoint="http://native.example:8080", model_id=identity.artifact.artifact_id,
|
||||
identity=identity, worker=worker, probe=probe, device="cpu:fixture",
|
||||
capacity=ExecutionCapacity(4096, 8192, 3), duration_ms=7,
|
||||
routing=RoutingMeasurements(
|
||||
tokens_per_second=12.5, queue_depth=2, seam_latency_ms=3.5,
|
||||
healthy=True, reliability=0.99,
|
||||
),
|
||||
)
|
||||
|
||||
payload = registration.payload()
|
||||
@@ -50,6 +56,12 @@ def test_native_registration_carries_exact_identity_range_capacity_and_dark_stat
|
||||
assert report["capacity"] == {
|
||||
"memory_capacity_bytes": 4096, "kv_capacity_tokens": 8192, "max_concurrent_sessions": 3,
|
||||
}
|
||||
assert report["routing"] == {
|
||||
"tokens_per_second": 12.5, "queue_depth": 2, "seam_latency_ms": 3.5,
|
||||
"healthy": True, "reliability": 0.99,
|
||||
}
|
||||
assert payload["benchmark_tokens_per_sec"] == 12.5
|
||||
assert payload["queue_depth"] == 2
|
||||
|
||||
tracker = TrackerServer()
|
||||
state = _capability_from_registration(
|
||||
@@ -62,6 +74,11 @@ def test_native_registration_carries_exact_identity_range_capacity_and_dark_stat
|
||||
assert state.memory_capacity_bytes == 4096
|
||||
assert state.kv_capacity_tokens == 8192
|
||||
assert state.max_concurrent_sessions == 3
|
||||
assert state.measured_tokens_per_second == 12.5
|
||||
assert state.reported_queue_depth == 2
|
||||
assert state.seam_latency_ms == 3.5
|
||||
assert state.healthy is True
|
||||
assert state.reliability == 0.99
|
||||
|
||||
|
||||
def test_native_registrar_has_no_tracker_or_backend_policy_of_its_own():
|
||||
@@ -92,3 +109,34 @@ def test_native_registration_refuses_a_probe_for_a_different_range():
|
||||
except NativeRegistrationError:
|
||||
return
|
||||
raise AssertionError("different worker range must not register")
|
||||
|
||||
|
||||
def _candidate(
|
||||
node_id: str, start: int, end: int, fingerprint: tuple[str, str], *, state: str = STATE_ADMITTED
|
||||
) -> SimpleNamespace:
|
||||
return SimpleNamespace(
|
||||
node_id=node_id, endpoint=f"http://{node_id}", model="generic-model", hf_repo=None,
|
||||
shard_start=start, shard_end=end, benchmark_tokens_per_sec=10.0,
|
||||
model_tokens_per_sec={}, queue_depth=0, proxy_inflight=0, wallet_address=None,
|
||||
capability=CapabilityState(
|
||||
state=state, shard_start=start, shard_end=end,
|
||||
model_artifact_digest=fingerprint[0], runtime_recipe_digest=fingerprint[1],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def test_existing_route_formation_requires_exact_compatible_coverage_and_excludes_dark_nodes():
|
||||
"""Routing consumes generic fingerprints and admission states, not GGUF policy."""
|
||||
exact = ("a" * 64, "b" * 64)
|
||||
other = ("c" * 64, "d" * 64)
|
||||
compatible_head = _candidate("head", 0, 3, exact)
|
||||
compatible_tail = _candidate("tail", 4, 7, exact)
|
||||
dark_head = _candidate("dark", 0, 7, exact, state=STATE_UNCERTIFIED)
|
||||
|
||||
route, error = _select_route([dark_head, compatible_head, compatible_tail], 0, 7)
|
||||
assert error == ""
|
||||
assert [node.node_id for node in route] == ["head", "tail"]
|
||||
|
||||
route, error = _select_route([compatible_head, _candidate("wrong", 4, 7, other)], 0, 7)
|
||||
assert route == []
|
||||
assert "covers layer 4" in error
|
||||
|
||||
Reference in New Issue
Block a user