This file contains 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
/* compress.c */ | |
/* Copyright 1994 by Philip Gage */ | |
#include <stdio.h> | |
#define BLOCKSIZE 5000 /* Maximum block size */ | |
#define HASHSIZE 4096 /* Size of hash table */ | |
#define MAXCHARS 200 /* Char set per block */ | |
#define THRESHOLD 3 /* Minimum pair count */ |
This file contains 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
from argparse import ArgumentParser, Namespace | |
from pathlib import Path | |
from random import shuffle | |
from tqdm import tqdm | |
from openwebtext import OpenWebTextLoader, shuffle, take | |
parser = ArgumentParser() | |
parser.add_argument('-j', '--jobs', type=int, default=2) |
This file contains 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
from os import getenv | |
from pathlib import Path | |
from typing import Callable | |
import numpy as np | |
import nvidia.dali.fn as fn | |
import nvidia.dali.ops as ops | |
import torch as T | |
from nvidia.dali.pipeline import pipeline_def | |
from nvidia.dali.plugin.pytorch import DALIGenericIterator, LastBatchPolicy |
This file contains 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
/** | |
* reset-device.cc | |
* | |
* Simple program which resets a devices if kernel launch was failed. This | |
* could happend due to invalida program counter as an example. | |
* | |
* $ nvcc -o reset-device reset-device.cc | |
* $ ./reset-device | |
* cudaSuccess: no error | |
*/ |
This file contains 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 | |
"""Py + Deps = <3: Simple script to install only dependencies of a python | |
package which follows PEP-517/PEP-518 guidelines. | |
""" | |
from argparse import ArgumentParser, Namespace | |
from dataclasses import dataclass, field | |
from pathlib import Path | |
from subprocess import check_call | |
from sys import version_info |
This file contains 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 python3 | |
"""Little script for generating a download list for fetching model weights and | |
configuration files of a model from HuggingFace Hub. With download list is | |
ready, you can easily fetch all files with throatling and supspending or | |
resuming with `aria2c` as an example: aria2c -c -i index.txt. | |
""" | |
from argparse import ArgumentParser, Namespace | |
from pathlib import Path |
This file contains 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 | |
from argparse import ArgumentParser, Namespace | |
from datetime import datetime | |
from json import dump | |
from os import rename | |
from pathlib import Path | |
from urllib.parse import parse_qs, urlparse | |
from xml.sax import ContentHandler | |
from xml.sax import parse as parse_xml |
This file contains 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 numpy as np | |
def pack(xs, dtype='q4_0'): | |
assert dtype == 'q4_0', 'Only quantized int4 type is supported.' | |
assert xs.size % 2 == 0, 'Only arrays of even length.' | |
# Estimate magnitude of array elements and its inverse. | |
amax = abs(xs).max() | |
magnitude = amax / 0b0111 | |
precision = np.float32(1) / magnitude if magnitude else np.float32(0) |
This file contains 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
from typing import Any, Callable | |
import flax.linen as nn | |
import jax | |
import jax.experimental.host_callback | |
import jax.numpy as jnp | |
from flax.linen.initializers import delta_orthogonal, variance_scaling | |
from phase_diagram import phase_boundary |
This file contains 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 pandas as pd | |
def pick_uniques(df: pd.DataFrame, size: int = 100): | |
assert a.index.is_monotonic | |
assert 'uid' in df | |
index = [] | |
uids = set() | |
for i, uid in df.uid.items(): | |
if uid in uids: |
NewerOlder