Track Kimi model metadata and cache path
This commit is contained in:
@@ -197,6 +197,65 @@ def test_benchmark_throughput_is_registered_in_payload(monkeypatch, tmp_path):
|
||||
assert captured["hardware_profile"]["benchmark_ok"] is True
|
||||
|
||||
|
||||
def test_real_model_startup_passes_download_dir_and_kimi_metadata(monkeypatch, tmp_path):
|
||||
import meshnet_node.startup as startup_mod
|
||||
|
||||
captured_registration: dict = {}
|
||||
captured_torch_kwargs: dict = {}
|
||||
|
||||
class FakeBackend:
|
||||
total_layers = 61
|
||||
|
||||
class FakeNode:
|
||||
backend = FakeBackend()
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
captured_torch_kwargs.update(kwargs)
|
||||
|
||||
def start(self):
|
||||
return 7099
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def apply_tracker_directives(self, directives):
|
||||
return None
|
||||
|
||||
monkeypatch.setattr(
|
||||
startup_mod,
|
||||
"detect_hardware",
|
||||
lambda: {"device": "cpu", "gpu_name": None, "vram_mb": 0, "ram_mb": 16384},
|
||||
)
|
||||
monkeypatch.setattr(startup_mod, "benchmark_throughput_checked", lambda _device: (42.5, True, None))
|
||||
monkeypatch.setattr(startup_mod, "TorchNodeServer", FakeNode)
|
||||
monkeypatch.setattr(startup_mod, "load_or_create_wallet", lambda **_kw: (b"", b"", "wallet-kimi"))
|
||||
monkeypatch.setattr(startup_mod, "_get_json", lambda _url, timeout=10.0: {"relay_url": None, "nodes": []})
|
||||
monkeypatch.setattr(
|
||||
startup_mod,
|
||||
"_post_json",
|
||||
lambda _url, payload, timeout=10.0: (
|
||||
captured_registration.update(payload) or {"node_id": "node-kimi"}
|
||||
),
|
||||
)
|
||||
monkeypatch.setattr(startup_mod, "_start_heartbeat", lambda *a, **kw: None)
|
||||
|
||||
cache_dir = tmp_path / "models"
|
||||
node = run_startup(
|
||||
tracker_url="http://localhost:8080",
|
||||
model_id="unsloth/Kimi-K2.7-Code",
|
||||
shard_start=0,
|
||||
shard_end=60,
|
||||
wallet_path=tmp_path / "wallet.json",
|
||||
cache_dir=cache_dir,
|
||||
)
|
||||
node.stop()
|
||||
|
||||
assert captured_torch_kwargs["cache_dir"] == cache_dir
|
||||
assert captured_registration["model_metadata"]["total_parameters"] == "1T"
|
||||
assert captured_registration["model_metadata"]["activated_parameters"] == "32B"
|
||||
assert captured_registration["model_metadata"]["context_length"] == 256000
|
||||
|
||||
|
||||
def test_cuda_benchmark_failure_is_registered_for_inventory_only_gpu(monkeypatch, tmp_path, capsys):
|
||||
import meshnet_node.startup as startup_mod
|
||||
|
||||
|
||||
@@ -50,6 +50,43 @@ def test_tracker_send_json_ignores_broken_pipe_after_client_disconnect():
|
||||
_TrackerHandler._send_json(DummyHandler(), 200, {"ok": True})
|
||||
|
||||
|
||||
def test_tracker_exposes_registered_model_metadata():
|
||||
tracker = TrackerServer()
|
||||
port = tracker.start()
|
||||
url = f"http://127.0.0.1:{port}"
|
||||
try:
|
||||
_post_json(
|
||||
f"{url}/v1/nodes/register",
|
||||
{
|
||||
"endpoint": "http://127.0.0.1:7100",
|
||||
"model": "Kimi-K2.7-Code",
|
||||
"hf_repo": "unsloth/Kimi-K2.7-Code",
|
||||
"num_layers": 61,
|
||||
"shard_start": 0,
|
||||
"shard_end": 60,
|
||||
"hardware_profile": {},
|
||||
"model_metadata": {
|
||||
"total_parameters": "1T",
|
||||
"activated_parameters": "32B",
|
||||
"context_length": 256000,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
models = _get_json(f"{url}/v1/models")
|
||||
network_map = _get_json(f"{url}/v1/network/map")
|
||||
finally:
|
||||
tracker.stop()
|
||||
|
||||
kimi = next(model for model in models["data"] if model["id"] == "unsloth/Kimi-K2.7-Code")
|
||||
assert kimi["metadata"]["total_parameters"] == "1T"
|
||||
assert kimi["metadata"]["activated_parameters"] == "32B"
|
||||
assert kimi["metadata"]["num_layers"] == 61
|
||||
registered = network_map["nodes"][0]
|
||||
assert registered["num_layers"] == 61
|
||||
assert registered["model_metadata"]["context_length"] == 256000
|
||||
|
||||
|
||||
def test_tracker_serves_health_while_proxy_request_is_in_flight():
|
||||
"""Long inference proxy requests must not block heartbeats/health checks."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user