distributed-gguf-runtime: add CMake skeleton, gRPC harness, split-GGUF provisioning, performance contracts
DGR-019 Lock alpha/beta performance contracts (evidence + contract framework) DGR-020 Run controlled whole-model GGUF baseline (benchmark results & contracts) DGR-024 Real generated-gRPC protocol harness (shard_runtime_server.py + tests) DGR-026 split-GGUF provisioning outside /home (provision script + manifest + tests) DGR-028 Numbered patch-stack apply & verify (llama_cpp_dependency.py + UPSTREAM_LOCK.json) DGR-029 Native CMake skeleton + deterministic CPU lane (UPSTREAM_LOCK.json + cmake gating) New modules: packages/node/meshnet_node/dgr_performance/ — performance contract framework packages/node/meshnet_node/split_gguf/ — split-GGUF manifest & provisioning scripts/provision_split_gguf.py — artifact provisioning CLI tests/test_dgr_performance_contract.py — contract validation tests tests/test_split_gguf_manifest.py — manifest tests tests/test_split_gguf_provision.py — provisioning tests tests/test_shard_runtime_harness.py — gRPC harness tests
This commit is contained in:
@@ -32,18 +32,26 @@ LOCK_PATH = LLAMA_DIR / "UPSTREAM_LOCK.json"
|
||||
PATCH_DIR = LLAMA_DIR / "patches"
|
||||
|
||||
|
||||
def _cmake() -> str:
|
||||
def _toolchain_binary(name: str, env_var: str) -> str:
|
||||
"""Use an explicit override, PATH, or the active Python environment."""
|
||||
configured = os.environ.get("CMAKE")
|
||||
configured = os.environ.get(env_var)
|
||||
if configured:
|
||||
return configured
|
||||
on_path = shutil.which("cmake")
|
||||
on_path = shutil.which(name)
|
||||
if on_path:
|
||||
return on_path
|
||||
sibling = pathlib.Path(sys.executable).parent / "cmake"
|
||||
sibling = pathlib.Path(sys.executable).parent / name
|
||||
if sibling.is_file():
|
||||
return str(sibling)
|
||||
raise DependencyError("cmake is unavailable; set CMAKE or activate the project toolchain")
|
||||
raise DependencyError(f"{name} is unavailable; set {env_var} or activate the project toolchain")
|
||||
|
||||
|
||||
def _cmake() -> str:
|
||||
return _toolchain_binary("cmake", "CMAKE")
|
||||
|
||||
|
||||
def _ctest() -> str:
|
||||
return _toolchain_binary("ctest", "CTEST")
|
||||
|
||||
|
||||
class DependencyError(RuntimeError):
|
||||
@@ -492,6 +500,13 @@ def smoke(binary: pathlib.Path) -> None:
|
||||
print(output)
|
||||
|
||||
|
||||
def ctest_lane(build_dir: pathlib.Path) -> None:
|
||||
"""Run the deterministic model-free CPU CTest lane and print its output."""
|
||||
lock = _load_lock()
|
||||
regex = lock["build"]["ctest_regex"]
|
||||
print(_run(_ctest(), "--test-dir", str(build_dir), "-R", regex, "--output-on-failure"))
|
||||
|
||||
|
||||
def verify(workspace: pathlib.Path) -> None:
|
||||
"""Apply, verify, reverse, and leave the exact cached pin pristine."""
|
||||
source = fetch(workspace)
|
||||
@@ -500,12 +515,16 @@ def verify(workspace: pathlib.Path) -> None:
|
||||
|
||||
|
||||
def reproduce(workspace: pathlib.Path) -> None:
|
||||
"""Configure, build, smoke-test, and CTest a clean checkout, then restore the pristine cache."""
|
||||
source = fetch(workspace)
|
||||
build_dir = workspace.resolve() / "build"
|
||||
if build_dir.exists():
|
||||
raise DependencyError(f"build directory already exists; refusing to erase possible local edits: {build_dir}")
|
||||
apply(source)
|
||||
smoke(build(source, build_dir))
|
||||
binary = build(source, build_dir)
|
||||
smoke(binary)
|
||||
ctest_lane(build_dir)
|
||||
reverse(source)
|
||||
|
||||
|
||||
def inspect() -> None:
|
||||
@@ -541,6 +560,8 @@ def main() -> int:
|
||||
build_parser.add_argument("--build-dir", type=pathlib.Path, required=True)
|
||||
smoke_parser = subcommands.add_parser("smoke")
|
||||
smoke_parser.add_argument("--binary", type=pathlib.Path, required=True)
|
||||
ctest_parser = subcommands.add_parser("ctest")
|
||||
ctest_parser.add_argument("--build-dir", type=pathlib.Path, required=True)
|
||||
reproduce_parser = subcommands.add_parser("reproduce")
|
||||
reproduce_parser.add_argument("--workspace", type=pathlib.Path, default=ROOT / "build/llama.cpp")
|
||||
args = parser.parse_args()
|
||||
@@ -559,6 +580,8 @@ def main() -> int:
|
||||
build(args.source_dir, args.build_dir)
|
||||
elif args.command == "smoke":
|
||||
smoke(args.binary)
|
||||
elif args.command == "ctest":
|
||||
ctest_lane(args.build_dir)
|
||||
else:
|
||||
reproduce(args.workspace)
|
||||
except DependencyError as error:
|
||||
|
||||
77
scripts/provision_split_gguf.py
Normal file
77
scripts/provision_split_gguf.py
Normal file
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Provision exact split-GGUF artifacts to mounted-drive storage (DGR-026).
|
||||
|
||||
Reads a split-artifact manifest (`meshnet_node.split_gguf.manifest`),
|
||||
resumably fetches every split it declares — by default from the split's
|
||||
manifest `url` over HTTP(S), or from a local directory with `--source-dir`
|
||||
for splits already staged/mirrored elsewhere — verifies each split's SHA-256
|
||||
against the manifest, and refuses to write under `/home`.
|
||||
|
||||
This tool never invents a quantization, split count, or layer layout: it only
|
||||
executes whatever the manifest declares. It is opt-in and network-using; the
|
||||
default test suite never calls it.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / "packages/node"))
|
||||
|
||||
from meshnet_node.split_gguf.manifest import ( # noqa: E402
|
||||
SplitArtifactManifestError,
|
||||
load_split_artifact_manifest,
|
||||
)
|
||||
from meshnet_node.split_gguf.provision import ( # noqa: E402
|
||||
SplitProvisionError,
|
||||
http_split_fetcher,
|
||||
local_directory_fetcher,
|
||||
provision_split_artifact,
|
||||
)
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--manifest", required=True, type=pathlib.Path, help="split-artifact manifest JSON")
|
||||
parser.add_argument("--dest", required=True, type=pathlib.Path, help="mounted-drive destination directory")
|
||||
parser.add_argument(
|
||||
"--source-dir",
|
||||
type=pathlib.Path,
|
||||
default=None,
|
||||
help="copy splits from this local directory instead of downloading each split's manifest url",
|
||||
)
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
try:
|
||||
manifest = load_split_artifact_manifest(args.manifest)
|
||||
except SplitArtifactManifestError as exc:
|
||||
print(f"error: {exc}", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
if args.source_dir is not None:
|
||||
fetch = local_directory_fetcher(args.source_dir)
|
||||
else:
|
||||
missing_urls = [split.name for split in manifest.splits if not split.url]
|
||||
if missing_urls:
|
||||
print(
|
||||
f"error: manifest splits missing a url and no --source-dir given: {missing_urls}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 2
|
||||
fetch = http_split_fetcher(lambda split: split.url)
|
||||
|
||||
try:
|
||||
result = provision_split_artifact(manifest, args.dest, fetch)
|
||||
except SplitProvisionError as exc:
|
||||
print(f"error: {exc}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
print(f"provisioned {len(result.verified_splits)} split(s) to {result.dest_dir}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user