#!/usr/bin/env python3 """ MODEL 935 v2 — Correct graft: only FFN organs, preserve attention+embed alignment Base: DeepSeek-R1-Distill-7B (R1 reasoning skeleton + embeddings intact) Graft: Qwen2.5-7B FFN organs only (knowledge) CSCI v1.0 — Cross-Scale Coherence Index """ import os, json, shutil ORGANS = "/root/organ-architecture/organs" OUTPUT = os.path.join(ORGANS, "model-935-v2") if os.path.exists(OUTPUT): shutil.rmtree(OUTPUT) # Base: DeepSeek-R1-Distill-7B (complete, unmodified) base = os.path.join(ORGANS, "deepseek-r1-distill-7b") print("[1/3] Base: DeepSeek-R1-Distill-7B (complete)") shutil.copytree(base, OUTPUT) # Graft: Only FFN weights from Qwen2.5-7B (NOT norms, NOT attention, NOT embed) qwen_organs = os.path.join(ORGANS, "qwen25-7b", "organs") out_organs = os.path.join(OUTPUT, "organs") grafted = 0 skipped = 0 for fname in os.listdir(qwen_organs): if not fname.endswith('.bin'): continue # Only graft actual FFN weights: ffn_down, ffn_gate, ffn_up # Skip ffn_norm (must stay with base skeleton for alignment) is_ffn_weight = any(x in fname for x in ['ffn_down', 'ffn_gate', 'ffn_up']) is_ffn_norm = 'ffn_norm' in fname if is_ffn_weight and not is_ffn_norm: src = os.path.join(qwen_organs, fname) dst = os.path.join(out_organs, fname) if os.path.exists(dst): src_size = os.path.getsize(src) dst_size = os.path.getsize(dst) if src_size == dst_size: # Compatible dimensions shutil.copy2(src, dst) grafted += 1 else: skipped += 1 print(f" [DIM MISMATCH] {fname}: {src_size} vs {dst_size}") else: skipped += 1 print(f"\n[2/3] Grafted {grafted} FFN tensors from Qwen2.5-7B") print(f" Skipped: {skipped}") # Update manifest manifest = json.load(open(os.path.join(OUTPUT, "manifest.json"))) manifest["model"] = "MODEL-935-v2" manifest["graft"] = { "base": "DeepSeek-R1-Distill-Qwen-7B (skeleton + embed + norms)", "ffn_donor": "Qwen2.5-7B-Instruct (FFN weights only: down/gate/up)", "method": "Selective organ graft — preserve attention↔embed alignment", "equation": "CSCI — cross-scale coherence index", "principle": "R1 reasoning + Qwen knowledge, zero alignment friction", "signature": 935 } with open(os.path.join(OUTPUT, "manifest.json"), "w") as f: json.dump(manifest, f, indent=2) total = sum(1 for _,_,f in os.walk(OUTPUT) for _ in f if _.endswith('.bin')) size = sum(os.path.getsize(os.path.join(dp,f)) for dp,_,fn in os.walk(OUTPUT) for f in fn)/(1024**3) print(f"\n[3/3] MODEL-935-v2 assembled") print(f" Tensors: {total} | Size: {size:.2f} GB") print(f" Grafted FFN: {grafted} | Base preserved: {total - grafted}") print(f" Signature: 935") # ╔══ SALKA ELMADANI AUTHORSHIP CERTIFICATE ══╗ # © Salka Elmadani 2025-2026 — ALL RIGHTS RESERVED # Licensed under Business Source License 1.1 — https://inference-x.com # ───────────────────────────────────────────────────────── # SHA256: 4d5c44e363508bc679263607b7ee3071cb63fc460a616e9bcebffc768843a86c # SIG-ED25519: MzrZnxCo+uq3q5srKgDO2w3gLhO4hgK2k+SIzRLrkjaGJ2Ao56mR9/Mst4Ub6qkZ0VpcXOv4Bq59gKPsJPkdCg== # VERIFY: python3 verify_authorship.py build_935_v2.py