Skip to content

Instantly share code, notes, and snippets.

View bigsnarfdude's full-sized avatar

BigsnarfDude bigsnarfdude

View GitHub Profile
@bigsnarfdude
bigsnarfdude / cuda_basics.py
Created May 20, 2024 04:07
cuda_basics.py
url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Cute_dog.jpg/1600px-Cute_dog.jpg?20140729055059'
import torch, os, math, gzip, pickle
import matplotlib.pyplot as plt
from urllib.request import urlretrieve
from pathlib import Path
from torch import tensor
import torchvision as tv
import torchvision.transforms.functional as tvf
from torchvision import io
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bigsnarfdude
bigsnarfdude / lm-eval.sh
Last active May 17, 2024 23:34
lm-eval.sh
MODEL_ID="vincentoh/llama3-alpaca-dpo-instruct"
TRUST_REMOTE_CODE="yes"
DTYPE="bfloat16"
BATCH_SIZE="auto"
CUDA_DEVICES=0
sudo apt update
sudo apt install -y screen vim git-lfs
pip install -q requests accelerate sentencepiece pytablewriter einops protobuf huggingface_hub==0.21.4
@bigsnarfdude
bigsnarfdude / safetensors_to_GGUF.md
Last active May 15, 2024 15:42
safetensors to GGUF

safetensors2llama.cpp


from huggingface_hub import snapshot_download
model_id="vincentoh/llama3_70b_no_robot_fsdp_qlora"
snapshot_download(repo_id=model_id, local_dir="llama70b-hf",local_dir_use_symlinks=False, revision="main")

from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda"
model_id = "vincentoh/llama3_70b_no_robot_fsdp_qlora"
model = AutoModelForCausalLM.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
messages = [{"role": "user", "content": "Why is the sky blue?"},]
@bigsnarfdude
bigsnarfdude / llama3_70b_fsdp_qlora.ipynb
Last active May 14, 2024 14:13
llama3_70b_fsdp_qlora.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bigsnarfdude
bigsnarfdude / llama3_8b_qlora_orpo.ipynb
Last active May 13, 2024 23:12
llama3_8b_qlora_orpo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bigsnarfdude
bigsnarfdude / no_robots2json.py
Created May 13, 2024 13:09
no_robots2json.py
from datasets import load_dataset
# Convert dataset to OAI messages
system_message = """You are Llama, an AI assistant created by BigSnarfDude to be helpful and honest. Your knowledge spans a wide range of topics, allowing you to engage in substantive conversations and provide analysis on complex subjects."""
def create_conversation(sample):
if sample["messages"][0]["role"] == "system":
return sample
else:
sample["messages"] = [{"role": "system", "content": system_message}] + sample["messages"]
@bigsnarfdude
bigsnarfdude / tableVRAM.md
Last active May 13, 2024 12:54
tableVRAM.md

Method	Bits	7B	13B	30B	65B	8x7B
Full	16	160GB	320GB	600GB	1200GB	1000GB
Freeze	16	20GB	40GB	120GB	240GB	200GB
LoRA	16	16GB	32GB	80GB	160GB	120GB
QLoRA	8	10GB	16GB	40GB	80GB	80GB
QLoRA	4	6GB	12GB	24GB	48GB	32GB

@bigsnarfdude
bigsnarfdude / llama3_instruct_inference.py
Created May 12, 2024 19:42
llama3_instruct_inference.py
import transformers
import torch
from huggingface_hub import login
login(token = '')
model_id = "meta-llama/Meta-Llama-3-8B-Instruct"