PMPF on google colab

#2
by Naphula - opened
Occult AI org

PMPF_colab

PMPF now works on google colab using T4. It is slower with bfloat16 but twice the VRAM as my local setup. In theory I should be able to finetune mistral nemo on it. And should be able to set up a runpod later too. So, I am merging 24B on my PC while the 8B finetunes on colab (script is named 7B but its actually 8B llama)

with this code, it should auto-save adapter checkpoints to drive, allowing to resume in case the runtime is terminated

import os

# 1. Create the backup folder on Drive if it doesn't exist
!mkdir -p /content/drive/MyDrive/Finetune_Backup

# 2. If there is already a local adapter folder, move its contents to Drive so we don't lose them
if os.path.exists("/content/Finetune/finetuned_adapter"):
    !cp -r /content/Finetune/finetuned_adapter/* /content/drive/MyDrive/Finetune_Backup/
    !rm -rf /content/Finetune/finetuned_adapter

# 3. Create the "Magic Link" (Symlink)
# This tells Linux: "Whenever the script writes to the local folder, actually put it on Google Drive"
!ln -s /content/drive/MyDrive/Finetune_Backup /content/Finetune/finetuned_adapter

print("Symlink created! Your checkpoints will now save directly to Google Drive in real-time.")

and this code downloads them all in 1 zip

import shutil
import os

# 1. Zip the entire folder containing all checkpoints
print("Zipping all epoch checkpoints...")
shutil.make_archive("/content/all_epochs_adapters", 'zip', "/content/Finetune/finetuned_adapter")

# 2. Copy the zip file to your Google Drive so it's safe
print("Copying to Google Drive...")
shutil.copy("/content/all_epochs_adapters.zip", "/content/drive/MyDrive/Finetune/all_epochs_adapters.zip")

print("Done! You can now find 'all_epochs_adapters.zip' in your Google Drive.")

Sign up or log in to comment