import os import shutil from huggingface_hub import snapshot_download BRAIN_VAULT = "/data/Brain_Weights" OLD_MODEL = "Qwen_Qwen2.5-72B-Instruct-AWQ" NEW_MODEL = "unsloth/Qwen2.5-32B-Instruct-bnb-4bit" print("--- INITIATING BRAIN REPLACEMENT PROTOCOL ---") old_path = os.path.join(BRAIN_VAULT, OLD_MODEL) if os.path.exists(old_path): print(f"Purging oversized AWQ neural structure from {old_path}...") shutil.rmtree(old_path, ignore_errors=True) os.makedirs(BRAIN_VAULT, exist_ok=True) print(f"Downloading Native 32B BNB Neural Architecture: {NEW_MODEL}") try: model_path = snapshot_download( repo_id=NEW_MODEL, cache_dir=BRAIN_VAULT, local_dir=os.path.join(BRAIN_VAULT, NEW_MODEL.replace("/", "_")), ignore_patterns=["*.pt", "*.bin"] ) print("\n✅ SUCCESS: Native 32B BNB weights anchored to persistent substrate.") except Exception as e: print(f"\n❌ FATAL ERROR: The download failed. Reason: {e}")