This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Inference for Llama-2 Transformer model in pure C. | |
Example compile: (see README for more details) | |
$ gcc -O3 -o run run.c -lm | |
Then run with: | |
$ ./run | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Based on: https://github.com/oobabooga/text-generation-webui/blob/main/convert-to-torch.py | |
# License: GNU Affero General Public License v3.0 | |
# | |
# | |
# This script converts a transformers model using a custom shard size. | |
# | |
# Load a model from a directory and shard it into 2GB chunks: | |
# python reshard-causallm-model.py --src-model gpt-j-6B --out-path gpt-j-6B-sharded --torch_dtype float16 --max-shard-size 2GB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def is_valid_jsonl(file_path): | |
with open(file_path, 'r', encoding='utf-8') as f: | |
for line_number, line in enumerate(f, start=1): | |
try: | |
json.loads(line) | |
except json.JSONDecodeError: | |
print(f'Invalid JSON on line {line_number}: {line}') | |
return False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import heapq | |
import shutil | |
import argparse | |
def get_directory_size(directory): | |
""" | |
Calculate the size of the directory. | |
Parameters: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import os | |
import sys | |
import random | |
import codecs | |
import json | |
from bs4 import BeautifulSoup | |
from multiprocessing import Pool | |
import colorama | |
from colorama import Fore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!wget https://model-server.zqevans2.workers.dev/jmann-small-190k.ckpt -O /content/drive/MyDrive/AI/models/jmann-small-190k.ckpt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
du -cBM --max-depth=1 2> >(grep -v 'Permission denied') | grep -v 'cannot access' | sort -n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! pip install kaggle | |
! mkdir ~/.kaggle | |
!cp /content/drive/MyDrive/kaggle.json ~/.kaggle/kaggle.json | |
# AN INDIVIDUAL .ckpt FILE | |
LINK='omgsupportteam/dd-tb-fine-22-10-11-22-42-36' | |
FILENAME = 'last.ckpt' | |
! kaggle datasets download $LINK -f $FILENAME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, json | |
from dateutil.parser import parse | |
from datetime import datetime, timezone, timedelta | |
with open("/var/colab/app.log", 'r') as fileData: | |
for textline in fileData: | |
if " started" in textline: | |
time = parse (json.loads(textline)['time']) | |
now = datetime.now(time.tzinfo) | |
later = time + timedelta(hours=4) | |
print(now-time, "session started") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
def prune_it(p): | |
print(f"prunin' in path: {p}") | |
size_initial = os.path.getsize(p) | |
nsd = dict() | |
sd = torch.load(p, map_location="cpu") | |
print(sd.keys()) | |
for k in sd.keys(): | |
if k != "optimizer_states": | |
nsd[k] = sd[k] |