Skip to content

Instantly share code, notes, and snippets.

"""
This script exports the AutoGPT-Q Llama 2 weights in llama2rs.bin format.
"""
import pathlib
import click
import struct
import torch
from torch import nn
from auto_gptq import AutoGPTQForCausalLM
from auto_gptq.nn_modules import qlinear
#!/usr/local/bin/python3
"""
This script should idempotently grab the stuff that's newly added to Pocket to pocket.md
You'll need to install https://airtable-python-wrapper.readthedocs.io, i.e. via:
$ pip3 install airtable-python-wrapper
and, of course, sign up for an Airtable account (free seems to work fine).
"""
@rachtsingh
rachtsingh / heap.c
Created September 15, 2018 22:19
Trying to access heap memory after it's been free'd
#include <stdio.h>
#include <stdlib.h>
// void * return type means that it returns a naked pointer, which is just an address.
void *foo(void) {
long *bar_ptr = malloc(sizeof(long));
*bar_ptr = 5;
printf("The data is held at address: %p, holds %ld bytes\n", bar_ptr, sizeof(long));
free(bar_ptr);
return (void *) bar_ptr;
@rachtsingh
rachtsingh / stack.c
Created September 15, 2018 22:14
Trying to use stack memory after it's gone
#include <stdio.h>
// void * return type means that it returns a naked pointer, which is just an address.
void *foo(void) {
long bar = 5;
printf("bar's address is: %p, holds %ld bytes\n", &bar, sizeof(long));
long *ret = &bar;
return (void *) ret; // ret is a pointer to a long, but we just turn it into a regular address
// note that the previous line doesn't *do* anything, it just gets the compiler off our back
}
import numpy as np
from matplotlib import pyplot as plt
def sample_gamma(alpha):
total = 0
scale = 1.
if (alpha < 1.0):
scale *= (1 - np.random.uniform() ** (1.0 / alpha))
total += 1
@rachtsingh
rachtsingh / Distributions.cu
Created January 18, 2018 18:02
Distributions.cu
#include "ATen/NativeFunctions.h"
#include "ATen/Dispatch.h"
#include "ATen/cuda/CUDAApplyUtils.cuh"
#include <curand.h>
#include <curand_kernel.h>
#include <curand_philox4x32_x.h>
#include <utility>
#include <functional>
#include <nvfunctional>

Keybase proof

I hereby claim:

  • I am rachtsingh on github.
  • I am rachitsingh (https://keybase.io/rachitsingh) on keybase.
  • I have a public key ASAtaQuPwR-0aYEy7PkgjheFZh-b4C2ZfWG7ssWrHRDi8Qo

To claim this, I am signing this object:

[01/30/17 13:57:47 INFO] Using GPU(s): 1
[01/30/17 13:57:47 INFO] Loading data from '../data/translate-train.t7'...
[01/30/17 13:57:51 INFO] * vocabulary size: source = 50004; target = 50004
[01/30/17 13:57:51 INFO] * additional features: source = 0; target = 0
[01/30/17 13:57:51 INFO] * maximum sequence length: source = 50; target = 51
[01/30/17 13:57:51 INFO] * number of training sentences: 100000
[01/30/17 13:57:51 INFO] * maximum batch size: 64
[01/30/17 13:57:51 INFO] Building model...
[01/30/17 13:57:55 INFO] * using input feeding
[01/30/17 13:57:56 INFO] Initializing parameters...
[01/30/17 12:34:39 INFO] Using GPU(s): 1
[01/30/17 12:34:39 INFO] Loading data from '../data/translate-train.t7'...
[01/30/17 12:34:44 INFO] * vocabulary size: source = 50004; target = 50004
[01/30/17 12:34:44 INFO] * additional features: source = 0; target = 0
[01/30/17 12:34:44 INFO] * maximum sequence length: source = 50; target = 51
[01/30/17 12:34:44 INFO] * number of training sentences: 100000
[01/30/17 12:34:44 INFO] * maximum batch size: 64
[01/30/17 12:34:44 INFO] Building model...
[01/30/17 12:34:48 INFO] * using input feeding
[01/30/17 12:34:48 INFO] Initializing parameters...
@rachtsingh
rachtsingh / batch_norm_no_opt.log
Created January 1, 2017 06:22
Batch norm with no memory optimization on the nn.BatchNormalization modules
Loading data from 'data/small-train.t7'...
* vocabulary size: source = 50004; target = 50004
* additional features: source = 0; target = 0
* maximum sequence length: source = 50; target = 51
* number of training sentences: 100000
* maximum batch size: 64
Building model...
* using input feeding
Initializing parameters...
* number of parameters: 84834004