organ-architecture/mass_dissect.py
2026-02-25 02:56:51 +00:00

104 lines
3.8 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Mass Dissection — All models on remote node
CSCI v1.0 — Cross-Scale Coherence Index
"""
import subprocess, os, sys, json, time
MODELS_DIR = "/mnt/models"
# Map GGUF filenames to organ directory names
models = {
"DeepSeek-R1-Distill-Qwen-14B-Q4_K_M.gguf": "deepseek-r1-14b",
"Qwen2.5-14B-Instruct-Q4_K_M.gguf": "qwen25-14b",
"gemma-2-9b-it-Q4_K_M.gguf": "gemma2-9b",
"Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf": "llama31-8b",
"Qwen2.5-7B-Instruct-Q4_K_M.gguf": "qwen25-7b",
"DeepSeek-R1-Distill-Qwen-7B-Q4_K_M.gguf": "deepseek-r1-distill-7b",
"DeepSeek-R1-7B-Q4_K_M.gguf": "deepseek-r1-7b",
"Mistral-7B-Instruct-v0.3-Q4_K_M.gguf": "mistral-7b",
"Phi-3.5-mini-instruct-Q4_K_M.gguf": "phi35-mini",
"Llama-3.2-3B-Instruct-Q4_K_M.gguf": "llama32-3b",
"Qwen2.5-3B-Instruct-Q4_K_M.gguf": "qwen25-3b",
"Llama-3.2-1B-Instruct-Q4_K_M.gguf": "llama32-1b",
"SmolLM2-135M-Instruct-Q8_0.gguf": "smollm2-135m",
}
results = []
skipped = []
for gguf, organ_name in models.items():
gguf_path = os.path.join(MODELS_DIR, gguf)
organ_path = os.path.join(ORGANS_DIR, organ_name)
if not os.path.exists(gguf_path):
print(f"[SKIP] {gguf} — not found")
skipped.append(gguf)
continue
if os.path.exists(os.path.join(organ_path, "manifest.json")):
# Already dissected — just measure
size_mb = sum(
os.path.getsize(os.path.join(dp, f))
for dp, dn, fn in os.walk(organ_path) for f in fn
) / (1024*1024)
print(f"[DONE] {organ_name} — already dissected ({size_mb:.0f}MB)")
results.append({"model": organ_name, "status": "exists", "size_mb": size_mb})
continue
# Dissect
print(f"\n{'='*60}")
print(f"[DISSECT] {gguf}{organ_name}")
print(f"{'='*60}")
t0 = time.time()
r = subprocess.run(
["python3", EXTRACT, "--model", gguf_path, "--output", organ_path],
capture_output=True, text=True, timeout=600
)
elapsed = time.time() - t0
if r.returncode == 0:
# Get last lines (summary)
lines = r.stdout.strip().split("\n")
for line in lines[-10:]:
print(line)
size_mb = sum(
os.path.getsize(os.path.join(dp, f))
for dp, dn, fn in os.walk(organ_path) for f in fn
) / (1024*1024)
results.append({
"model": organ_name, "status": "dissected",
"size_mb": size_mb, "time_s": elapsed
})
print(f"[OK] {organ_name}{size_mb:.0f}MB in {elapsed:.1f}s")
else:
print(f"[ERROR] {organ_name}")
print(r.stderr[-500:] if r.stderr else r.stdout[-500:])
results.append({"model": organ_name, "status": "error", "error": r.stderr[-200:]})
# Summary
print(f"\n{'='*60}")
print(f" MASS DISSECTION COMPLETE")
print(f"{'='*60}")
for r in results:
status = "" if r["status"] in ("dissected", "exists") else ""
size = f"{r.get('size_mb',0):.0f}MB"
time_s = f"{r.get('time_s',0):.0f}s" if r.get("time_s") else "cached"
print(f" {status} {r['model']:30s} {size:>8s} {time_s}")
total_mb = sum(r.get("size_mb",0) for r in results)
print(f"\n Total organs: {total_mb/1024:.1f} GB")
print(f"{'='*60}")
# Save results
json.dump(results, f, indent=2)
# ╔══ SALKA ELMADANI AUTHORSHIP CERTIFICATE ══╗
# © Salka Elmadani 2025-2026 — ALL RIGHTS RESERVED
# Licensed under Business Source License 1.1 — https://inference-x.com
# ─────────────────────────────────────────────────────────
# SIG-ED25519: XB8aA7wVzKOHkvMcZgE5YT3x8BUD/EwVTDRxEMSR7nmWYIT17XY+gC4AJ+y0B29l8MQGFDGk+buLoKxiagTFCA==
# VERIFY: python3 verify_authorship.py mass_dissect.py