spb/localvm-research Public License
Running LLMs larger than memory on a consumer Mac — falsification-driven research: margin-gated deferred refinement, out-of-core verification on Apple Silicon. TR-01 published.
Python 63.2%
JavaScript 23.5%
CSS 11.8%
Shell 0.9%
Makefile 0.5%
1#!/usr/bin/env python32# =============================================================================3# Project : localvm-research4# File : benchmarks/hardware_manifest.py5# Purpose : macOS hardware/software fingerprint embedded in every result file6# Author : Simon-Pierre Boucher7# Contact : contact@spboucher.ai8# Created : 2026-08-119# Modified : 2026-08-1110# Platform : macOS / Apple Silicon (arm64)11# License : All rights reserved (research code)12# =============================================================================13"""Collect a reproducibility manifest for the current Mac.1415Records chip model, P/E core counts, GPU core count, unified memory size,16SSD model, macOS version, and versions of the key software stack (Python,17MLX, PyTorch, NumPy), plus the current git commit. Every benchmark result18JSON must embed this manifest (CLAUDE.md §0.2, §10).1920Usage:21 python3 benchmarks/hardware_manifest.py # pretty-print JSON22 from hardware_manifest import collect_manifest # programmatic use23"""2425from __future__ import annotations2627import json28import platform29import subprocess30import sys31from datetime import datetime, timezone323334def _run(cmd: list[str]) -> str:35 try:36 return subprocess.run(cmd, capture_output=True, text=True, timeout=30).stdout.strip()37 except (OSError, subprocess.TimeoutExpired):38 return ""394041def _sysctl(key: str) -> str:42 return _run(["sysctl", "-n", key])434445def _sysctl_int(key: str) -> int | None:46 val = _sysctl(key)47 try:48 return int(val)49 except ValueError:50 return None515253def _gpu_cores() -> int | None:54 """GPU core count via system_profiler (no sysctl key exposes it)."""55 out = _run(["system_profiler", "SPDisplaysDataType", "-json"])56 try:57 displays = json.loads(out)["SPDisplaysDataType"]58 for gpu in displays:59 cores = gpu.get("sppci_cores")60 if cores is not None:61 return int(cores)62 except (json.JSONDecodeError, KeyError, ValueError, TypeError):63 pass64 return None656667def _ssd_info() -> dict:68 out = _run(["system_profiler", "SPNVMeDataType", "-json"])69 try:70 items = json.loads(out)["SPNVMeDataType"]71 for controller in items:72 for dev in controller.get("_items", []):73 return {74 "model": dev.get("device_model", "").strip(),75 "size": dev.get("size", ""),76 "smart_status": dev.get("smart_status", ""),77 }78 except (json.JSONDecodeError, KeyError, TypeError):79 pass80 return {"model": None, "size": None, "smart_status": None}818283def _pkg_version(module: str) -> str | None:84 try:85 from importlib.metadata import version8687 return version(module)88 except Exception:89 return None909192def _git_commit() -> dict:93 commit = _run(["git", "rev-parse", "HEAD"])94 dirty = bool(_run(["git", "status", "--porcelain"]))95 return {"commit": commit or None, "dirty_tree": dirty}969798def _thermal_state() -> str | None:99 # 'thermal pressure' via thermal level sysctl where available100 lvl = _sysctl("machdep.xcpm.cpu_thermal_level")101 return lvl or None102103104def collect_manifest() -> dict:105 """Return the full hardware/software manifest as a dict."""106 mem_bytes = _sysctl_int("hw.memsize") or 0107 manifest = {108 "author": "Simon-Pierre Boucher",109 "contact": "contact@spboucher.ai",110 "project": "localvm-research",111 "collected_utc": datetime.now(timezone.utc).isoformat(),112 "chip": {113 "brand": _sysctl("machdep.cpu.brand_string"),114 "arch": platform.machine(),115 "cores_total": _sysctl_int("hw.ncpu"),116 "cores_performance": _sysctl_int("hw.perflevel0.physicalcpu"),117 "cores_efficiency": _sysctl_int("hw.perflevel1.physicalcpu"),118 "gpu_cores": _gpu_cores(),119 },120 "memory": {121 "unified_bytes": mem_bytes,122 "unified_gb": round(mem_bytes / 2**30, 1),123 "pagesize": _sysctl_int("hw.pagesize"),124 },125 "ssd": _ssd_info(),126 "os": {127 "product": _run(["sw_vers", "-productName"]),128 "version": _run(["sw_vers", "-productVersion"]),129 "build": _run(["sw_vers", "-buildVersion"]),130 "kernel": platform.release(),131 },132 "software": {133 "python": sys.version.split()[0],134 "mlx": _pkg_version("mlx"),135 "mlx_lm": _pkg_version("mlx-lm"),136 "torch": _pkg_version("torch"),137 "numpy": _pkg_version("numpy"),138 },139 "git": _git_commit(),140 "thermal_level_at_collect": _thermal_state(),141 }142 return manifest143144145if __name__ == "__main__":146 print(json.dumps(collect_manifest(), indent=2))147